MCPcopy Create free account
hub / github.com/dolthub/doltgresql / DiffRootObjects

Method DiffRootObjects

core/procedures/root_object.go:46–136  ·  view source on GitHub ↗

DiffRootObjects implements the interface objinterface.Collection.

(ctx context.Context, fromHash string, o objinterface.RootObject, t objinterface.RootObject, a objinterface.RootObject)

Source from the content-addressed store, hash-verified

44
45// DiffRootObjects implements the interface objinterface.Collection.
46func (pgp *Collection) DiffRootObjects(ctx context.Context, fromHash string, o objinterface.RootObject, t objinterface.RootObject, a objinterface.RootObject) ([]objinterface.RootObjectDiff, objinterface.RootObject, error) {
47 // We ignore many fields when diffing, as differences in these fields would result in a different procedure due to overloading
48 // For example, "proc_name(text)" and "proc_name(varchar)" cannot produce a conflict as they're different procedures
49 ours := o.(Procedure)
50 theirs := t.(Procedure)
51 ancestor, hasAncestor := a.(Procedure)
52 var diffs []objinterface.RootObjectDiff
53 {
54 ourParamNames := strings.Join(ours.ParameterNames, ",")
55 theirParamNames := strings.Join(theirs.ParameterNames, ",")
56 ancParamNames := strings.Join(ancestor.ParameterNames, ",")
57 diff := objinterface.RootObjectDiff{
58 Type: pgtypes.Text,
59 FromHash: fromHash,
60 FieldName: FIELD_NAME_PARAMETER_NAMES,
61 }
62 if pgmerge.DiffValues(&diff, ourParamNames, theirParamNames, ancParamNames, hasAncestor) {
63 diffs = append(diffs, diff)
64 } else {
65 ours.ParameterNames = strings.Split(diff.OurValue.(string), ",")
66 }
67 }
68 {
69 ourModes := ours.ParameterModesAsString()
70 theirModes := theirs.ParameterModesAsString()
71 ancModes := ancestor.ParameterModesAsString()
72 diff := objinterface.RootObjectDiff{
73 Type: pgtypes.Text,
74 FromHash: fromHash,
75 FieldName: FIELD_NAME_PARAMETER_MODES,
76 }
77 if pgmerge.DiffValues(&diff, ourModes, theirModes, ancModes, hasAncestor) {
78 diffs = append(diffs, diff)
79 } else {
80 paramModes, err := ParameterModesFromString(diff.OurValue.(string))
81 if err != nil {
82 return nil, nil, err
83 }
84 ours.ParameterModes = paramModes
85 }
86 }
87 if ours.Definition != theirs.Definition {
88 diff := objinterface.RootObjectDiff{
89 Type: pgtypes.Text,
90 FromHash: fromHash,
91 FieldName: FIELD_NAME_DEFINITION,
92 }
93 if pgmerge.DiffValues(&diff, ours.GetInnerDefinition(), theirs.GetInnerDefinition(), ancestor.GetInnerDefinition(), hasAncestor) {
94 diffs = append(diffs, diff)
95 } else {
96 ours.Definition = ours.ReplaceDefinition(diff.OurValue.(string))
97 }
98 }
99 if ours.ExtensionName != theirs.ExtensionName {
100 diff := objinterface.RootObjectDiff{
101 Type: pgtypes.Text,
102 FromHash: fromHash,
103 FieldName: FIELD_NAME_EXTENSION_NAME,

Callers

nothing calls this directly

Calls 4

ParameterModesFromStringFunction · 0.85
GetInnerDefinitionMethod · 0.45
ReplaceDefinitionMethod · 0.45

Tested by

no test coverage detected