diff --git a/go/mysql/json/marshal.go b/go/mysql/json/marshal.go index d1a0072ccbb..97d14a336c8 100644 --- a/go/mysql/json/marshal.go +++ b/go/mysql/json/marshal.go @@ -175,6 +175,6 @@ func MarshalSQLValue(buf []byte) (*sqltypes.Value, error) { return nil, err } - newVal := sqltypes.MakeTrusted(querypb.Type_JSON, jsonVal.MarshalSQLTo(nil)) + newVal := sqltypes.MakeTrusted(querypb.Type_RAW, jsonVal.MarshalSQLTo(nil)) return &newVal, nil } diff --git a/go/test/endtoend/vtgate/queries/dml/insert_test.go b/go/test/endtoend/vtgate/queries/dml/insert_test.go index 77a8dfe017a..941c60c9c60 100644 --- a/go/test/endtoend/vtgate/queries/dml/insert_test.go +++ b/go/test/endtoend/vtgate/queries/dml/insert_test.go @@ -470,3 +470,50 @@ 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) { + mcmp, closer := start(t) + defer closer() + + mcmp.Exec(`insert into j_tbl(id, jdoc) values (1, '{}'), (2, '{"a": 1, "b": 2}')`) + mcmp.Exec(`select * from j_tbl order by id`) + + mcmp.Exec(`insert into j_tbl(id, jdoc) select 3, json_object("k", "a")`) + mcmp.Exec(`select * from j_tbl order by id`) + + mcmp.Exec(`insert into j_tbl(id, jdoc) select 4,JSON_OBJECT( + 'date', CAST(1629849600 AS UNSIGNED), + 'keywordSourceId', CAST(930701976723823 AS UNSIGNED), + 'keywordSourceVersionId', CAST(210825230433 AS UNSIGNED) + )`) + mcmp.Exec(`select * from j_tbl order by id`) + + utils.Exec(t, mcmp.VtConn, `insert into uks.j_utbl(id, jdoc) select * from sks.j_tbl`) + 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)) diff --git a/go/test/endtoend/vtgate/queries/dml/main_test.go b/go/test/endtoend/vtgate/queries/dml/main_test.go index c00e27fe3a0..0c4d58aa614 100644 --- a/go/test/endtoend/vtgate/queries/dml/main_test.go +++ b/go/test/endtoend/vtgate/queries/dml/main_test.go @@ -133,7 +133,7 @@ func start(t *testing.T) (utils.MySQLCompare, func()) { tables := []string{ "s_tbl", "num_vdx_tbl", "user_tbl", "order_tbl", "oevent_tbl", "oextra_tbl", - "auto_tbl", "oid_vdx_tbl", "unq_idx", "nonunq_idx", "u_tbl", "mixed_tbl", "lkp_map_idx", + "auto_tbl", "oid_vdx_tbl", "unq_idx", "nonunq_idx", "u_tbl", "mixed_tbl", "lkp_map_idx", "j_tbl", "j_utbl", } for _, table := range tables { // TODO (@frouioui): following assertions produce different results between MySQL and Vitess diff --git a/go/test/endtoend/vtgate/queries/dml/sharded_schema.sql b/go/test/endtoend/vtgate/queries/dml/sharded_schema.sql index 3310724d420..cc24737a0fa 100644 --- a/go/test/endtoend/vtgate/queries/dml/sharded_schema.sql +++ b/go/test/endtoend/vtgate/queries/dml/sharded_schema.sql @@ -86,3 +86,10 @@ create table lkp_mixed_idx keyspace_id varbinary(20), primary key (lkp_key) ) Engine = InnoDB; + +create table j_tbl +( + id bigint, + jdoc json, + primary key (id) +) Engine = InnoDB; \ No newline at end of file diff --git a/go/test/endtoend/vtgate/queries/dml/unsharded_schema.sql b/go/test/endtoend/vtgate/queries/dml/unsharded_schema.sql index 4d2ad06618a..cd64605ad20 100644 --- a/go/test/endtoend/vtgate/queries/dml/unsharded_schema.sql +++ b/go/test/endtoend/vtgate/queries/dml/unsharded_schema.sql @@ -34,4 +34,11 @@ values (0, 1, 1000); insert into auto_seq(id, next_id, cache) values (0, 666, 1000); insert into mixed_seq(id, next_id, cache) -values (0, 1, 1000); \ No newline at end of file +values (0, 1, 1000); + +create table j_utbl +( + id bigint, + jdoc json, + primary key (id) +) Engine = InnoDB; \ No newline at end of file diff --git a/go/test/endtoend/vtgate/queries/dml/vschema.json b/go/test/endtoend/vtgate/queries/dml/vschema.json index a42a93d7403..72a949a49e4 100644 --- a/go/test/endtoend/vtgate/queries/dml/vschema.json +++ b/go/test/endtoend/vtgate/queries/dml/vschema.json @@ -188,6 +188,14 @@ "name": "hash" } ] + }, + "j_tbl": { + "column_vindexes": [ + { + "column": "id", + "name": "hash" + } + ] } } } \ No newline at end of file diff --git a/go/vt/proto/query/query.pb.go b/go/vt/proto/query/query.pb.go index 098ccad1032..c9e6e8cf485 100644 --- a/go/vt/proto/query/query.pb.go +++ b/go/vt/proto/query/query.pb.go @@ -315,6 +315,14 @@ const ( // BITNUM specifies a base 2 binary type (unquoted varbinary). // Properties: 34, IsText. Type_BITNUM Type = 4130 +<<<<<<< HEAD +======= + // VECTOR specifies a VECTOR type + // Properties: 35, IsQuoted. + Type_VECTOR Type = 2083 + // RAW specifies a type which won't be quoted but the value used as-is while encoding. + Type_RAW Type = 2084 +>>>>>>> e89f684b09 (JSON Encoding: Use Type_RAW for marshalling json (#16637)) ) // Enum value maps for Type. @@ -355,6 +363,11 @@ var ( 4128: "HEXNUM", 4129: "HEXVAL", 4130: "BITNUM", +<<<<<<< HEAD +======= + 2083: "VECTOR", + 2084: "RAW", +>>>>>>> e89f684b09 (JSON Encoding: Use Type_RAW for marshalling json (#16637)) } Type_value = map[string]int32{ "NULL_TYPE": 0, @@ -392,6 +405,11 @@ var ( "HEXNUM": 4128, "HEXVAL": 4129, "BITNUM": 4130, +<<<<<<< HEAD +======= + "VECTOR": 2083, + "RAW": 2084, +>>>>>>> e89f684b09 (JSON Encoding: Use Type_RAW for marshalling json (#16637)) } ) @@ -6433,6 +6451,7 @@ var file_query_proto_rawDesc = []byte{ 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x25, 0x0a, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x52, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, +<<<<<<< HEAD 0x12, 0x18, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x6e, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x6e, 0x67, 0x12, 0x3f, 0x0a, 0x1c, 0x70, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x5f, 0x74, 0x65, 0x72, 0x6d, 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, @@ -6550,6 +6569,108 @@ var file_query_proto_rawDesc = []byte{ 0x72, 0x6f, 0x74, 0x6f, 0x5a, 0x22, 0x76, 0x69, 0x74, 0x65, 0x73, 0x73, 0x2e, 0x69, 0x6f, 0x2f, 0x76, 0x69, 0x74, 0x65, 0x73, 0x73, 0x2f, 0x67, 0x6f, 0x2f, 0x76, 0x74, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +======= + 0x12, 0x35, 0x0a, 0x0a, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0e, 0x32, 0x16, 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x53, 0x63, 0x68, + 0x65, 0x6d, 0x61, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x09, 0x74, 0x61, + 0x62, 0x6c, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x74, 0x61, 0x62, 0x6c, 0x65, + 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x74, 0x61, + 0x62, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x22, 0x6d, 0x0a, 0x07, 0x55, 0x44, 0x46, 0x49, + 0x6e, 0x66, 0x6f, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x61, 0x67, 0x67, 0x72, 0x65, + 0x67, 0x61, 0x74, 0x69, 0x6e, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x61, 0x67, + 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x69, 0x6e, 0x67, 0x12, 0x2c, 0x0a, 0x0b, 0x72, 0x65, 0x74, + 0x75, 0x72, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0b, + 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x0a, 0x72, 0x65, 0x74, + 0x75, 0x72, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x22, 0xd5, 0x01, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x53, + 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x22, 0x0a, + 0x04, 0x75, 0x64, 0x66, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x71, 0x75, + 0x65, 0x72, 0x79, 0x2e, 0x55, 0x44, 0x46, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x75, 0x64, 0x66, + 0x73, 0x12, 0x58, 0x0a, 0x10, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x64, 0x65, 0x66, 0x69, 0x6e, + 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x71, 0x75, + 0x65, 0x72, 0x79, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x44, 0x65, 0x66, 0x69, 0x6e, + 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0f, 0x74, 0x61, 0x62, 0x6c, + 0x65, 0x44, 0x65, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0x42, 0x0a, 0x14, 0x54, + 0x61, 0x62, 0x6c, 0x65, 0x44, 0x65, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x6e, + 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x2a, + 0x92, 0x03, 0x0a, 0x09, 0x4d, 0x79, 0x53, 0x71, 0x6c, 0x46, 0x6c, 0x61, 0x67, 0x12, 0x09, 0x0a, + 0x05, 0x45, 0x4d, 0x50, 0x54, 0x59, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d, 0x4e, 0x4f, 0x54, 0x5f, + 0x4e, 0x55, 0x4c, 0x4c, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x50, + 0x52, 0x49, 0x5f, 0x4b, 0x45, 0x59, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x10, 0x02, 0x12, 0x13, 0x0a, + 0x0f, 0x55, 0x4e, 0x49, 0x51, 0x55, 0x45, 0x5f, 0x4b, 0x45, 0x59, 0x5f, 0x46, 0x4c, 0x41, 0x47, + 0x10, 0x04, 0x12, 0x15, 0x0a, 0x11, 0x4d, 0x55, 0x4c, 0x54, 0x49, 0x50, 0x4c, 0x45, 0x5f, 0x4b, + 0x45, 0x59, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x10, 0x08, 0x12, 0x0d, 0x0a, 0x09, 0x42, 0x4c, 0x4f, + 0x42, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x10, 0x10, 0x12, 0x11, 0x0a, 0x0d, 0x55, 0x4e, 0x53, 0x49, + 0x47, 0x4e, 0x45, 0x44, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x10, 0x20, 0x12, 0x11, 0x0a, 0x0d, 0x5a, + 0x45, 0x52, 0x4f, 0x46, 0x49, 0x4c, 0x4c, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x10, 0x40, 0x12, 0x10, + 0x0a, 0x0b, 0x42, 0x49, 0x4e, 0x41, 0x52, 0x59, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x10, 0x80, 0x01, + 0x12, 0x0e, 0x0a, 0x09, 0x45, 0x4e, 0x55, 0x4d, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x10, 0x80, 0x02, + 0x12, 0x18, 0x0a, 0x13, 0x41, 0x55, 0x54, 0x4f, 0x5f, 0x49, 0x4e, 0x43, 0x52, 0x45, 0x4d, 0x45, + 0x4e, 0x54, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x10, 0x80, 0x04, 0x12, 0x13, 0x0a, 0x0e, 0x54, 0x49, + 0x4d, 0x45, 0x53, 0x54, 0x41, 0x4d, 0x50, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x10, 0x80, 0x08, 0x12, + 0x0d, 0x0a, 0x08, 0x53, 0x45, 0x54, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x10, 0x80, 0x10, 0x12, 0x1a, + 0x0a, 0x15, 0x4e, 0x4f, 0x5f, 0x44, 0x45, 0x46, 0x41, 0x55, 0x4c, 0x54, 0x5f, 0x56, 0x41, 0x4c, + 0x55, 0x45, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x10, 0x80, 0x20, 0x12, 0x17, 0x0a, 0x12, 0x4f, 0x4e, + 0x5f, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x5f, 0x4e, 0x4f, 0x57, 0x5f, 0x46, 0x4c, 0x41, 0x47, + 0x10, 0x80, 0x40, 0x12, 0x0e, 0x0a, 0x08, 0x4e, 0x55, 0x4d, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x10, + 0x80, 0x80, 0x02, 0x12, 0x13, 0x0a, 0x0d, 0x50, 0x41, 0x52, 0x54, 0x5f, 0x4b, 0x45, 0x59, 0x5f, + 0x46, 0x4c, 0x41, 0x47, 0x10, 0x80, 0x80, 0x01, 0x12, 0x10, 0x0a, 0x0a, 0x47, 0x52, 0x4f, 0x55, + 0x50, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x10, 0x80, 0x80, 0x02, 0x12, 0x11, 0x0a, 0x0b, 0x55, 0x4e, + 0x49, 0x51, 0x55, 0x45, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x10, 0x80, 0x80, 0x04, 0x12, 0x11, 0x0a, + 0x0b, 0x42, 0x49, 0x4e, 0x43, 0x4d, 0x50, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x10, 0x80, 0x80, 0x08, + 0x1a, 0x02, 0x10, 0x01, 0x2a, 0x6b, 0x0a, 0x04, 0x46, 0x6c, 0x61, 0x67, 0x12, 0x08, 0x0a, 0x04, + 0x4e, 0x4f, 0x4e, 0x45, 0x10, 0x00, 0x12, 0x0f, 0x0a, 0x0a, 0x49, 0x53, 0x49, 0x4e, 0x54, 0x45, + 0x47, 0x52, 0x41, 0x4c, 0x10, 0x80, 0x02, 0x12, 0x0f, 0x0a, 0x0a, 0x49, 0x53, 0x55, 0x4e, 0x53, + 0x49, 0x47, 0x4e, 0x45, 0x44, 0x10, 0x80, 0x04, 0x12, 0x0c, 0x0a, 0x07, 0x49, 0x53, 0x46, 0x4c, + 0x4f, 0x41, 0x54, 0x10, 0x80, 0x08, 0x12, 0x0d, 0x0a, 0x08, 0x49, 0x53, 0x51, 0x55, 0x4f, 0x54, + 0x45, 0x44, 0x10, 0x80, 0x10, 0x12, 0x0b, 0x0a, 0x06, 0x49, 0x53, 0x54, 0x45, 0x58, 0x54, 0x10, + 0x80, 0x20, 0x12, 0x0d, 0x0a, 0x08, 0x49, 0x53, 0x42, 0x49, 0x4e, 0x41, 0x52, 0x59, 0x10, 0x80, + 0x40, 0x2a, 0xd7, 0x03, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0d, 0x0a, 0x09, 0x4e, 0x55, + 0x4c, 0x4c, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x04, 0x49, 0x4e, 0x54, + 0x38, 0x10, 0x81, 0x02, 0x12, 0x0a, 0x0a, 0x05, 0x55, 0x49, 0x4e, 0x54, 0x38, 0x10, 0x82, 0x06, + 0x12, 0x0a, 0x0a, 0x05, 0x49, 0x4e, 0x54, 0x31, 0x36, 0x10, 0x83, 0x02, 0x12, 0x0b, 0x0a, 0x06, + 0x55, 0x49, 0x4e, 0x54, 0x31, 0x36, 0x10, 0x84, 0x06, 0x12, 0x0a, 0x0a, 0x05, 0x49, 0x4e, 0x54, + 0x32, 0x34, 0x10, 0x85, 0x02, 0x12, 0x0b, 0x0a, 0x06, 0x55, 0x49, 0x4e, 0x54, 0x32, 0x34, 0x10, + 0x86, 0x06, 0x12, 0x0a, 0x0a, 0x05, 0x49, 0x4e, 0x54, 0x33, 0x32, 0x10, 0x87, 0x02, 0x12, 0x0b, + 0x0a, 0x06, 0x55, 0x49, 0x4e, 0x54, 0x33, 0x32, 0x10, 0x88, 0x06, 0x12, 0x0a, 0x0a, 0x05, 0x49, + 0x4e, 0x54, 0x36, 0x34, 0x10, 0x89, 0x02, 0x12, 0x0b, 0x0a, 0x06, 0x55, 0x49, 0x4e, 0x54, 0x36, + 0x34, 0x10, 0x8a, 0x06, 0x12, 0x0c, 0x0a, 0x07, 0x46, 0x4c, 0x4f, 0x41, 0x54, 0x33, 0x32, 0x10, + 0x8b, 0x08, 0x12, 0x0c, 0x0a, 0x07, 0x46, 0x4c, 0x4f, 0x41, 0x54, 0x36, 0x34, 0x10, 0x8c, 0x08, + 0x12, 0x0e, 0x0a, 0x09, 0x54, 0x49, 0x4d, 0x45, 0x53, 0x54, 0x41, 0x4d, 0x50, 0x10, 0x8d, 0x10, + 0x12, 0x09, 0x0a, 0x04, 0x44, 0x41, 0x54, 0x45, 0x10, 0x8e, 0x10, 0x12, 0x09, 0x0a, 0x04, 0x54, + 0x49, 0x4d, 0x45, 0x10, 0x8f, 0x10, 0x12, 0x0d, 0x0a, 0x08, 0x44, 0x41, 0x54, 0x45, 0x54, 0x49, + 0x4d, 0x45, 0x10, 0x90, 0x10, 0x12, 0x09, 0x0a, 0x04, 0x59, 0x45, 0x41, 0x52, 0x10, 0x91, 0x06, + 0x12, 0x0b, 0x0a, 0x07, 0x44, 0x45, 0x43, 0x49, 0x4d, 0x41, 0x4c, 0x10, 0x12, 0x12, 0x09, 0x0a, + 0x04, 0x54, 0x45, 0x58, 0x54, 0x10, 0x93, 0x30, 0x12, 0x09, 0x0a, 0x04, 0x42, 0x4c, 0x4f, 0x42, + 0x10, 0x94, 0x50, 0x12, 0x0c, 0x0a, 0x07, 0x56, 0x41, 0x52, 0x43, 0x48, 0x41, 0x52, 0x10, 0x95, + 0x30, 0x12, 0x0e, 0x0a, 0x09, 0x56, 0x41, 0x52, 0x42, 0x49, 0x4e, 0x41, 0x52, 0x59, 0x10, 0x96, + 0x50, 0x12, 0x09, 0x0a, 0x04, 0x43, 0x48, 0x41, 0x52, 0x10, 0x97, 0x30, 0x12, 0x0b, 0x0a, 0x06, + 0x42, 0x49, 0x4e, 0x41, 0x52, 0x59, 0x10, 0x98, 0x50, 0x12, 0x08, 0x0a, 0x03, 0x42, 0x49, 0x54, + 0x10, 0x99, 0x10, 0x12, 0x09, 0x0a, 0x04, 0x45, 0x4e, 0x55, 0x4d, 0x10, 0x9a, 0x10, 0x12, 0x08, + 0x0a, 0x03, 0x53, 0x45, 0x54, 0x10, 0x9b, 0x10, 0x12, 0x09, 0x0a, 0x05, 0x54, 0x55, 0x50, 0x4c, + 0x45, 0x10, 0x1c, 0x12, 0x0d, 0x0a, 0x08, 0x47, 0x45, 0x4f, 0x4d, 0x45, 0x54, 0x52, 0x59, 0x10, + 0x9d, 0x10, 0x12, 0x09, 0x0a, 0x04, 0x4a, 0x53, 0x4f, 0x4e, 0x10, 0x9e, 0x10, 0x12, 0x0e, 0x0a, + 0x0a, 0x45, 0x58, 0x50, 0x52, 0x45, 0x53, 0x53, 0x49, 0x4f, 0x4e, 0x10, 0x1f, 0x12, 0x0b, 0x0a, + 0x06, 0x48, 0x45, 0x58, 0x4e, 0x55, 0x4d, 0x10, 0xa0, 0x20, 0x12, 0x0b, 0x0a, 0x06, 0x48, 0x45, + 0x58, 0x56, 0x41, 0x4c, 0x10, 0xa1, 0x20, 0x12, 0x0b, 0x0a, 0x06, 0x42, 0x49, 0x54, 0x4e, 0x55, + 0x4d, 0x10, 0xa2, 0x20, 0x12, 0x0b, 0x0a, 0x06, 0x56, 0x45, 0x43, 0x54, 0x4f, 0x52, 0x10, 0xa3, + 0x10, 0x12, 0x08, 0x0a, 0x03, 0x52, 0x41, 0x57, 0x10, 0xa4, 0x10, 0x2a, 0x46, 0x0a, 0x10, 0x54, + 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, + 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, + 0x50, 0x52, 0x45, 0x50, 0x41, 0x52, 0x45, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x52, 0x4f, 0x4c, + 0x4c, 0x42, 0x41, 0x43, 0x4b, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x43, 0x4f, 0x4d, 0x4d, 0x49, + 0x54, 0x10, 0x03, 0x2a, 0x3b, 0x0a, 0x0f, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x54, 0x61, 0x62, + 0x6c, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x09, 0x0a, 0x05, 0x56, 0x49, 0x45, 0x57, 0x53, 0x10, + 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x54, 0x41, 0x42, 0x4c, 0x45, 0x53, 0x10, 0x01, 0x12, 0x07, 0x0a, + 0x03, 0x41, 0x4c, 0x4c, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x55, 0x44, 0x46, 0x53, 0x10, 0x03, + 0x42, 0x35, 0x0a, 0x0f, 0x69, 0x6f, 0x2e, 0x76, 0x69, 0x74, 0x65, 0x73, 0x73, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x5a, 0x22, 0x76, 0x69, 0x74, 0x65, 0x73, 0x73, 0x2e, 0x69, 0x6f, 0x2f, 0x76, + 0x69, 0x74, 0x65, 0x73, 0x73, 0x2f, 0x67, 0x6f, 0x2f, 0x76, 0x74, 0x2f, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x2f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +>>>>>>> e89f684b09 (JSON Encoding: Use Type_RAW for marshalling json (#16637)) } var ( diff --git a/go/vt/sqlparser/normalizer_test.go b/go/vt/sqlparser/normalizer_test.go index de1fdc868ad..15d24d9d3be 100644 --- a/go/vt/sqlparser/normalizer_test.go +++ b/go/vt/sqlparser/normalizer_test.go @@ -209,6 +209,23 @@ func TestNormalize(t *testing.T) { outbv: map[string]*querypb.BindVariable{ "v1": sqltypes.BitNumBindVariable([]byte("0b11")), }, + }, { + // json value in insert + in: "insert into t values ('{\"k\", \"v\"}')", + outstmt: "insert into t values (:bv1 /* VARCHAR */)", + outbv: map[string]*querypb.BindVariable{ + "bv1": sqltypes.StringBindVariable("{\"k\", \"v\"}"), + }, + }, { + // json function in insert + in: "insert into t values (JSON_OBJECT('_id', 27, 'name', 'carrot'))", + outstmt: "insert into t values (json_object(:bv1 /* VARCHAR */, :bv2 /* INT64 */, :bv3 /* VARCHAR */, :bv4 /* VARCHAR */))", + outbv: map[string]*querypb.BindVariable{ + "bv1": sqltypes.StringBindVariable("_id"), + "bv2": sqltypes.Int64BindVariable(27), + "bv3": sqltypes.StringBindVariable("name"), + "bv4": sqltypes.StringBindVariable("carrot"), + }, }, { // ORDER BY column_position in: "select a, b from t order by 1 asc", diff --git a/go/vt/sqlparser/parsed_query.go b/go/vt/sqlparser/parsed_query.go index a612e555ee8..491e7400988 100644 --- a/go/vt/sqlparser/parsed_query.go +++ b/go/vt/sqlparser/parsed_query.go @@ -101,7 +101,7 @@ func EncodeValue(buf *strings.Builder, value *querypb.BindVariable) { sqltypes.ProtoToValue(bv).EncodeSQLStringBuilder(buf) } buf.WriteByte(')') - case querypb.Type_JSON: + case querypb.Type_RAW: v, _ := sqltypes.BindVariableToValue(value) buf.Write(v.Raw()) default: diff --git a/go/vt/sqlparser/parsed_query_test.go b/go/vt/sqlparser/parsed_query_test.go index ef59676883f..64c10d61e97 100644 --- a/go/vt/sqlparser/parsed_query_test.go +++ b/go/vt/sqlparser/parsed_query_test.go @@ -80,6 +80,14 @@ func TestGenerateQuery(t *testing.T) { "vals": sqltypes.TestBindVariable([]any{1, "aa"}), }, output: "select * from a where id in (1, 'aa')", + }, { + desc: "json bindvar and raw bindvar", + query: "insert into t values (:v1, :v2)", + bindVars: map[string]*querypb.BindVariable{ + "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"))`, }, { desc: "list bind vars 0 arguments", query: "select * from a where id in ::vals", @@ -138,20 +146,19 @@ func TestGenerateQuery(t *testing.T) { parser := NewTestParser() for _, tcase := range tcases { - tree, err := parser.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) + require.NoError(t, err) + 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, bytes) + } + }) } } diff --git a/java/jdbc/src/test/java/io/vitess/jdbc/FieldWithMetadataTest.java b/java/jdbc/src/test/java/io/vitess/jdbc/FieldWithMetadataTest.java index bcadc49d33a..26ad5fd11b3 100644 --- a/java/jdbc/src/test/java/io/vitess/jdbc/FieldWithMetadataTest.java +++ b/java/jdbc/src/test/java/io/vitess/jdbc/FieldWithMetadataTest.java @@ -16,6 +16,9 @@ package io.vitess.jdbc; +import java.util.Set; +import java.util.EnumSet; + import io.vitess.proto.Query; import io.vitess.util.MysqlDefs; import io.vitess.util.charset.CharsetMapping; @@ -274,6 +277,16 @@ public void testNumericAndDateTimeEncoding() throws SQLException { } } + // Define the types to skip + Set typesToSkip = EnumSet.of( + Query.Type.UNRECOGNIZED, + Query.Type.EXPRESSION, + Query.Type.HEXVAL, + Query.Type.HEXNUM, + Query.Type.BITNUM, + Query.Type.RAW + ); + @Test public void testPrecisionAdjustFactor() throws SQLException { VitessConnection conn = getVitessConnection(); @@ -294,7 +307,8 @@ public void testPrecisionAdjustFactor() throws SQLException { conn.setIncludedFields(Query.ExecuteOptions.IncludedFields.TYPE_AND_NAME); for (Query.Type type : Query.Type.values()) { - if (type == Query.Type.UNRECOGNIZED || type == Query.Type.EXPRESSION || type == Query.Type.HEXVAL || type == Query.Type.HEXNUM || type == Query.Type.BITNUM) { + // Skip if the type is in the set + if (typesToSkip.contains(type)) { continue; } diff --git a/proto/query.proto b/proto/query.proto index 4d94fcb2c83..80dedd43959 100644 --- a/proto/query.proto +++ b/proto/query.proto @@ -215,6 +215,14 @@ 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. diff --git a/web/vtadmin/src/proto/vtadmin.d.ts b/web/vtadmin/src/proto/vtadmin.d.ts index 69f7891e271..46e8755c19f 100644 --- a/web/vtadmin/src/proto/vtadmin.d.ts +++ b/web/vtadmin/src/proto/vtadmin.d.ts @@ -33979,7 +33979,13 @@ export namespace query { EXPRESSION = 31, HEXNUM = 4128, HEXVAL = 4129, +<<<<<<< HEAD BITNUM = 4130 +======= + BITNUM = 4130, + VECTOR = 2083, + RAW = 2084 +>>>>>>> e89f684b09 (JSON Encoding: Use Type_RAW for marshalling json (#16637)) } /** Properties of a Value. */ diff --git a/web/vtadmin/src/proto/vtadmin.js b/web/vtadmin/src/proto/vtadmin.js index 3263bc3eb51..15a7bcc7f0d 100644 --- a/web/vtadmin/src/proto/vtadmin.js +++ b/web/vtadmin/src/proto/vtadmin.js @@ -80140,6 +80140,11 @@ export const query = $root.query = (() => { * @property {number} HEXNUM=4128 HEXNUM value * @property {number} HEXVAL=4129 HEXVAL value * @property {number} BITNUM=4130 BITNUM value +<<<<<<< HEAD +======= + * @property {number} VECTOR=2083 VECTOR value + * @property {number} RAW=2084 RAW value +>>>>>>> e89f684b09 (JSON Encoding: Use Type_RAW for marshalling json (#16637)) */ query.Type = (function() { const valuesById = {}, values = Object.create(valuesById); @@ -80178,6 +80183,11 @@ export const query = $root.query = (() => { values[valuesById[4128] = "HEXNUM"] = 4128; values[valuesById[4129] = "HEXVAL"] = 4129; values[valuesById[4130] = "BITNUM"] = 4130; +<<<<<<< HEAD +======= + values[valuesById[2083] = "VECTOR"] = 2083; + values[valuesById[2084] = "RAW"] = 2084; +>>>>>>> e89f684b09 (JSON Encoding: Use Type_RAW for marshalling json (#16637)) return values; })(); @@ -80366,6 +80376,11 @@ export const query = $root.query = (() => { case 4128: case 4129: case 4130: +<<<<<<< HEAD +======= + case 2083: + case 2084: +>>>>>>> e89f684b09 (JSON Encoding: Use Type_RAW for marshalling json (#16637)) break; } if (message.value != null && message.hasOwnProperty("value")) @@ -80533,6 +80548,17 @@ export const query = $root.query = (() => { case 4130: message.type = 4130; break; +<<<<<<< HEAD +======= + case "VECTOR": + case 2083: + message.type = 2083; + break; + case "RAW": + case 2084: + message.type = 2084; + break; +>>>>>>> e89f684b09 (JSON Encoding: Use Type_RAW for marshalling json (#16637)) } if (object.value != null) if (typeof object.value === "string") @@ -80805,6 +80831,11 @@ export const query = $root.query = (() => { case 4128: case 4129: case 4130: +<<<<<<< HEAD +======= + case 2083: + case 2084: +>>>>>>> e89f684b09 (JSON Encoding: Use Type_RAW for marshalling json (#16637)) break; } if (message.value != null && message.hasOwnProperty("value")) @@ -80981,6 +81012,17 @@ export const query = $root.query = (() => { case 4130: message.type = 4130; break; +<<<<<<< HEAD +======= + case "VECTOR": + case 2083: + message.type = 2083; + break; + case "RAW": + case 2084: + message.type = 2084; + break; +>>>>>>> e89f684b09 (JSON Encoding: Use Type_RAW for marshalling json (#16637)) } if (object.value != null) if (typeof object.value === "string") @@ -82471,6 +82513,11 @@ export const query = $root.query = (() => { case 4128: case 4129: case 4130: +<<<<<<< HEAD +======= + case 2083: + case 2084: +>>>>>>> e89f684b09 (JSON Encoding: Use Type_RAW for marshalling json (#16637)) break; } if (message.table != null && message.hasOwnProperty("table")) @@ -82664,6 +82711,17 @@ export const query = $root.query = (() => { case 4130: message.type = 4130; break; +<<<<<<< HEAD +======= + case "VECTOR": + case 2083: + message.type = 2083; + break; + case "RAW": + case 2084: + message.type = 2084; + break; +>>>>>>> e89f684b09 (JSON Encoding: Use Type_RAW for marshalling json (#16637)) } if (object.table != null) message.table = String(object.table); @@ -99046,25 +99104,28 @@ export const query = $root.query = (() => { return GetSchemaRequest; })(); - query.GetSchemaResponse = (function() { +<<<<<<< HEAD +======= + query.UDFInfo = (function() { /** - * Properties of a GetSchemaResponse. + * Properties of a UDFInfo. * @memberof query - * @interface IGetSchemaResponse - * @property {Object.|null} [table_definition] GetSchemaResponse table_definition + * @interface IUDFInfo + * @property {string|null} [name] UDFInfo name + * @property {boolean|null} [aggregating] UDFInfo aggregating + * @property {query.Type|null} [return_type] UDFInfo return_type */ /** - * Constructs a new GetSchemaResponse. + * Constructs a new UDFInfo. * @memberof query - * @classdesc Represents a GetSchemaResponse. - * @implements IGetSchemaResponse + * @classdesc Represents a UDFInfo. + * @implements IUDFInfo * @constructor - * @param {query.IGetSchemaResponse=} [properties] Properties to set + * @param {query.IUDFInfo=} [properties] Properties to set */ - function GetSchemaResponse(properties) { - this.table_definition = {}; + function UDFInfo(properties) { if (properties) for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -99072,95 +99133,103 @@ export const query = $root.query = (() => { } /** - * GetSchemaResponse table_definition. - * @member {Object.} table_definition - * @memberof query.GetSchemaResponse + * UDFInfo name. + * @member {string} name + * @memberof query.UDFInfo * @instance */ - GetSchemaResponse.prototype.table_definition = $util.emptyObject; + UDFInfo.prototype.name = ""; /** - * Creates a new GetSchemaResponse instance using the specified properties. + * UDFInfo aggregating. + * @member {boolean} aggregating + * @memberof query.UDFInfo + * @instance + */ + UDFInfo.prototype.aggregating = false; + + /** + * UDFInfo return_type. + * @member {query.Type} return_type + * @memberof query.UDFInfo + * @instance + */ + UDFInfo.prototype.return_type = 0; + + /** + * Creates a new UDFInfo instance using the specified properties. * @function create - * @memberof query.GetSchemaResponse + * @memberof query.UDFInfo * @static - * @param {query.IGetSchemaResponse=} [properties] Properties to set - * @returns {query.GetSchemaResponse} GetSchemaResponse instance + * @param {query.IUDFInfo=} [properties] Properties to set + * @returns {query.UDFInfo} UDFInfo instance */ - GetSchemaResponse.create = function create(properties) { - return new GetSchemaResponse(properties); + UDFInfo.create = function create(properties) { + return new UDFInfo(properties); }; /** - * Encodes the specified GetSchemaResponse message. Does not implicitly {@link query.GetSchemaResponse.verify|verify} messages. + * Encodes the specified UDFInfo message. Does not implicitly {@link query.UDFInfo.verify|verify} messages. * @function encode - * @memberof query.GetSchemaResponse + * @memberof query.UDFInfo * @static - * @param {query.IGetSchemaResponse} message GetSchemaResponse message or plain object to encode + * @param {query.IUDFInfo} message UDFInfo message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - GetSchemaResponse.encode = function encode(message, writer) { + UDFInfo.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.table_definition != null && Object.hasOwnProperty.call(message, "table_definition")) - for (let keys = Object.keys(message.table_definition), i = 0; i < keys.length; ++i) - writer.uint32(/* id 2, wireType 2 =*/18).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.table_definition[keys[i]]).ldelim(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message.aggregating != null && Object.hasOwnProperty.call(message, "aggregating")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.aggregating); + if (message.return_type != null && Object.hasOwnProperty.call(message, "return_type")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.return_type); return writer; }; /** - * Encodes the specified GetSchemaResponse message, length delimited. Does not implicitly {@link query.GetSchemaResponse.verify|verify} messages. + * Encodes the specified UDFInfo message, length delimited. Does not implicitly {@link query.UDFInfo.verify|verify} messages. * @function encodeDelimited - * @memberof query.GetSchemaResponse + * @memberof query.UDFInfo * @static - * @param {query.IGetSchemaResponse} message GetSchemaResponse message or plain object to encode + * @param {query.IUDFInfo} message UDFInfo message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - GetSchemaResponse.encodeDelimited = function encodeDelimited(message, writer) { + UDFInfo.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** - * Decodes a GetSchemaResponse message from the specified reader or buffer. + * Decodes a UDFInfo message from the specified reader or buffer. * @function decode - * @memberof query.GetSchemaResponse + * @memberof query.UDFInfo * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand - * @returns {query.GetSchemaResponse} GetSchemaResponse + * @returns {query.UDFInfo} UDFInfo * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - GetSchemaResponse.decode = function decode(reader, length) { + UDFInfo.decode = function decode(reader, length) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); - let end = length === undefined ? reader.len : reader.pos + length, message = new $root.query.GetSchemaResponse(), key, value; + let end = length === undefined ? reader.len : reader.pos + length, message = new $root.query.UDFInfo(); while (reader.pos < end) { let tag = reader.uint32(); switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } case 2: { - if (message.table_definition === $util.emptyObject) - message.table_definition = {}; - let end2 = reader.uint32() + reader.pos; - key = ""; - value = ""; - while (reader.pos < end2) { - let tag2 = reader.uint32(); - switch (tag2 >>> 3) { - case 1: - key = reader.string(); - break; - case 2: - value = reader.string(); - break; - default: - reader.skipType(tag2 & 7); - break; - } - } - message.table_definition[key] = value; + message.aggregating = reader.bool(); + break; + } + case 3: { + message.return_type = reader.int32(); break; } default: @@ -99172,169 +99241,605 @@ export const query = $root.query = (() => { }; /** - * Decodes a GetSchemaResponse message from the specified reader or buffer, length delimited. + * Decodes a UDFInfo message from the specified reader or buffer, length delimited. * @function decodeDelimited - * @memberof query.GetSchemaResponse + * @memberof query.UDFInfo * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {query.GetSchemaResponse} GetSchemaResponse + * @returns {query.UDFInfo} UDFInfo * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - GetSchemaResponse.decodeDelimited = function decodeDelimited(reader) { + UDFInfo.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** - * Verifies a GetSchemaResponse message. + * Verifies a UDFInfo message. * @function verify - * @memberof query.GetSchemaResponse + * @memberof query.UDFInfo * @static * @param {Object.} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ - GetSchemaResponse.verify = function verify(message) { + UDFInfo.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; - if (message.table_definition != null && message.hasOwnProperty("table_definition")) { - if (!$util.isObject(message.table_definition)) - return "table_definition: object expected"; - let key = Object.keys(message.table_definition); - for (let i = 0; i < key.length; ++i) - if (!$util.isString(message.table_definition[key[i]])) - return "table_definition: string{k:string} expected"; - } + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.aggregating != null && message.hasOwnProperty("aggregating")) + if (typeof message.aggregating !== "boolean") + return "aggregating: boolean expected"; + if (message.return_type != null && message.hasOwnProperty("return_type")) + switch (message.return_type) { + default: + return "return_type: enum value expected"; + case 0: + case 257: + case 770: + case 259: + case 772: + case 261: + case 774: + case 263: + case 776: + case 265: + case 778: + case 1035: + case 1036: + case 2061: + case 2062: + case 2063: + case 2064: + case 785: + case 18: + case 6163: + case 10260: + case 6165: + case 10262: + case 6167: + case 10264: + case 2073: + case 2074: + case 2075: + case 28: + case 2077: + case 2078: + case 31: + case 4128: + case 4129: + case 4130: + case 2083: + case 2084: + break; + } return null; }; /** - * Creates a GetSchemaResponse message from a plain object. Also converts values to their respective internal types. + * Creates a UDFInfo message from a plain object. Also converts values to their respective internal types. * @function fromObject - * @memberof query.GetSchemaResponse + * @memberof query.UDFInfo * @static * @param {Object.} object Plain object - * @returns {query.GetSchemaResponse} GetSchemaResponse + * @returns {query.UDFInfo} UDFInfo */ - GetSchemaResponse.fromObject = function fromObject(object) { - if (object instanceof $root.query.GetSchemaResponse) + UDFInfo.fromObject = function fromObject(object) { + if (object instanceof $root.query.UDFInfo) return object; - let message = new $root.query.GetSchemaResponse(); - if (object.table_definition) { - if (typeof object.table_definition !== "object") - throw TypeError(".query.GetSchemaResponse.table_definition: object expected"); - message.table_definition = {}; - for (let keys = Object.keys(object.table_definition), i = 0; i < keys.length; ++i) - message.table_definition[keys[i]] = String(object.table_definition[keys[i]]); - } - return message; - }; - - /** - * Creates a plain object from a GetSchemaResponse message. Also converts values to other types if specified. - * @function toObject - * @memberof query.GetSchemaResponse - * @static - * @param {query.GetSchemaResponse} message GetSchemaResponse - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - GetSchemaResponse.toObject = function toObject(message, options) { - if (!options) - options = {}; - let object = {}; - if (options.objects || options.defaults) - object.table_definition = {}; - let keys2; - if (message.table_definition && (keys2 = Object.keys(message.table_definition)).length) { - object.table_definition = {}; - for (let j = 0; j < keys2.length; ++j) - object.table_definition[keys2[j]] = message.table_definition[keys2[j]]; - } - return object; - }; - - /** - * Converts this GetSchemaResponse to JSON. - * @function toJSON - * @memberof query.GetSchemaResponse - * @instance - * @returns {Object.} JSON object - */ - GetSchemaResponse.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - /** - * Gets the default type url for GetSchemaResponse - * @function getTypeUrl - * @memberof query.GetSchemaResponse - * @static - * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") - * @returns {string} The default type url - */ - GetSchemaResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { - if (typeUrlPrefix === undefined) { - typeUrlPrefix = "type.googleapis.com"; - } - return typeUrlPrefix + "/query.GetSchemaResponse"; - }; - - return GetSchemaResponse; - })(); - - return query; -})(); - -export const replicationdata = $root.replicationdata = (() => { - - /** - * Namespace replicationdata. - * @exports replicationdata - * @namespace - */ - const replicationdata = {}; - - replicationdata.Status = (function() { - - /** - * Properties of a Status. - * @memberof replicationdata - * @interface IStatus - * @property {string|null} [position] Status position - * @property {number|null} [replication_lag_seconds] Status replication_lag_seconds - * @property {string|null} [source_host] Status source_host - * @property {number|null} [source_port] Status source_port - * @property {number|null} [connect_retry] Status connect_retry - * @property {string|null} [relay_log_position] Status relay_log_position - * @property {string|null} [file_position] Status file_position - * @property {string|null} [relay_log_source_binlog_equivalent_position] Status relay_log_source_binlog_equivalent_position - * @property {number|null} [source_server_id] Status source_server_id - * @property {string|null} [source_uuid] Status source_uuid - * @property {number|null} [io_state] Status io_state - * @property {string|null} [last_io_error] Status last_io_error - * @property {number|null} [sql_state] Status sql_state - * @property {string|null} [last_sql_error] Status last_sql_error - * @property {string|null} [relay_log_file_position] Status relay_log_file_position - * @property {string|null} [source_user] Status source_user - * @property {number|null} [sql_delay] Status sql_delay - * @property {boolean|null} [auto_position] Status auto_position - * @property {boolean|null} [using_gtid] Status using_gtid - * @property {boolean|null} [has_replication_filters] Status has_replication_filters - * @property {boolean|null} [ssl_allowed] Status ssl_allowed - * @property {boolean|null} [replication_lag_unknown] Status replication_lag_unknown - */ - - /** - * Constructs a new Status. - * @memberof replicationdata - * @classdesc Represents a Status. - * @implements IStatus - * @constructor - * @param {replicationdata.IStatus=} [properties] Properties to set - */ - function Status(properties) { + let message = new $root.query.UDFInfo(); + if (object.name != null) + message.name = String(object.name); + if (object.aggregating != null) + message.aggregating = Boolean(object.aggregating); + switch (object.return_type) { + default: + if (typeof object.return_type === "number") { + message.return_type = object.return_type; + break; + } + break; + case "NULL_TYPE": + case 0: + message.return_type = 0; + break; + case "INT8": + case 257: + message.return_type = 257; + break; + case "UINT8": + case 770: + message.return_type = 770; + break; + case "INT16": + case 259: + message.return_type = 259; + break; + case "UINT16": + case 772: + message.return_type = 772; + break; + case "INT24": + case 261: + message.return_type = 261; + break; + case "UINT24": + case 774: + message.return_type = 774; + break; + case "INT32": + case 263: + message.return_type = 263; + break; + case "UINT32": + case 776: + message.return_type = 776; + break; + case "INT64": + case 265: + message.return_type = 265; + break; + case "UINT64": + case 778: + message.return_type = 778; + break; + case "FLOAT32": + case 1035: + message.return_type = 1035; + break; + case "FLOAT64": + case 1036: + message.return_type = 1036; + break; + case "TIMESTAMP": + case 2061: + message.return_type = 2061; + break; + case "DATE": + case 2062: + message.return_type = 2062; + break; + case "TIME": + case 2063: + message.return_type = 2063; + break; + case "DATETIME": + case 2064: + message.return_type = 2064; + break; + case "YEAR": + case 785: + message.return_type = 785; + break; + case "DECIMAL": + case 18: + message.return_type = 18; + break; + case "TEXT": + case 6163: + message.return_type = 6163; + break; + case "BLOB": + case 10260: + message.return_type = 10260; + break; + case "VARCHAR": + case 6165: + message.return_type = 6165; + break; + case "VARBINARY": + case 10262: + message.return_type = 10262; + break; + case "CHAR": + case 6167: + message.return_type = 6167; + break; + case "BINARY": + case 10264: + message.return_type = 10264; + break; + case "BIT": + case 2073: + message.return_type = 2073; + break; + case "ENUM": + case 2074: + message.return_type = 2074; + break; + case "SET": + case 2075: + message.return_type = 2075; + break; + case "TUPLE": + case 28: + message.return_type = 28; + break; + case "GEOMETRY": + case 2077: + message.return_type = 2077; + break; + case "JSON": + case 2078: + message.return_type = 2078; + break; + case "EXPRESSION": + case 31: + message.return_type = 31; + break; + case "HEXNUM": + case 4128: + message.return_type = 4128; + break; + case "HEXVAL": + case 4129: + message.return_type = 4129; + break; + case "BITNUM": + case 4130: + message.return_type = 4130; + break; + case "VECTOR": + case 2083: + message.return_type = 2083; + break; + case "RAW": + case 2084: + message.return_type = 2084; + break; + } + return message; + }; + + /** + * Creates a plain object from a UDFInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof query.UDFInfo + * @static + * @param {query.UDFInfo} message UDFInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UDFInfo.toObject = function toObject(message, options) { + if (!options) + options = {}; + let object = {}; + if (options.defaults) { + object.name = ""; + object.aggregating = false; + object.return_type = options.enums === String ? "NULL_TYPE" : 0; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.aggregating != null && message.hasOwnProperty("aggregating")) + object.aggregating = message.aggregating; + if (message.return_type != null && message.hasOwnProperty("return_type")) + object.return_type = options.enums === String ? $root.query.Type[message.return_type] === undefined ? message.return_type : $root.query.Type[message.return_type] : message.return_type; + return object; + }; + + /** + * Converts this UDFInfo to JSON. + * @function toJSON + * @memberof query.UDFInfo + * @instance + * @returns {Object.} JSON object + */ + UDFInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UDFInfo + * @function getTypeUrl + * @memberof query.UDFInfo + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UDFInfo.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/query.UDFInfo"; + }; + + return UDFInfo; + })(); + +>>>>>>> e89f684b09 (JSON Encoding: Use Type_RAW for marshalling json (#16637)) + query.GetSchemaResponse = (function() { + + /** + * Properties of a GetSchemaResponse. + * @memberof query + * @interface IGetSchemaResponse + * @property {Object.|null} [table_definition] GetSchemaResponse table_definition + */ + + /** + * Constructs a new GetSchemaResponse. + * @memberof query + * @classdesc Represents a GetSchemaResponse. + * @implements IGetSchemaResponse + * @constructor + * @param {query.IGetSchemaResponse=} [properties] Properties to set + */ + function GetSchemaResponse(properties) { + this.table_definition = {}; + if (properties) + for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetSchemaResponse table_definition. + * @member {Object.} table_definition + * @memberof query.GetSchemaResponse + * @instance + */ + GetSchemaResponse.prototype.table_definition = $util.emptyObject; + + /** + * Creates a new GetSchemaResponse instance using the specified properties. + * @function create + * @memberof query.GetSchemaResponse + * @static + * @param {query.IGetSchemaResponse=} [properties] Properties to set + * @returns {query.GetSchemaResponse} GetSchemaResponse instance + */ + GetSchemaResponse.create = function create(properties) { + return new GetSchemaResponse(properties); + }; + + /** + * Encodes the specified GetSchemaResponse message. Does not implicitly {@link query.GetSchemaResponse.verify|verify} messages. + * @function encode + * @memberof query.GetSchemaResponse + * @static + * @param {query.IGetSchemaResponse} message GetSchemaResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetSchemaResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.table_definition != null && Object.hasOwnProperty.call(message, "table_definition")) + for (let keys = Object.keys(message.table_definition), i = 0; i < keys.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.table_definition[keys[i]]).ldelim(); + return writer; + }; + + /** + * Encodes the specified GetSchemaResponse message, length delimited. Does not implicitly {@link query.GetSchemaResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof query.GetSchemaResponse + * @static + * @param {query.IGetSchemaResponse} message GetSchemaResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetSchemaResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetSchemaResponse message from the specified reader or buffer. + * @function decode + * @memberof query.GetSchemaResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {query.GetSchemaResponse} GetSchemaResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetSchemaResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + let end = length === undefined ? reader.len : reader.pos + length, message = new $root.query.GetSchemaResponse(), key, value; + while (reader.pos < end) { + let tag = reader.uint32(); + switch (tag >>> 3) { + case 2: { + if (message.table_definition === $util.emptyObject) + message.table_definition = {}; + let end2 = reader.uint32() + reader.pos; + key = ""; + value = ""; + while (reader.pos < end2) { + let tag2 = reader.uint32(); + switch (tag2 >>> 3) { + case 1: + key = reader.string(); + break; + case 2: + value = reader.string(); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.table_definition[key] = value; + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetSchemaResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof query.GetSchemaResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {query.GetSchemaResponse} GetSchemaResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetSchemaResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetSchemaResponse message. + * @function verify + * @memberof query.GetSchemaResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetSchemaResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.table_definition != null && message.hasOwnProperty("table_definition")) { + if (!$util.isObject(message.table_definition)) + return "table_definition: object expected"; + let key = Object.keys(message.table_definition); + for (let i = 0; i < key.length; ++i) + if (!$util.isString(message.table_definition[key[i]])) + return "table_definition: string{k:string} expected"; + } + return null; + }; + + /** + * Creates a GetSchemaResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof query.GetSchemaResponse + * @static + * @param {Object.} object Plain object + * @returns {query.GetSchemaResponse} GetSchemaResponse + */ + GetSchemaResponse.fromObject = function fromObject(object) { + if (object instanceof $root.query.GetSchemaResponse) + return object; + let message = new $root.query.GetSchemaResponse(); + if (object.table_definition) { + if (typeof object.table_definition !== "object") + throw TypeError(".query.GetSchemaResponse.table_definition: object expected"); + message.table_definition = {}; + for (let keys = Object.keys(object.table_definition), i = 0; i < keys.length; ++i) + message.table_definition[keys[i]] = String(object.table_definition[keys[i]]); + } + return message; + }; + + /** + * Creates a plain object from a GetSchemaResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof query.GetSchemaResponse + * @static + * @param {query.GetSchemaResponse} message GetSchemaResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetSchemaResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + let object = {}; + if (options.objects || options.defaults) + object.table_definition = {}; + let keys2; + if (message.table_definition && (keys2 = Object.keys(message.table_definition)).length) { + object.table_definition = {}; + for (let j = 0; j < keys2.length; ++j) + object.table_definition[keys2[j]] = message.table_definition[keys2[j]]; + } + return object; + }; + + /** + * Converts this GetSchemaResponse to JSON. + * @function toJSON + * @memberof query.GetSchemaResponse + * @instance + * @returns {Object.} JSON object + */ + GetSchemaResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GetSchemaResponse + * @function getTypeUrl + * @memberof query.GetSchemaResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GetSchemaResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/query.GetSchemaResponse"; + }; + + return GetSchemaResponse; + })(); + + return query; +})(); + +export const replicationdata = $root.replicationdata = (() => { + + /** + * Namespace replicationdata. + * @exports replicationdata + * @namespace + */ + const replicationdata = {}; + + replicationdata.Status = (function() { + + /** + * Properties of a Status. + * @memberof replicationdata + * @interface IStatus + * @property {string|null} [position] Status position + * @property {number|null} [replication_lag_seconds] Status replication_lag_seconds + * @property {string|null} [source_host] Status source_host + * @property {number|null} [source_port] Status source_port + * @property {number|null} [connect_retry] Status connect_retry + * @property {string|null} [relay_log_position] Status relay_log_position + * @property {string|null} [file_position] Status file_position + * @property {string|null} [relay_log_source_binlog_equivalent_position] Status relay_log_source_binlog_equivalent_position + * @property {number|null} [source_server_id] Status source_server_id + * @property {string|null} [source_uuid] Status source_uuid + * @property {number|null} [io_state] Status io_state + * @property {string|null} [last_io_error] Status last_io_error + * @property {number|null} [sql_state] Status sql_state + * @property {string|null} [last_sql_error] Status last_sql_error + * @property {string|null} [relay_log_file_position] Status relay_log_file_position + * @property {string|null} [source_user] Status source_user + * @property {number|null} [sql_delay] Status sql_delay + * @property {boolean|null} [auto_position] Status auto_position + * @property {boolean|null} [using_gtid] Status using_gtid + * @property {boolean|null} [has_replication_filters] Status has_replication_filters + * @property {boolean|null} [ssl_allowed] Status ssl_allowed + * @property {boolean|null} [replication_lag_unknown] Status replication_lag_unknown + */ + + /** + * Constructs a new Status. + * @memberof replicationdata + * @classdesc Represents a Status. + * @implements IStatus + * @constructor + * @param {replicationdata.IStatus=} [properties] Properties to set + */ + function Status(properties) { if (properties) for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -101894,168 +102399,592 @@ export const vschema = $root.vschema = (() => { if (message.foreign_key_mode != null && message.hasOwnProperty("foreign_key_mode")) switch (message.foreign_key_mode) { default: - return "foreign_key_mode: enum value expected"; + return "foreign_key_mode: enum value expected"; + case 0: + case 1: + case 2: + case 3: + break; + } + return null; + }; + + /** + * Creates a Keyspace message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof vschema.Keyspace + * @static + * @param {Object.} object Plain object + * @returns {vschema.Keyspace} Keyspace + */ + Keyspace.fromObject = function fromObject(object) { + if (object instanceof $root.vschema.Keyspace) + return object; + let message = new $root.vschema.Keyspace(); + if (object.sharded != null) + message.sharded = Boolean(object.sharded); + if (object.vindexes) { + if (typeof object.vindexes !== "object") + throw TypeError(".vschema.Keyspace.vindexes: object expected"); + message.vindexes = {}; + for (let keys = Object.keys(object.vindexes), i = 0; i < keys.length; ++i) { + if (typeof object.vindexes[keys[i]] !== "object") + throw TypeError(".vschema.Keyspace.vindexes: object expected"); + message.vindexes[keys[i]] = $root.vschema.Vindex.fromObject(object.vindexes[keys[i]]); + } + } + if (object.tables) { + if (typeof object.tables !== "object") + throw TypeError(".vschema.Keyspace.tables: object expected"); + message.tables = {}; + for (let keys = Object.keys(object.tables), i = 0; i < keys.length; ++i) { + if (typeof object.tables[keys[i]] !== "object") + throw TypeError(".vschema.Keyspace.tables: object expected"); + message.tables[keys[i]] = $root.vschema.Table.fromObject(object.tables[keys[i]]); + } + } + if (object.require_explicit_routing != null) + message.require_explicit_routing = Boolean(object.require_explicit_routing); + switch (object.foreign_key_mode) { + default: + if (typeof object.foreign_key_mode === "number") { + message.foreign_key_mode = object.foreign_key_mode; + break; + } + break; + case "unspecified": + case 0: + message.foreign_key_mode = 0; + break; + case "disallow": + case 1: + message.foreign_key_mode = 1; + break; + case "unmanaged": + case 2: + message.foreign_key_mode = 2; + break; + case "managed": + case 3: + message.foreign_key_mode = 3; + break; + } + return message; + }; + + /** + * Creates a plain object from a Keyspace message. Also converts values to other types if specified. + * @function toObject + * @memberof vschema.Keyspace + * @static + * @param {vschema.Keyspace} message Keyspace + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Keyspace.toObject = function toObject(message, options) { + if (!options) + options = {}; + let object = {}; + if (options.objects || options.defaults) { + object.vindexes = {}; + object.tables = {}; + } + if (options.defaults) { + object.sharded = false; + object.require_explicit_routing = false; + object.foreign_key_mode = options.enums === String ? "unspecified" : 0; + } + if (message.sharded != null && message.hasOwnProperty("sharded")) + object.sharded = message.sharded; + let keys2; + if (message.vindexes && (keys2 = Object.keys(message.vindexes)).length) { + object.vindexes = {}; + for (let j = 0; j < keys2.length; ++j) + object.vindexes[keys2[j]] = $root.vschema.Vindex.toObject(message.vindexes[keys2[j]], options); + } + if (message.tables && (keys2 = Object.keys(message.tables)).length) { + object.tables = {}; + for (let j = 0; j < keys2.length; ++j) + object.tables[keys2[j]] = $root.vschema.Table.toObject(message.tables[keys2[j]], options); + } + if (message.require_explicit_routing != null && message.hasOwnProperty("require_explicit_routing")) + object.require_explicit_routing = message.require_explicit_routing; + if (message.foreign_key_mode != null && message.hasOwnProperty("foreign_key_mode")) + object.foreign_key_mode = options.enums === String ? $root.vschema.Keyspace.ForeignKeyMode[message.foreign_key_mode] === undefined ? message.foreign_key_mode : $root.vschema.Keyspace.ForeignKeyMode[message.foreign_key_mode] : message.foreign_key_mode; + return object; + }; + + /** + * Converts this Keyspace to JSON. + * @function toJSON + * @memberof vschema.Keyspace + * @instance + * @returns {Object.} JSON object + */ + Keyspace.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Keyspace + * @function getTypeUrl + * @memberof vschema.Keyspace + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Keyspace.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/vschema.Keyspace"; + }; + + /** + * ForeignKeyMode enum. + * @name vschema.Keyspace.ForeignKeyMode + * @enum {number} + * @property {number} unspecified=0 unspecified value + * @property {number} disallow=1 disallow value + * @property {number} unmanaged=2 unmanaged value + * @property {number} managed=3 managed value + */ + Keyspace.ForeignKeyMode = (function() { + const valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "unspecified"] = 0; + values[valuesById[1] = "disallow"] = 1; + values[valuesById[2] = "unmanaged"] = 2; + values[valuesById[3] = "managed"] = 3; + return values; + })(); + + return Keyspace; + })(); + +<<<<<<< HEAD +======= + vschema.MultiTenantSpec = (function() { + + /** + * Properties of a MultiTenantSpec. + * @memberof vschema + * @interface IMultiTenantSpec + * @property {string|null} [tenant_id_column_name] MultiTenantSpec tenant_id_column_name + * @property {query.Type|null} [tenant_id_column_type] MultiTenantSpec tenant_id_column_type + */ + + /** + * Constructs a new MultiTenantSpec. + * @memberof vschema + * @classdesc Represents a MultiTenantSpec. + * @implements IMultiTenantSpec + * @constructor + * @param {vschema.IMultiTenantSpec=} [properties] Properties to set + */ + function MultiTenantSpec(properties) { + if (properties) + for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * MultiTenantSpec tenant_id_column_name. + * @member {string} tenant_id_column_name + * @memberof vschema.MultiTenantSpec + * @instance + */ + MultiTenantSpec.prototype.tenant_id_column_name = ""; + + /** + * MultiTenantSpec tenant_id_column_type. + * @member {query.Type} tenant_id_column_type + * @memberof vschema.MultiTenantSpec + * @instance + */ + MultiTenantSpec.prototype.tenant_id_column_type = 0; + + /** + * Creates a new MultiTenantSpec instance using the specified properties. + * @function create + * @memberof vschema.MultiTenantSpec + * @static + * @param {vschema.IMultiTenantSpec=} [properties] Properties to set + * @returns {vschema.MultiTenantSpec} MultiTenantSpec instance + */ + MultiTenantSpec.create = function create(properties) { + return new MultiTenantSpec(properties); + }; + + /** + * Encodes the specified MultiTenantSpec message. Does not implicitly {@link vschema.MultiTenantSpec.verify|verify} messages. + * @function encode + * @memberof vschema.MultiTenantSpec + * @static + * @param {vschema.IMultiTenantSpec} message MultiTenantSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MultiTenantSpec.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.tenant_id_column_name != null && Object.hasOwnProperty.call(message, "tenant_id_column_name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.tenant_id_column_name); + if (message.tenant_id_column_type != null && Object.hasOwnProperty.call(message, "tenant_id_column_type")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.tenant_id_column_type); + return writer; + }; + + /** + * Encodes the specified MultiTenantSpec message, length delimited. Does not implicitly {@link vschema.MultiTenantSpec.verify|verify} messages. + * @function encodeDelimited + * @memberof vschema.MultiTenantSpec + * @static + * @param {vschema.IMultiTenantSpec} message MultiTenantSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MultiTenantSpec.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a MultiTenantSpec message from the specified reader or buffer. + * @function decode + * @memberof vschema.MultiTenantSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {vschema.MultiTenantSpec} MultiTenantSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MultiTenantSpec.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + let end = length === undefined ? reader.len : reader.pos + length, message = new $root.vschema.MultiTenantSpec(); + while (reader.pos < end) { + let tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.tenant_id_column_name = reader.string(); + break; + } + case 2: { + message.tenant_id_column_type = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a MultiTenantSpec message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof vschema.MultiTenantSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {vschema.MultiTenantSpec} MultiTenantSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MultiTenantSpec.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a MultiTenantSpec message. + * @function verify + * @memberof vschema.MultiTenantSpec + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + MultiTenantSpec.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.tenant_id_column_name != null && message.hasOwnProperty("tenant_id_column_name")) + if (!$util.isString(message.tenant_id_column_name)) + return "tenant_id_column_name: string expected"; + if (message.tenant_id_column_type != null && message.hasOwnProperty("tenant_id_column_type")) + switch (message.tenant_id_column_type) { + default: + return "tenant_id_column_type: enum value expected"; case 0: - case 1: - case 2: - case 3: + case 257: + case 770: + case 259: + case 772: + case 261: + case 774: + case 263: + case 776: + case 265: + case 778: + case 1035: + case 1036: + case 2061: + case 2062: + case 2063: + case 2064: + case 785: + case 18: + case 6163: + case 10260: + case 6165: + case 10262: + case 6167: + case 10264: + case 2073: + case 2074: + case 2075: + case 28: + case 2077: + case 2078: + case 31: + case 4128: + case 4129: + case 4130: + case 2083: + case 2084: break; } return null; }; /** - * Creates a Keyspace message from a plain object. Also converts values to their respective internal types. + * Creates a MultiTenantSpec message from a plain object. Also converts values to their respective internal types. * @function fromObject - * @memberof vschema.Keyspace + * @memberof vschema.MultiTenantSpec * @static * @param {Object.} object Plain object - * @returns {vschema.Keyspace} Keyspace + * @returns {vschema.MultiTenantSpec} MultiTenantSpec */ - Keyspace.fromObject = function fromObject(object) { - if (object instanceof $root.vschema.Keyspace) + MultiTenantSpec.fromObject = function fromObject(object) { + if (object instanceof $root.vschema.MultiTenantSpec) return object; - let message = new $root.vschema.Keyspace(); - if (object.sharded != null) - message.sharded = Boolean(object.sharded); - if (object.vindexes) { - if (typeof object.vindexes !== "object") - throw TypeError(".vschema.Keyspace.vindexes: object expected"); - message.vindexes = {}; - for (let keys = Object.keys(object.vindexes), i = 0; i < keys.length; ++i) { - if (typeof object.vindexes[keys[i]] !== "object") - throw TypeError(".vschema.Keyspace.vindexes: object expected"); - message.vindexes[keys[i]] = $root.vschema.Vindex.fromObject(object.vindexes[keys[i]]); - } - } - if (object.tables) { - if (typeof object.tables !== "object") - throw TypeError(".vschema.Keyspace.tables: object expected"); - message.tables = {}; - for (let keys = Object.keys(object.tables), i = 0; i < keys.length; ++i) { - if (typeof object.tables[keys[i]] !== "object") - throw TypeError(".vschema.Keyspace.tables: object expected"); - message.tables[keys[i]] = $root.vschema.Table.fromObject(object.tables[keys[i]]); - } - } - if (object.require_explicit_routing != null) - message.require_explicit_routing = Boolean(object.require_explicit_routing); - switch (object.foreign_key_mode) { + let message = new $root.vschema.MultiTenantSpec(); + if (object.tenant_id_column_name != null) + message.tenant_id_column_name = String(object.tenant_id_column_name); + switch (object.tenant_id_column_type) { default: - if (typeof object.foreign_key_mode === "number") { - message.foreign_key_mode = object.foreign_key_mode; + if (typeof object.tenant_id_column_type === "number") { + message.tenant_id_column_type = object.tenant_id_column_type; break; } break; - case "unspecified": + case "NULL_TYPE": case 0: - message.foreign_key_mode = 0; + message.tenant_id_column_type = 0; break; - case "disallow": - case 1: - message.foreign_key_mode = 1; + case "INT8": + case 257: + message.tenant_id_column_type = 257; break; - case "unmanaged": - case 2: - message.foreign_key_mode = 2; + case "UINT8": + case 770: + message.tenant_id_column_type = 770; break; - case "managed": - case 3: - message.foreign_key_mode = 3; + case "INT16": + case 259: + message.tenant_id_column_type = 259; + break; + case "UINT16": + case 772: + message.tenant_id_column_type = 772; + break; + case "INT24": + case 261: + message.tenant_id_column_type = 261; + break; + case "UINT24": + case 774: + message.tenant_id_column_type = 774; + break; + case "INT32": + case 263: + message.tenant_id_column_type = 263; + break; + case "UINT32": + case 776: + message.tenant_id_column_type = 776; + break; + case "INT64": + case 265: + message.tenant_id_column_type = 265; + break; + case "UINT64": + case 778: + message.tenant_id_column_type = 778; + break; + case "FLOAT32": + case 1035: + message.tenant_id_column_type = 1035; + break; + case "FLOAT64": + case 1036: + message.tenant_id_column_type = 1036; + break; + case "TIMESTAMP": + case 2061: + message.tenant_id_column_type = 2061; + break; + case "DATE": + case 2062: + message.tenant_id_column_type = 2062; + break; + case "TIME": + case 2063: + message.tenant_id_column_type = 2063; + break; + case "DATETIME": + case 2064: + message.tenant_id_column_type = 2064; + break; + case "YEAR": + case 785: + message.tenant_id_column_type = 785; + break; + case "DECIMAL": + case 18: + message.tenant_id_column_type = 18; + break; + case "TEXT": + case 6163: + message.tenant_id_column_type = 6163; + break; + case "BLOB": + case 10260: + message.tenant_id_column_type = 10260; + break; + case "VARCHAR": + case 6165: + message.tenant_id_column_type = 6165; + break; + case "VARBINARY": + case 10262: + message.tenant_id_column_type = 10262; + break; + case "CHAR": + case 6167: + message.tenant_id_column_type = 6167; + break; + case "BINARY": + case 10264: + message.tenant_id_column_type = 10264; + break; + case "BIT": + case 2073: + message.tenant_id_column_type = 2073; + break; + case "ENUM": + case 2074: + message.tenant_id_column_type = 2074; + break; + case "SET": + case 2075: + message.tenant_id_column_type = 2075; + break; + case "TUPLE": + case 28: + message.tenant_id_column_type = 28; + break; + case "GEOMETRY": + case 2077: + message.tenant_id_column_type = 2077; + break; + case "JSON": + case 2078: + message.tenant_id_column_type = 2078; + break; + case "EXPRESSION": + case 31: + message.tenant_id_column_type = 31; + break; + case "HEXNUM": + case 4128: + message.tenant_id_column_type = 4128; + break; + case "HEXVAL": + case 4129: + message.tenant_id_column_type = 4129; + break; + case "BITNUM": + case 4130: + message.tenant_id_column_type = 4130; + break; + case "VECTOR": + case 2083: + message.tenant_id_column_type = 2083; + break; + case "RAW": + case 2084: + message.tenant_id_column_type = 2084; break; } return message; }; /** - * Creates a plain object from a Keyspace message. Also converts values to other types if specified. + * Creates a plain object from a MultiTenantSpec message. Also converts values to other types if specified. * @function toObject - * @memberof vschema.Keyspace + * @memberof vschema.MultiTenantSpec * @static - * @param {vschema.Keyspace} message Keyspace + * @param {vschema.MultiTenantSpec} message MultiTenantSpec * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - Keyspace.toObject = function toObject(message, options) { + MultiTenantSpec.toObject = function toObject(message, options) { if (!options) options = {}; let object = {}; - if (options.objects || options.defaults) { - object.vindexes = {}; - object.tables = {}; - } if (options.defaults) { - object.sharded = false; - object.require_explicit_routing = false; - object.foreign_key_mode = options.enums === String ? "unspecified" : 0; - } - if (message.sharded != null && message.hasOwnProperty("sharded")) - object.sharded = message.sharded; - let keys2; - if (message.vindexes && (keys2 = Object.keys(message.vindexes)).length) { - object.vindexes = {}; - for (let j = 0; j < keys2.length; ++j) - object.vindexes[keys2[j]] = $root.vschema.Vindex.toObject(message.vindexes[keys2[j]], options); - } - if (message.tables && (keys2 = Object.keys(message.tables)).length) { - object.tables = {}; - for (let j = 0; j < keys2.length; ++j) - object.tables[keys2[j]] = $root.vschema.Table.toObject(message.tables[keys2[j]], options); + object.tenant_id_column_name = ""; + object.tenant_id_column_type = options.enums === String ? "NULL_TYPE" : 0; } - if (message.require_explicit_routing != null && message.hasOwnProperty("require_explicit_routing")) - object.require_explicit_routing = message.require_explicit_routing; - if (message.foreign_key_mode != null && message.hasOwnProperty("foreign_key_mode")) - object.foreign_key_mode = options.enums === String ? $root.vschema.Keyspace.ForeignKeyMode[message.foreign_key_mode] === undefined ? message.foreign_key_mode : $root.vschema.Keyspace.ForeignKeyMode[message.foreign_key_mode] : message.foreign_key_mode; + if (message.tenant_id_column_name != null && message.hasOwnProperty("tenant_id_column_name")) + object.tenant_id_column_name = message.tenant_id_column_name; + if (message.tenant_id_column_type != null && message.hasOwnProperty("tenant_id_column_type")) + object.tenant_id_column_type = options.enums === String ? $root.query.Type[message.tenant_id_column_type] === undefined ? message.tenant_id_column_type : $root.query.Type[message.tenant_id_column_type] : message.tenant_id_column_type; return object; }; /** - * Converts this Keyspace to JSON. + * Converts this MultiTenantSpec to JSON. * @function toJSON - * @memberof vschema.Keyspace + * @memberof vschema.MultiTenantSpec * @instance * @returns {Object.} JSON object */ - Keyspace.prototype.toJSON = function toJSON() { + MultiTenantSpec.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** - * Gets the default type url for Keyspace + * Gets the default type url for MultiTenantSpec * @function getTypeUrl - * @memberof vschema.Keyspace + * @memberof vschema.MultiTenantSpec * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - Keyspace.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + MultiTenantSpec.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } - return typeUrlPrefix + "/vschema.Keyspace"; + return typeUrlPrefix + "/vschema.MultiTenantSpec"; }; - /** - * ForeignKeyMode enum. - * @name vschema.Keyspace.ForeignKeyMode - * @enum {number} - * @property {number} unspecified=0 unspecified value - * @property {number} disallow=1 disallow value - * @property {number} unmanaged=2 unmanaged value - * @property {number} managed=3 managed value - */ - Keyspace.ForeignKeyMode = (function() { - const valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "unspecified"] = 0; - values[valuesById[1] = "disallow"] = 1; - values[valuesById[2] = "unmanaged"] = 2; - values[valuesById[3] = "managed"] = 3; - return values; - })(); - - return Keyspace; + return MultiTenantSpec; })(); +>>>>>>> e89f684b09 (JSON Encoding: Use Type_RAW for marshalling json (#16637)) vschema.Vindex = (function() { /** @@ -103539,6 +104468,11 @@ export const vschema = $root.vschema = (() => { case 4128: case 4129: case 4130: +<<<<<<< HEAD +======= + case 2083: + case 2084: +>>>>>>> e89f684b09 (JSON Encoding: Use Type_RAW for marshalling json (#16637)) break; } if (message.invisible != null && message.hasOwnProperty("invisible")) @@ -103732,6 +104666,17 @@ export const vschema = $root.vschema = (() => { case 4130: message.type = 4130; break; +<<<<<<< HEAD +======= + case "VECTOR": + case 2083: + message.type = 2083; + break; + case "RAW": + case 2084: + message.type = 2084; + break; +>>>>>>> e89f684b09 (JSON Encoding: Use Type_RAW for marshalling json (#16637)) } if (object.invisible != null) message.invisible = Boolean(object.invisible);