polardbxengine/mysql-test/suite/x/r/crud_table_criteria_args.re...

1133 lines
20 KiB
Plaintext

=============================================
CRUD TABLE CRITERIA ARGS SCENARIOS
=============================================
================================================================================
PREAMBLE
================================================================================
================================================================================
TEST START
================================================================================
RUN drop schema if exists xtest
0 rows affected
RUN create schema xtest
1 rows affected
RUN use xtest
0 rows affected
RUN create table mytable (id int primary key, name varchar(40), price decimal(5,2), info json)
0 rows affected
RUN insert into mytable values (1, 'banana', 1.20, '{"color": "yellow"}')
1 rows affected
RUN insert into mytable values (2, 'apple', 0.25, '{"color":"red"}')
1 rows affected
RUN insert into mytable values (3, 'tomato', 1.80, '{"color":"red"}')
1 rows affected
RUN insert into mytable values (4, 'mango', 3.14, '{"color":"green"}')
1 rows affected
RUN insert into mytable values (5, 'orange', 0.90, '{"color":"orange"}')
1 rows affected
RUN insert into mytable values (6, 'berry', null, '{"color":"orange"}')
1 rows affected
RUN SELECT * FROM xtest.mytable ORDER BY price
id name price info
6 berry null {"color": "orange"}
2 apple 0.25 {"color": "red"}
5 orange 0.90 {"color": "orange"}
1 banana 1.20 {"color": "yellow"}
3 tomato 1.80 {"color": "red"}
4 mango 3.14 {"color": "green"}
0 rows affected
Find with == Operator and placeholder
send Mysqlx.Crud.Find {
collection {
name: "mytable"
schema: "xtest"
}
data_model: TABLE
criteria {
type: OPERATOR
operator {
name: "=="
param {
type: IDENT
identifier {
name: "name"
}
}
param {
type: PLACEHOLDER
position: 0
}
}
}
args {
type: V_STRING
v_string {
value: "tomato"
}
}
}
id name price info
3 tomato 1.80 {"color": "red"}
command ok
Find with != Operator. placeholder and projection
send Mysqlx.Crud.Find {
collection {
name: "mytable"
schema: "xtest"
}
data_model: TABLE
projection {
source {
type: IDENT
identifier {
name: "name"
}
}
}
criteria {
type: OPERATOR
operator {
name: "=="
param {
type: IDENT
identifier {
name: "name"
}
}
param {
type: PLACEHOLDER
position: 0
}
}
}
args {
type: V_STRING
v_string {
value: "tomato"
}
}
}
name
tomato
command ok
Find with != Operator and placeholder
send Mysqlx.Crud.Find {
collection {
name: "mytable"
schema: "xtest"
}
data_model: TABLE
criteria {
type: OPERATOR
operator {
name: "!="
param {
type: IDENT
identifier {
name: "name"
}
}
param {
type: PLACEHOLDER
position: 0
}
}
}
args {
type: V_STRING
v_string {
value: "tomato"
}
}
}
id name price info
1 banana 1.20 {"color": "yellow"}
2 apple 0.25 {"color": "red"}
4 mango 3.14 {"color": "green"}
5 orange 0.90 {"color": "orange"}
6 berry null {"color": "orange"}
command ok
Find with > Operator and placeholder
send Mysqlx.Crud.Find {
collection {
name: "mytable"
schema: "xtest"
}
data_model: TABLE
criteria {
type: OPERATOR
operator {
name: ">"
param {
type: IDENT
identifier {
name: "price"
}
}
param {
type: PLACEHOLDER
position: 0
}
}
}
args {
type: V_DOUBLE
v_double: 1.8
}
}
id name price info
4 mango 3.14 {"color": "green"}
command ok
Find with != Operator, placeholder and Order desc
send Mysqlx.Crud.Find {
collection {
name: "mytable"
schema: "xtest"
}
data_model: TABLE
criteria {
type: OPERATOR
operator {
name: "!="
param {
type: IDENT
identifier {
name: "price"
}
}
param {
type: PLACEHOLDER
position: 0
}
}
}
order {
expr {
type: IDENT
identifier {
name: "name"
}
}
direction: DESC
}
args {
type: V_DOUBLE
v_double: 0
}
}
id name price info
3 tomato 1.80 {"color": "red"}
5 orange 0.90 {"color": "orange"}
4 mango 3.14 {"color": "green"}
1 banana 1.20 {"color": "yellow"}
2 apple 0.25 {"color": "red"}
command ok
Find with != Operator, placeholder and Order asc
send Mysqlx.Crud.Find {
collection {
name: "mytable"
schema: "xtest"
}
data_model: TABLE
criteria {
type: OPERATOR
operator {
name: "!="
param {
type: IDENT
identifier {
name: "price"
}
}
param {
type: PLACEHOLDER
position: 0
}
}
}
order {
expr {
type: IDENT
identifier {
name: "name"
}
}
direction: ASC
}
args {
type: V_DOUBLE
v_double: 0
}
}
id name price info
2 apple 0.25 {"color": "red"}
1 banana 1.20 {"color": "yellow"}
4 mango 3.14 {"color": "green"}
5 orange 0.90 {"color": "orange"}
3 tomato 1.80 {"color": "red"}
command ok
Find with < Operator and placeholder
send Mysqlx.Crud.Find {
collection {
name: "mytable"
schema: "xtest"
}
data_model: TABLE
criteria {
type: OPERATOR
operator {
name: "<"
param {
type: IDENT
identifier {
name: "price"
}
}
param {
type: PLACEHOLDER
position: 0
}
}
}
args {
type: V_DOUBLE
v_double: 0.25
}
}
id name price info
command ok
Find with >= Operator and placeholder
send Mysqlx.Crud.Find {
collection {
name: "mytable"
schema: "xtest"
}
data_model: TABLE
criteria {
type: OPERATOR
operator {
name: ">="
param {
type: IDENT
identifier {
name: "price"
}
}
param {
type: PLACEHOLDER
position: 0
}
}
}
args {
type: V_DOUBLE
v_double: 1.8
}
}
id name price info
3 tomato 1.80 {"color": "red"}
4 mango 3.14 {"color": "green"}
command ok
Find with <= Operator and placeholder
send Mysqlx.Crud.Find {
collection {
name: "mytable"
schema: "xtest"
}
data_model: TABLE
criteria {
type: OPERATOR
operator {
name: "<="
param {
type: IDENT
identifier {
name: "price"
}
}
param {
type: PLACEHOLDER
position: 0
}
}
}
args {
type: V_DOUBLE
v_double: 0.25
}
}
id name price info
2 apple 0.25 {"color": "red"}
command ok
Find with in Operator and placeholder
send Mysqlx.Crud.Find {
collection {
name: "mytable"
schema: "xtest"
}
data_model: TABLE
criteria {
type: OPERATOR
operator {
name: "in"
param {
type: IDENT
identifier {
name: "price"
}
}
param {
type: PLACEHOLDER
position: 0
}
}
}
args {
type: V_DOUBLE
v_double: 1.8
}
}
id name price info
3 tomato 1.80 {"color": "red"}
command ok
Find with not in Operator and placeholder
send Mysqlx.Crud.Find {
collection {
name: "mytable"
schema: "xtest"
}
data_model: TABLE
criteria {
type: OPERATOR
operator {
name: "not_in"
param {
type: IDENT
identifier {
name: "price"
}
}
param {
type: PLACEHOLDER
position: 0
}
}
}
args {
type: V_DOUBLE
v_double: 1.8
}
}
id name price info
1 banana 1.20 {"color": "yellow"}
2 apple 0.25 {"color": "red"}
4 mango 3.14 {"color": "green"}
5 orange 0.90 {"color": "orange"}
command ok
Find with == Operator, V_NULL and placeholder
send Mysqlx.Crud.Find {
collection {
name: "mytable"
schema: "xtest"
}
data_model: TABLE
criteria {
type: OPERATOR
operator {
name: "is"
param {
type: IDENT
identifier {
name: "price"
}
}
param {
type: PLACEHOLDER
position: 0
}
}
}
args {
type: V_NULL
}
}
id name price info
6 berry null {"color": "orange"}
command ok
Update with == operator and placeholder
send Mysqlx.Crud.Update {
collection {
name: "mytable"
schema: "xtest"
}
data_model: TABLE
criteria {
type: OPERATOR
operator {
name: "=="
param {
type: IDENT
identifier {
name: "price"
}
}
param {
type: PLACEHOLDER
position: 0
}
}
}
operation {
source {
name: "price"
}
operation: SET
value {
type: LITERAL
literal {
type: V_DOUBLE
v_double: 18
}
}
}
args {
type: V_DOUBLE
v_double: 1.8
}
}
1 rows affected
Rows matched: 1 Changed: 1 Warnings: 0
RUN SELECT * FROM xtest.mytable ORDER BY price
id name price info
6 berry null {"color": "orange"}
2 apple 0.25 {"color": "red"}
5 orange 0.90 {"color": "orange"}
1 banana 1.20 {"color": "yellow"}
4 mango 3.14 {"color": "green"}
3 tomato 18.00 {"color": "red"}
0 rows affected
Update with > operator and placeholder
send Mysqlx.Crud.Update {
collection {
name: "mytable"
schema: "xtest"
}
data_model: TABLE
criteria {
type: OPERATOR
operator {
name: ">"
param {
type: IDENT
identifier {
name: "price"
}
}
param {
type: PLACEHOLDER
position: 0
}
}
}
operation {
source {
name: "price"
}
operation: SET
value {
type: LITERAL
literal {
type: V_DOUBLE
v_double: 10
}
}
}
args {
type: V_DOUBLE
v_double: 1
}
}
3 rows affected
Rows matched: 3 Changed: 3 Warnings: 0
RUN SELECT * FROM xtest.mytable ORDER BY price
id name price info
6 berry null {"color": "orange"}
2 apple 0.25 {"color": "red"}
5 orange 0.90 {"color": "orange"}
1 banana 10.00 {"color": "yellow"}
3 tomato 10.00 {"color": "red"}
4 mango 10.00 {"color": "green"}
0 rows affected
Update with >= operator and placeholder
send Mysqlx.Crud.Update {
collection {
name: "mytable"
schema: "xtest"
}
data_model: TABLE
criteria {
type: OPERATOR
operator {
name: ">="
param {
type: IDENT
identifier {
name: "price"
}
}
param {
type: PLACEHOLDER
position: 0
}
}
}
operation {
source {
name: "price"
}
operation: SET
value {
type: LITERAL
literal {
type: V_DOUBLE
v_double: 895.63
}
}
}
args {
type: V_DOUBLE
v_double: 1.8
}
}
3 rows affected
Rows matched: 3 Changed: 3 Warnings: 0
RUN SELECT * FROM xtest.mytable ORDER BY price
id name price info
6 berry null {"color": "orange"}
2 apple 0.25 {"color": "red"}
5 orange 0.90 {"color": "orange"}
1 banana 895.63 {"color": "yellow"}
3 tomato 895.63 {"color": "red"}
4 mango 895.63 {"color": "green"}
0 rows affected
Update with <= operator and placeholder
send Mysqlx.Crud.Update {
collection {
name: "mytable"
schema: "xtest"
}
data_model: TABLE
criteria {
type: OPERATOR
operator {
name: "<="
param {
type: IDENT
identifier {
name: "price"
}
}
param {
type: PLACEHOLDER
position: 0
}
}
}
operation {
source {
name: "price"
}
operation: SET
value {
type: LITERAL
literal {
type: V_DOUBLE
v_double: 456.54
}
}
}
args {
type: V_DOUBLE
v_double: 0.9
}
}
2 rows affected
Rows matched: 2 Changed: 2 Warnings: 0
RUN SELECT * FROM xtest.mytable ORDER BY price
id name price info
6 berry null {"color": "orange"}
2 apple 456.54 {"color": "red"}
5 orange 456.54 {"color": "orange"}
1 banana 895.63 {"color": "yellow"}
3 tomato 895.63 {"color": "red"}
4 mango 895.63 {"color": "green"}
0 rows affected
Update with Float value and placeholder
send Mysqlx.Crud.Update {
collection {
name: "mytable"
schema: "xtest"
}
data_model: TABLE
criteria {
type: OPERATOR
operator {
name: "=="
param {
type: IDENT
identifier {
name: "name"
}
}
param {
type: PLACEHOLDER
position: 0
}
}
}
operation {
source {
name: "price"
}
operation: SET
value {
type: LITERAL
literal {
type: V_FLOAT
v_float: 256.53
}
}
}
args {
type: V_STRING
v_string {
value: "berry"
}
}
}
1 rows affected
Rows matched: 1 Changed: 1 Warnings: 0
RUN SELECT * FROM xtest.mytable ORDER BY price
id name price info
6 berry 256.53 {"color": "orange"}
2 apple 456.54 {"color": "red"}
5 orange 456.54 {"color": "orange"}
1 banana 895.63 {"color": "yellow"}
3 tomato 895.63 {"color": "red"}
4 mango 895.63 {"color": "green"}
0 rows affected
Update with String value and placeholder
send Mysqlx.Crud.Update {
collection {
name: "mytable"
schema: "xtest"
}
data_model: TABLE
criteria {
type: OPERATOR
operator {
name: "=="
param {
type: IDENT
identifier {
name: "price"
}
}
param {
type: PLACEHOLDER
position: 0
}
}
}
operation {
source {
name: "name"
}
operation: SET
value {
type: LITERAL
literal {
type: V_STRING
v_string {
value: "watermelon"
}
}
}
}
args {
type: V_DOUBLE
v_double: 256.53
}
}
1 rows affected
Rows matched: 1 Changed: 1 Warnings: 0
RUN SELECT * FROM xtest.mytable ORDER BY price
id name price info
6 watermelon 256.53 {"color": "orange"}
2 apple 456.54 {"color": "red"}
5 orange 456.54 {"color": "orange"}
1 banana 895.63 {"color": "yellow"}
3 tomato 895.63 {"color": "red"}
4 mango 895.63 {"color": "green"}
0 rows affected
Update with Null value and placeholder
send Mysqlx.Crud.Update {
collection {
name: "mytable"
schema: "xtest"
}
data_model: TABLE
criteria {
type: OPERATOR
operator {
name: "=="
param {
type: IDENT
identifier {
name: "name"
}
}
param {
type: PLACEHOLDER
position: 0
}
}
}
operation {
source {
name: "price"
}
operation: SET
value {
type: LITERAL
literal {
type: V_NULL
}
}
}
args {
type: V_STRING
v_string {
value: "banana"
}
}
}
1 rows affected
Rows matched: 1 Changed: 1 Warnings: 0
RUN SELECT * FROM xtest.mytable ORDER BY price
id name price info
1 banana null {"color": "yellow"}
6 watermelon 256.53 {"color": "orange"}
2 apple 456.54 {"color": "red"}
5 orange 456.54 {"color": "orange"}
3 tomato 895.63 {"color": "red"}
4 mango 895.63 {"color": "green"}
0 rows affected
Update with ITEM_MERGE value and placeholder
send Mysqlx.Crud.Update {
collection {
name: "mytable"
schema: "xtest"
}
data_model: TABLE
criteria {
type: OPERATOR
operator {
name: "=="
param {
type: IDENT
identifier {
name: "name"
}
}
param {
type: PLACEHOLDER
position: 0
}
}
}
operation {
source {
name: "info"
}
operation: ITEM_MERGE
value {
type: LITERAL
literal {
type: V_OCTETS
v_octets {
value: "{\"third\":3.0, \"fourth\": \"four\"}"
}
}
}
}
args {
type: V_STRING
v_string {
value: "banana"
}
}
}
1 rows affected
Rows matched: 1 Changed: 1 Warnings: 0
RUN SELECT * FROM xtest.mytable ORDER BY price
id name price info
1 banana null {"color": "yellow", "third": 3.0, "fourth": "four"}
6 watermelon 256.53 {"color": "orange"}
2 apple 456.54 {"color": "red"}
5 orange 456.54 {"color": "orange"}
3 tomato 895.63 {"color": "red"}
4 mango 895.63 {"color": "green"}
0 rows affected
RUN insert into xtest.mytable values (7, 'Grapes',null, '{"third": ["two"]}')
1 rows affected
Update with ARRAY_INSERT value and placeholder
send Mysqlx.Crud.Update {
collection {
name: "mytable"
schema: "xtest"
}
data_model: TABLE
criteria {
type: OPERATOR
operator {
name: "=="
param {
type: IDENT
identifier {
name: "name"
}
}
param {
type: PLACEHOLDER
position: 0
}
}
}
operation {
source {
document_path {
type: MEMBER
value: "third"
}
document_path {
type: ARRAY_INDEX
index: 0
}
name: "info"
}
operation: ARRAY_INSERT
value {
type: LITERAL
literal {
type: V_OCTETS
v_octets {
value: "two.1"
}
}
}
}
args {
type: V_STRING
v_string {
value: "Grapes"
}
}
}
1 rows affected
Rows matched: 1 Changed: 1 Warnings: 0
RUN SELECT * FROM xtest.mytable ORDER BY price
id name price info
1 banana null {"color": "yellow", "third": 3.0, "fourth": "four"}
7 Grapes null {"third": ["two.1", "two"]}
6 watermelon 256.53 {"color": "orange"}
2 apple 456.54 {"color": "red"}
5 orange 456.54 {"color": "orange"}
3 tomato 895.63 {"color": "red"}
4 mango 895.63 {"color": "green"}
0 rows affected
Delete with == Operator and placeholder
send Mysqlx.Crud.Delete {
collection {
name: "mytable"
schema: "xtest"
}
data_model: TABLE
criteria {
type: OPERATOR
operator {
name: "=="
param {
type: IDENT
identifier {
name: "price"
}
}
param {
type: PLACEHOLDER
position: 0
}
}
}
args {
type: V_DOUBLE
v_double: 256.53
}
}
1 rows affected
RUN SELECT * FROM xtest.mytable
id name price info
1 banana null {"color": "yellow", "third": 3.0, "fourth": "four"}
2 apple 456.54 {"color": "red"}
3 tomato 895.63 {"color": "red"}
4 mango 895.63 {"color": "green"}
5 orange 456.54 {"color": "orange"}
7 Grapes null {"third": ["two.1", "two"]}
0 rows affected
Delete with != Operator and placeholder
send Mysqlx.Crud.Delete {
collection {
name: "mytable"
schema: "xtest"
}
data_model: TABLE
criteria {
type: OPERATOR
operator {
name: "!="
param {
type: IDENT
identifier {
name: "price"
}
}
param {
type: PLACEHOLDER
position: 0
}
}
}
args {
type: V_DOUBLE
v_double: 256.53
}
}
4 rows affected
RUN SELECT * FROM xtest.mytable
id name price info
1 banana null {"color": "yellow", "third": 3.0, "fourth": "four"}
7 Grapes null {"third": ["two.1", "two"]}
0 rows affected
Find Wrong placeholder
send Mysqlx.Crud.Find {
collection {
name: "mytable"
schema: "xtest"
}
data_model: TABLE
criteria {
type: OPERATOR
operator {
name: ">"
param {
type: IDENT
identifier {
name: "price"
}
}
param {
type: PLACEHOLDER
position: 1
}
}
}
args {
type: V_DOUBLE
v_double: 0
}
}
Got expected error: Invalid value of placeholder (code 5154)
Find Missing placeholder
send Mysqlx.Crud.Find {
collection {
name: "mytable"
schema: "xtest"
}
data_model: TABLE
criteria {
type: OPERATOR
operator {
name: ">"
param {
type: IDENT
identifier {
name: "price"
}
}
param {
type: PLACEHOLDER
position: 0
}
}
}
}
Got expected error: Invalid value of placeholder (code 5154)
================================================================================
CLEAN UP
================================================================================
RUN drop schema if exists xtest
1 rows affected
Mysqlx.Ok {
msg: "bye!"
}
ok