Skip to content

Commit 37976af

Browse files
authored
Merge pull request #3254 from dolthub/nicktobey/update_json
[no-release-notes] Tweak ComparableJSON interface to take context parameter and have mor…
2 parents 56af719 + a12c63f commit 37976af

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

sql/expression/function/json/json_type.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func (j JSONType) Eval(ctx *sql.Context, row sql.Row) (interface{}, error) {
106106
}
107107

108108
if comparableDoc, ok := doc.(types.ComparableJSON); ok {
109-
return comparableDoc.Type(ctx)
109+
return comparableDoc.JsonType(ctx)
110110
}
111111

112112
val, err := doc.ToInterface(ctx)

sql/types/json_value.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ type SearchableJSON interface {
9595

9696
type ComparableJSON interface {
9797
sql.JSONWrapper
98-
Compare(other interface{}) (int, error)
99-
Type(ctx context.Context) (string, error)
98+
Compare(ctx context.Context, other interface{}) (int, error)
99+
JsonType(ctx context.Context) (string, error)
100100
}
101101

102102
// MutableJSON is a JSON value that can be efficiently modified. These modifications return the new value, but they
@@ -510,11 +510,11 @@ func CompareJSON(ctx context.Context, a, b interface{}) (int, error) {
510510
}
511511

512512
if comparableA, ok := a.(ComparableJSON); ok {
513-
return comparableA.Compare(b)
513+
return comparableA.Compare(ctx, b)
514514
}
515515

516516
if comparableB, ok := b.(ComparableJSON); ok {
517-
result, err := comparableB.Compare(a)
517+
result, err := comparableB.Compare(ctx, a)
518518
return -result, err
519519
}
520520

0 commit comments

Comments
 (0)