2014-05-05 13:44:58 +00:00
|
|
|
#! /bin/bash
|
|
|
|
|
2022-08-17 03:46:23 +00:00
|
|
|
run_cap_test ./drive_sql "select json_concat('[null,', 1.0, 2.0)"
|
|
|
|
|
2022-04-30 20:05:42 +00:00
|
|
|
run_cap_test ./drive_sql "select json_concat(json('[null, true, 0]'), 1.0, 2.0)"
|
2021-06-02 15:59:53 +00:00
|
|
|
|
2022-04-30 20:05:42 +00:00
|
|
|
run_cap_test ./drive_sql "select json_concat(json('[\"tag0\"]'), 'tag1', 'tag2')"
|
2021-09-27 22:54:10 +00:00
|
|
|
|
2022-04-30 20:05:42 +00:00
|
|
|
run_cap_test ./drive_sql "select json_concat(NULL, NULL)"
|
2021-09-27 22:54:10 +00:00
|
|
|
|
2022-04-30 20:05:42 +00:00
|
|
|
run_cap_test ./drive_sql "select json_concat(NULL, json('{\"abc\": 1}'))"
|
2021-09-27 22:54:10 +00:00
|
|
|
|
2022-04-30 20:05:42 +00:00
|
|
|
run_cap_test ./drive_sql "select json_contains(NULL, 4)"
|
2021-09-27 22:54:10 +00:00
|
|
|
|
2022-04-30 20:05:42 +00:00
|
|
|
run_cap_test ./drive_sql "select json_contains('', 4)"
|
2021-09-27 22:54:10 +00:00
|
|
|
|
2022-04-30 20:05:42 +00:00
|
|
|
run_cap_test ./drive_sql "select json_contains('null', NULL)"
|
2021-09-27 22:54:10 +00:00
|
|
|
|
2022-04-30 20:05:42 +00:00
|
|
|
run_cap_test ./drive_sql "select json_contains('[[0]]', 0)"
|
2021-09-27 22:54:10 +00:00
|
|
|
|
2022-04-30 20:05:42 +00:00
|
|
|
run_cap_test ./drive_sql "select json_contains('4', 4)"
|
2018-05-17 14:06:50 +00:00
|
|
|
|
2022-04-30 20:05:42 +00:00
|
|
|
run_cap_test ./drive_sql "select json_contains('4', 2)"
|
2018-05-17 14:06:50 +00:00
|
|
|
|
2022-04-30 20:05:42 +00:00
|
|
|
run_cap_test env TEST_COMMENT='contains1' ./drive_sql <<EOF
|
2018-05-17 14:06:50 +00:00
|
|
|
select json_contains('"hi"', 'hi')
|
|
|
|
EOF
|
|
|
|
|
2022-07-16 04:41:47 +00:00
|
|
|
run_cap_test env TEST_COMMENT='contains1.5' ./drive_sql <<EOF
|
|
|
|
select json_contains('"hi"', 'hi there')
|
|
|
|
EOF
|
|
|
|
|
2022-04-30 20:05:42 +00:00
|
|
|
run_cap_test env TEST_COMMENT='contains2' ./drive_sql <<EOF
|
2018-05-17 14:06:50 +00:00
|
|
|
select json_contains('["hi", "bye"]', 'hola') as res
|
|
|
|
EOF
|
|
|
|
|
2022-04-30 20:05:42 +00:00
|
|
|
run_cap_test env TEST_COMMENT='contains3' ./drive_sql <<EOF
|
2018-05-17 14:06:50 +00:00
|
|
|
select json_contains('["hi", "bye", "solong"]', 'bye') as res
|
|
|
|
EOF
|
|
|
|
|
2022-04-30 20:05:42 +00:00
|
|
|
run_cap_test env TEST_COMMENT='contains4' ./drive_sql <<EOF
|
2018-05-17 14:06:50 +00:00
|
|
|
select json_contains('["hi", "bye", "solong]', 'bye') as res
|
|
|
|
EOF
|
|
|
|
|
2022-08-17 03:46:23 +00:00
|
|
|
run_cap_test ./drive_sql "select jget()"
|
|
|
|
|
|
|
|
run_cap_test ./drive_sql "select jget('[123, true', '/0')"
|
|
|
|
|
2022-04-30 20:05:42 +00:00
|
|
|
run_cap_test ./drive_sql "select jget('4', '')"
|
2018-05-17 14:06:50 +00:00
|
|
|
|
2022-04-30 20:05:42 +00:00
|
|
|
run_cap_test ./drive_sql "select jget('4', null)"
|
2021-09-10 05:22:52 +00:00
|
|
|
|
2022-04-30 20:05:42 +00:00
|
|
|
run_cap_test ./drive_sql "select jget('[null, true, 20, 30, 40]', '/3')"
|
2021-09-10 05:22:52 +00:00
|
|
|
|
2022-04-30 20:05:42 +00:00
|
|
|
run_cap_test ./drive_sql "select typeof(jget('[null, true, 20, 30, 40]', '/3'))"
|
2021-09-10 05:22:52 +00:00
|
|
|
|
2022-04-30 20:05:42 +00:00
|
|
|
run_cap_test ./drive_sql "select jget('[null, true, 20, 30, 40, {\"msg\": \"Hello\"}]', '/5')"
|
2021-06-02 15:59:53 +00:00
|
|
|
|
2022-04-30 20:05:42 +00:00
|
|
|
run_cap_test ./drive_sql "select jget('[null, true, 20, 30, 40, {\"msg\": \"Hello\"}]', '/5/msg')"
|
2021-06-02 15:59:53 +00:00
|
|
|
|
2022-04-30 20:05:42 +00:00
|
|
|
run_cap_test ./drive_sql "select jget('[null, true, 20, 30, 40, {\"msg\": \"Hello\"}]', '')"
|
2021-06-02 15:59:53 +00:00
|
|
|
|
2022-04-30 20:05:42 +00:00
|
|
|
run_cap_test ./drive_sql "select jget('[null, true, 20, 30, 40]', '/abc')"
|
2015-12-01 05:07:18 +00:00
|
|
|
|
2022-04-30 20:05:42 +00:00
|
|
|
run_cap_test ./drive_sql "select jget('[null, true, 20, 30, 40]', '/abc', 1)"
|
2015-12-01 05:07:18 +00:00
|
|
|
|
2022-04-30 20:05:42 +00:00
|
|
|
run_cap_test ./drive_sql "select jget('[null, true, 20, 30, 40]', '/0')"
|
2015-12-01 05:07:18 +00:00
|
|
|
|
2022-04-30 20:05:42 +00:00
|
|
|
run_cap_test ./drive_sql "select jget('[null, true, 20, 30, 40]', '/0/foo')"
|
2021-09-10 05:22:52 +00:00
|
|
|
|
2022-04-30 20:05:42 +00:00
|
|
|
run_cap_test ./drive_sql "select jget('[null, true, 20, 30, 4.0]', '/4')"
|
2021-09-10 05:22:52 +00:00
|
|
|
|
2022-04-30 20:05:42 +00:00
|
|
|
run_cap_test ./drive_sql "select typeof(jget('[null, true, 20, 30, 4.0]', '/4'))"
|
2014-05-05 13:44:58 +00:00
|
|
|
|
2022-04-30 20:05:42 +00:00
|
|
|
run_cap_test ./drive_sql "select jget('[null, true, 20, 30, 40', '/0/foo')"
|
2014-05-05 13:44:58 +00:00
|
|
|
|
2022-04-30 20:05:42 +00:00
|
|
|
run_cap_test ./drive_sql "select json_group_object(key) from (select 1 as key)"
|
2015-11-30 03:56:10 +00:00
|
|
|
|
|
|
|
GROUP_SELECT_1=$(cat <<EOF
|
|
|
|
SELECT id, json_group_object(key, value) as stack FROM (
|
|
|
|
SELECT 1 as id, 'key1' as key, 10 as value
|
|
|
|
UNION ALL SELECT 1 as id, 'key2' as key, 20 as value
|
|
|
|
UNION ALL SELECT 1 as id, 'key3' as key, 30 as value)
|
|
|
|
EOF
|
|
|
|
)
|
|
|
|
|
2022-04-30 20:05:42 +00:00
|
|
|
run_cap_test ./drive_sql "$GROUP_SELECT_1"
|
2015-11-30 03:56:10 +00:00
|
|
|
|
|
|
|
GROUP_SELECT_2=$(cat <<EOF
|
|
|
|
SELECT id, json_group_object(key, value) as stack FROM (
|
|
|
|
SELECT 1 as id, 1 as key, 10 as value
|
|
|
|
UNION ALL SELECT 1 as id, 2 as key, null as value
|
|
|
|
UNION ALL SELECT 1 as id, 3 as key, 30.5 as value)
|
|
|
|
EOF
|
|
|
|
)
|
|
|
|
|
2022-04-30 20:05:42 +00:00
|
|
|
run_cap_test ./drive_sql "$GROUP_SELECT_2"
|
2015-12-10 05:20:49 +00:00
|
|
|
|
|
|
|
if test x"$HAVE_SQLITE3_VALUE_SUBTYPE" != x""; then
|
|
|
|
GROUP_SELECT_3=$(cat <<EOF
|
2022-07-16 15:04:32 +00:00
|
|
|
SELECT id, json_group_object(key, json(value)) as stack FROM (
|
2015-12-10 05:20:49 +00:00
|
|
|
SELECT 1 as id, 1 as key, 10 as value
|
|
|
|
UNION ALL SELECT 1 as id, 2 as key, json_array(1, 2, 3) as value
|
|
|
|
UNION ALL SELECT 1 as id, 3 as key, 30.5 as value)
|
|
|
|
EOF
|
|
|
|
)
|
|
|
|
|
2022-04-30 20:05:42 +00:00
|
|
|
run_cap_test ./drive_sql "$GROUP_SELECT_3"
|
2015-12-10 05:20:49 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
GROUP_ARRAY_SELECT_1=$(cat <<EOF
|
|
|
|
SELECT json_group_array(value) as stack FROM (
|
|
|
|
SELECT 10 as value
|
|
|
|
UNION ALL SELECT null as value
|
|
|
|
UNION ALL SELECT 'hello' as value)
|
|
|
|
EOF
|
|
|
|
)
|
|
|
|
|
2022-04-30 20:05:42 +00:00
|
|
|
run_cap_test ./drive_sql "$GROUP_ARRAY_SELECT_1"
|
2015-12-10 05:20:49 +00:00
|
|
|
|
|
|
|
GROUP_ARRAY_SELECT_2=$(cat <<EOF
|
|
|
|
SELECT json_group_array(value, value * 10) as stack FROM (
|
|
|
|
SELECT 10 as value
|
|
|
|
UNION ALL SELECT 20 as value
|
|
|
|
UNION ALL SELECT 30 as value)
|
|
|
|
EOF
|
|
|
|
)
|
|
|
|
|
2022-04-30 20:05:42 +00:00
|
|
|
run_cap_test ./drive_sql "$GROUP_ARRAY_SELECT_2"
|
2022-09-16 20:02:52 +00:00
|
|
|
|
|
|
|
run_cap_test ./drive_sql "SELECT json_group_array(column1) FROM (VALUES (1)) WHERE 0"
|