| 1 |
## Put records in order using members of json doc |
| 2 |
|
| 3 |
## Preamble |
| 4 |
--source include/xplugin_preamble.inc |
| 5 |
--source include/xplugin_create_user.inc |
| 6 |
## Test starts here |
| 7 |
--write_file $MYSQL_TMP_DIR/crud_order_by.xpl |
| 8 |
## Test data |
| 9 |
-->sql |
| 10 |
create schema xtest; |
| 11 |
use xtest; |
| 12 |
create table xtable (doc JSON); |
| 13 |
insert into xtable (doc) values ('{"numeric": 2, "string": "2"}'); |
| 14 |
insert into xtable (doc) values ('{"numeric": 70, "string": "70"}'); |
| 15 |
insert into xtable (doc) values ('{"numeric": 5, "string": "5"}'); |
| 16 |
insert into xtable (doc) values ('{"numeric": 10, "string": "10"}'); |
| 17 |
insert into xtable (doc) values ('{"numeric": 1, "string": "1"}'); |
| 18 |
insert into xtable (doc) values ('{"numeric": 30, "string": "30"}'); |
| 19 |
SELECT * FROM xtest.xtable; |
| 20 |
-->endsql |
| 21 |
|
| 22 |
Mysqlx.Crud.Find { |
| 23 |
collection { |
| 24 |
name: "xtable" |
| 25 |
schema: "xtest" |
| 26 |
} |
| 27 |
data_model: TABLE |
| 28 |
order { |
| 29 |
expr { |
| 30 |
type: IDENT |
| 31 |
identifier { |
| 32 |
document_path { |
| 33 |
type: MEMBER |
| 34 |
value: "numeric" |
| 35 |
} |
| 36 |
} |
| 37 |
} |
| 38 |
} |
| 39 |
} |
| 40 |
-->recvresult |
| 41 |
|
| 42 |
|
| 43 |
Mysqlx.Crud.Find { |
| 44 |
collection { |
| 45 |
name: "xtable" |
| 46 |
schema: "xtest" |
| 47 |
} |
| 48 |
data_model: TABLE |
| 49 |
order { |
| 50 |
expr { |
| 51 |
type: IDENT |
| 52 |
identifier { |
| 53 |
document_path { |
| 54 |
type: MEMBER |
| 55 |
value: "string" |
| 56 |
} |
| 57 |
} |
| 58 |
} |
| 59 |
} |
| 60 |
} |
| 61 |
-->recvresult |
| 62 |
|
| 63 |
EOF |
| 64 |
|
| 65 |
--exec $MYSQLXTEST -ux_root --password='' --file=$MYSQL_TMP_DIR/crud_order_by.xpl 2>&1 |
| 66 |
|
| 67 |
## Cleanup |
| 68 |
--source ../include/xplugin_cleanup.inc |