Skip to content

Commit

Permalink
Fix conflicts
Browse files Browse the repository at this point in the history
Signed-off-by: Rohit Nayak <[email protected]>
  • Loading branch information
rohit-nayak-ps committed Aug 29, 2024
1 parent 5069b0f commit d96a4ad
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 190 deletions.
7 changes: 0 additions & 7 deletions go/mysql/json/marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,7 @@ func MarshalSQLValue(buf []byte) (*sqltypes.Value, error) {
if err != nil {
return nil, err
}
<<<<<<< HEAD
newVal := sqltypes.MakeTrusted(querypb.Type_JSON, jsonVal.MarshalSQLTo(nil))
if err != nil {
return nil, err
}
=======

newVal := sqltypes.MakeTrusted(querypb.Type_RAW, jsonVal.MarshalSQLTo(nil))
>>>>>>> e89f684b09 (JSON Encoding: Use Type_RAW for marshalling json (#16637))
return &newVal, nil
}
24 changes: 0 additions & 24 deletions go/test/endtoend/vtgate/queries/dml/insert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -470,29 +470,6 @@ func TestMixedCases(t *testing.T) {
// final check count on the lookup vindex table.
utils.AssertMatches(t, mcmp.VtConn, "select count(*) from lkp_mixed_idx", "[[INT64(12)]]")
}
<<<<<<< HEAD
=======

// TestInsertAlias test the alias feature in insert statement.
func TestInsertAlias(t *testing.T) {
mcmp, closer := start(t)
defer closer()

// initial record
mcmp.Exec("insert into user_tbl(id, region_id, name) values (1, 1,'foo'),(2, 2,'bar'),(3, 3,'baz'),(4, 4,'buzz')")

qr := mcmp.Exec("insert into user_tbl(id, region_id, name) values (2, 2, 'foo') as new on duplicate key update name = new.name")
assert.EqualValues(t, 2, qr.RowsAffected)

// this validates the record.
mcmp.Exec("select id, region_id, name from user_tbl order by id")

qr = mcmp.Exec("insert into user_tbl(id, region_id, name) values (3, 3, 'foo') as new(m, n, p) on duplicate key update name = p")
assert.EqualValues(t, 2, qr.RowsAffected)

// this validates the record.
mcmp.Exec("select id, region_id, name from user_tbl order by id")
}

// TestInsertJson tests that selected json values are encoded correctly.
func TestInsertJson(t *testing.T) {
Expand All @@ -516,4 +493,3 @@ func TestInsertJson(t *testing.T) {
utils.AssertMatches(t, mcmp.VtConn, `select * from uks.j_utbl order by id`,
`[[INT64(1) JSON("{}")] [INT64(2) JSON("{\"a\": 1, \"b\": 2}")] [INT64(3) JSON("{\"k\": \"a\"}")] [INT64(4) JSON("{\"date\": 1629849600, \"keywordSourceId\": 930701976723823, \"keywordSourceVersionId\": 210825230433}")]]`)
}
>>>>>>> e89f684b09 (JSON Encoding: Use Type_RAW for marshalling json (#16637))
144 changes: 14 additions & 130 deletions go/vt/proto/query/query.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 4 additions & 19 deletions go/vt/sqlparser/parsed_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"reflect"
"testing"

"github.com/stretchr/testify/require"

"vitess.io/vitess/go/sqltypes"
querypb "vitess.io/vitess/go/vt/proto/query"

Expand Down Expand Up @@ -86,7 +88,7 @@ func TestGenerateQuery(t *testing.T) {
"v1": sqltypes.ValueBindVariable(sqltypes.MakeTrusted(querypb.Type_JSON, []byte(`{"key": "value"}`))),
"v2": sqltypes.ValueBindVariable(sqltypes.MakeTrusted(querypb.Type_RAW, []byte(`json_object("k", "v")`))),
},
output: `insert into t values ('{"key": "value"}', json_object("k", "v"))`,
output: `insert into t values ('{\"key\": \"value\"}', json_object("k", "v"))`,
}, {
desc: "list bind vars 0 arguments",
query: "select * from a where id in ::vals",
Expand Down Expand Up @@ -144,24 +146,8 @@ func TestGenerateQuery(t *testing.T) {
}

for _, tcase := range tcases {
<<<<<<< HEAD
tree, err := Parse(tcase.query)
if err != nil {
t.Errorf("parse failed for %s: %v", tcase.desc, err)
continue
}
buf := NewTrackedBuffer(nil)
buf.Myprintf("%v", tree)
pq := buf.ParsedQuery()
bytes, err := pq.GenerateQuery(tcase.bindVars, tcase.extras)
if err != nil {
assert.Equal(t, tcase.output, err.Error())
} else {
assert.Equal(t, tcase.output, string(bytes))
}
=======
t.Run(tcase.query, func(t *testing.T) {
tree, err := parser.Parse(tcase.query)
tree, err := Parse(tcase.query)
require.NoError(t, err)
buf := NewTrackedBuffer(nil)
buf.Myprintf("%v", tree)
Expand All @@ -173,7 +159,6 @@ func TestGenerateQuery(t *testing.T) {
assert.Equal(t, tcase.output, bytes)
}
})
>>>>>>> e89f684b09 (JSON Encoding: Use Type_RAW for marshalling json (#16637))
}
}

Expand Down
6 changes: 0 additions & 6 deletions proto/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,8 @@ enum Type {
// BITNUM specifies a base 2 binary type (unquoted varbinary).
// Properties: 34, IsText.
BITNUM = 4130;
<<<<<<< HEAD
=======
// VECTOR specifies a VECTOR type
// Properties: 35, IsQuoted.
VECTOR = 2083;
// RAW specifies a type which won't be quoted but the value used as-is while encoding.
RAW = 2084;
>>>>>>> e89f684b09 (JSON Encoding: Use Type_RAW for marshalling json (#16637))
}

// Value represents a typed value.
Expand Down
8 changes: 4 additions & 4 deletions web/vtadmin/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d96a4ad

Please sign in to comment.