ToRow implements the interface doltdb.RootObjectDiff.
(ctx *sql.Context)
| 96 | |
| 97 | // ToRow implements the interface doltdb.RootObjectDiff. |
| 98 | func (diff RootObjectDiff) ToRow(ctx *sql.Context) (_ sql.Row, err error) { |
| 99 | var baseValue any |
| 100 | var ourValue any |
| 101 | var theirValue any |
| 102 | var ourChange any |
| 103 | var theirChange any |
| 104 | if diff.AncestorValue != nil { |
| 105 | baseValue, err = diff.Type.IoOutput(ctx, diff.AncestorValue) |
| 106 | if err != nil { |
| 107 | return nil, err |
| 108 | } |
| 109 | } |
| 110 | if diff.OurValue != nil { |
| 111 | ourValue, err = diff.Type.IoOutput(ctx, diff.OurValue) |
| 112 | if err != nil { |
| 113 | return nil, err |
| 114 | } |
| 115 | } |
| 116 | if diff.TheirValue != nil { |
| 117 | theirValue, err = diff.Type.IoOutput(ctx, diff.TheirValue) |
| 118 | if err != nil { |
| 119 | return nil, err |
| 120 | } |
| 121 | } |
| 122 | switch diff.OurChange { |
| 123 | case RootObjectDiffChange_Added: |
| 124 | ourChange = "added" |
| 125 | case RootObjectDiffChange_Deleted: |
| 126 | ourChange = "deleted" |
| 127 | case RootObjectDiffChange_Modified: |
| 128 | ourChange = "modified" |
| 129 | case RootObjectDiffChange_NoChange: |
| 130 | ourChange = "no_change" |
| 131 | } |
| 132 | switch diff.TheirChange { |
| 133 | case RootObjectDiffChange_Added: |
| 134 | theirChange = "added" |
| 135 | case RootObjectDiffChange_Deleted: |
| 136 | theirChange = "deleted" |
| 137 | case RootObjectDiffChange_Modified: |
| 138 | theirChange = "modified" |
| 139 | case RootObjectDiffChange_NoChange: |
| 140 | ourChange = "no_change" |
| 141 | } |
| 142 | return sql.Row{diff.FromHash, baseValue, ourValue, ourChange, theirValue, theirChange, diff.FieldName}, nil |
| 143 | } |
| 144 | |
| 145 | // DiffFromRow converts a row to a conflict diff. |
| 146 | func DiffFromRow(ctx *sql.Context, conflict doltdb.ConflictRootObject, row sql.Row) (_ doltdb.RootObjectDiff, err error) { |