code
stringlengths 26
870k
| docstring
stringlengths 1
65.6k
| func_name
stringlengths 1
194
| language
stringclasses 1
value | repo
stringlengths 8
68
| path
stringlengths 5
182
| url
stringlengths 46
251
| license
stringclasses 4
values |
---|---|---|---|---|---|---|---|
def test_sql_parse_query_20(self):
"""
FETCH 1000 FROM cursor_123
""" | FETCH 1000 FROM cursor_123 | test_sql_parse_query_20 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_query_21(self):
"""
CLOSE cursor_123
""" | CLOSE cursor_123 | test_sql_parse_query_21 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_query_22(self):
"""
CREATE VIEW view_a (a, b) AS WITH RECURSIVE view_a (a, b) AS
(SELECT * FROM a(1)) SELECT "a", "b" FROM "view_a"
""" | CREATE VIEW view_a (a, b) AS WITH RECURSIVE view_a (a, b) AS
(SELECT * FROM a(1)) SELECT "a", "b" FROM "view_a" | test_sql_parse_query_22 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_query_23(self):
"""
CREATE FOREIGN TABLE ft1 () SERVER no_server
""" | CREATE FOREIGN TABLE ft1 () SERVER no_server | test_sql_parse_query_23 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_query_24(self):
"""
CREATE TEMPORARY TABLE my_temp_table (
test_id integer NOT NULL
) ON COMMIT DROP
% OK %
CREATE TEMPORARY TABLE my_temp_table (
test_id pg_catalog.int4 NOT NULL
) ON COMMIT DROP
""" | CREATE TEMPORARY TABLE my_temp_table (
test_id integer NOT NULL
) ON COMMIT DROP
% OK %
CREATE TEMPORARY TABLE my_temp_table (
test_id pg_catalog.int4 NOT NULL
) ON COMMIT DROP | test_sql_parse_query_24 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_query_25(self):
"""
CREATE TEMPORARY TABLE my_temp_table AS (SELECT 1) WITH NO DATA
""" | CREATE TEMPORARY TABLE my_temp_table AS (SELECT 1) WITH NO DATA | test_sql_parse_query_25 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_query_26(self):
"""
CREATE TABLE types (
a float(2), b float(49),
c NUMERIC(2, 3), d character(4), e char(5),
f varchar(6), g character varying(7))
% OK %
CREATE TABLE types (
a pg_catalog.float4,
b pg_catalog.float8,
c pg_catalog.numeric,
d pg_catalog.bpchar,
e pg_catalog.bpchar,
f pg_catalog.varchar,
g pg_catalog.varchar
)
""" | CREATE TABLE types (
a float(2), b float(49),
c NUMERIC(2, 3), d character(4), e char(5),
f varchar(6), g character varying(7))
% OK %
CREATE TABLE types (
a pg_catalog.float4,
b pg_catalog.float8,
c pg_catalog.numeric,
d pg_catalog.bpchar,
e pg_catalog.bpchar,
f pg_catalog.varchar,
g pg_catalog.varchar
) | test_sql_parse_query_26 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_query_27(self):
"""
SET LOCAL search_path TO 'my_schema', 'public'
""" | SET LOCAL search_path TO 'my_schema', 'public' | test_sql_parse_query_27 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_query_28(self):
"""
SET SESSION datestyle TO postgres, dmy
% OK %
SET datestyle TO 'postgres', 'dmy'
""" | SET SESSION datestyle TO postgres, dmy
% OK %
SET datestyle TO 'postgres', 'dmy' | test_sql_parse_query_28 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_query_29(self):
"""
SHOW search_path
""" | SHOW search_path | test_sql_parse_query_29 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_query_30(self):
"""
SHOW TIME ZONE
% OK %
SHOW timezone
""" | SHOW TIME ZONE
% OK %
SHOW timezone | test_sql_parse_query_30 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_query_31(self):
"""
SELECT ('asxasx')[2][3:4]
""" | SELECT ('asxasx')[2][3:4] | test_sql_parse_query_31 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_query_32(self):
"""
SELECT ((blah(4))[0])[2][3:4][2][5:5]
""" | SELECT ((blah(4))[0])[2][3:4][2][5:5] | test_sql_parse_query_32 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_query_33(self):
"""
SELECT a <= ANY (ARRAY[1, 2, 3])
""" | SELECT a <= ANY (ARRAY[1, 2, 3]) | test_sql_parse_query_33 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_query_34(self):
"""
SELECT a <= ALL (ARRAY[1, 2, 3])
""" | SELECT a <= ALL (ARRAY[1, 2, 3]) | test_sql_parse_query_34 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_query_35(self):
"""
SELECT a <= some(array[1, 2, 3])
% OK %
SELECT a <= ANY (ARRAY[1, 2, 3])
""" | SELECT a <= some(array[1, 2, 3])
% OK %
SELECT a <= ANY (ARRAY[1, 2, 3]) | test_sql_parse_query_35 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_query_36(self):
"""
SELECT a NOT IN (1, 2, 3)
% OK %
SELECT (a NOT IN (1, 2, 3))
""" | SELECT a NOT IN (1, 2, 3)
% OK %
SELECT (a NOT IN (1, 2, 3)) | test_sql_parse_query_36 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_query_37(self):
"""
SELECT a NOT LIKE 'a%'
% OK %
SELECT (a NOT LIKE 'a%')
""" | SELECT a NOT LIKE 'a%'
% OK %
SELECT (a NOT LIKE 'a%') | test_sql_parse_query_37 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_query_38(self):
"""
SELECT a NOT ILIKE 'a%'
% OK %
SELECT (a NOT ILIKE 'a%')
""" | SELECT a NOT ILIKE 'a%'
% OK %
SELECT (a NOT ILIKE 'a%') | test_sql_parse_query_38 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_query_39(self):
"""
SELECT a ILIKE 'a%'
% OK %
SELECT (a ILIKE 'a%')
""" | SELECT a ILIKE 'a%'
% OK %
SELECT (a ILIKE 'a%') | test_sql_parse_query_39 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_query_40(self):
"""
WITH RECURSIVE t(n) AS (((
VALUES (1)
) UNION ALL (
SELECT (n + 1) FROM t WHERE (n < 100)
)))
SELECT sum(n) FROM t
""" | WITH RECURSIVE t(n) AS (((
VALUES (1)
) UNION ALL (
SELECT (n + 1) FROM t WHERE (n < 100)
)))
SELECT sum(n) FROM t | test_sql_parse_query_40 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_query_41(self):
"""
SELECT 1 FROM t WHERE ia.attnum > 0 AND NOT ia.attisdropped
% OK %
SELECT 1 FROM t WHERE ((ia.attnum > 0) AND (NOT ia.attisdropped))
""" | SELECT 1 FROM t WHERE ia.attnum > 0 AND NOT ia.attisdropped
% OK %
SELECT 1 FROM t WHERE ((ia.attnum > 0) AND (NOT ia.attisdropped)) | test_sql_parse_query_41 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_query_42(self):
"""
SELECT ($1)::oid[]
""" | SELECT ($1)::oid[] | test_sql_parse_query_42 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_query_43(self):
"""
SELECT ($1)::oid[5]
""" | SELECT ($1)::oid[5] | test_sql_parse_query_43 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_query_44(self):
"""
SELECT ($1)::oid[5][6]
""" | SELECT ($1)::oid[5][6] | test_sql_parse_query_44 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_query_45(self):
"""
SET LOCAL search_path TO DEFAULT
""" | SET LOCAL search_path TO DEFAULT | test_sql_parse_query_45 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_query_46(self):
"""
SET SESSION search_path TO DEFAULT
% OK %
SET search_path TO DEFAULT
""" | SET SESSION search_path TO DEFAULT
% OK %
SET search_path TO DEFAULT | test_sql_parse_query_46 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_query_47(self):
"""
RESET search_path
% OK %
SET search_path TO DEFAULT
""" | RESET search_path
% OK %
SET search_path TO DEFAULT | test_sql_parse_query_47 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_query_48(self):
"""
RESET ALL
""" | RESET ALL | test_sql_parse_query_48 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_query_49(self):
"""
SELECT nullif(a, 3) FROM b
""" | SELECT nullif(a, 3) FROM b | test_sql_parse_query_49 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_query_50(self):
"""
SELECT 'a'::char, 'a'::"char"
% OK %
SELECT ('a')::pg_catalog.bpchar, ('a')::pg_catalog.char
""" | SELECT 'a'::char, 'a'::"char"
% OK %
SELECT ('a')::pg_catalog.bpchar, ('a')::pg_catalog.char | test_sql_parse_query_50 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_query_51(self):
"""
SELECT ARRAY ((SELECT c FROM a)) FROM b
""" | SELECT ARRAY ((SELECT c FROM a)) FROM b | test_sql_parse_query_51 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_query_52(self):
"""
SELECT * FROM b WHERE (c ILIKE 'blah%' COLLATE collation_name)
""" | SELECT * FROM b WHERE (c ILIKE 'blah%' COLLATE collation_name) | test_sql_parse_query_52 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_query_53(self):
"""
SELECT GREATEST(x, y, 0), LEAST(x, y, 100) FROM b
""" | SELECT GREATEST(x, y, 0), LEAST(x, y, 100) FROM b | test_sql_parse_query_53 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_query_54(self):
"""
SELECT (x IS DISTINCT FROM y) FROM b
""" | SELECT (x IS DISTINCT FROM y) FROM b | test_sql_parse_query_54 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_query_55(self):
"""
SELECT (x IS NOT DISTINCT FROM y) FROM b
""" | SELECT (x IS NOT DISTINCT FROM y) FROM b | test_sql_parse_query_55 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_lock_01(self):
'''
LOCK TABLE films IN ACCESS SHARE MODE
''' | LOCK TABLE films IN ACCESS SHARE MODE | test_sql_parse_lock_01 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_lock_02(self):
'''
LOCK TABLE films IN ACCESS SHARE MODE NOWAIT
''' | LOCK TABLE films IN ACCESS SHARE MODE NOWAIT | test_sql_parse_lock_02 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_lock_03(self):
'''
LOCK TABLE ONLY (films) IN ACCESS SHARE MODE
''' | LOCK TABLE ONLY (films) IN ACCESS SHARE MODE | test_sql_parse_lock_03 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_lock_04(self):
'''
LOCK TABLE ONLY (films) IN ACCESS SHARE MODE NOWAIT
''' | LOCK TABLE ONLY (films) IN ACCESS SHARE MODE NOWAIT | test_sql_parse_lock_04 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_lock_05(self):
'''
LOCK TABLE films IN ROW SHARE MODE
''' | LOCK TABLE films IN ROW SHARE MODE | test_sql_parse_lock_05 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_lock_06(self):
'''
LOCK TABLE films IN ROW EXCLUSIVE MODE
''' | LOCK TABLE films IN ROW EXCLUSIVE MODE | test_sql_parse_lock_06 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_lock_07(self):
'''
LOCK TABLE films IN SHARE UPDATE EXCLUSIVE MODE
''' | LOCK TABLE films IN SHARE UPDATE EXCLUSIVE MODE | test_sql_parse_lock_07 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_lock_08(self):
'''
LOCK TABLE films IN SHARE MODE
''' | LOCK TABLE films IN SHARE MODE | test_sql_parse_lock_08 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_lock_09(self):
'''
LOCK TABLE films IN SHARE ROW EXCLUSIVE MODE
''' | LOCK TABLE films IN SHARE ROW EXCLUSIVE MODE | test_sql_parse_lock_09 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_lock_10(self):
'''
LOCK TABLE films IN EXCLUSIVE MODE
''' | LOCK TABLE films IN EXCLUSIVE MODE | test_sql_parse_lock_10 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_lock_11(self):
'''
LOCK TABLE films IN ACCESS EXCLUSIVE MODE
''' | LOCK TABLE films IN ACCESS EXCLUSIVE MODE | test_sql_parse_lock_11 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_transaction_29(self):
"""
SET SESSION transaction_isolation = serializable
% OK %
SET LOCAL transaction_isolation TO 'serializable'
""" | SET SESSION transaction_isolation = serializable
% OK %
SET LOCAL transaction_isolation TO 'serializable' | test_sql_parse_transaction_29 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_transaction_30(self):
"""
RESET transaction_deferrable
% OK %
SET LOCAL transaction_deferrable TO DEFAULT
""" | RESET transaction_deferrable
% OK %
SET LOCAL transaction_deferrable TO DEFAULT | test_sql_parse_transaction_30 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_transaction_31(self):
"""
SET transaction_read_only TO DEFAULT
% OK %
SET LOCAL transaction_read_only TO DEFAULT
""" | SET transaction_read_only TO DEFAULT
% OK %
SET LOCAL transaction_read_only TO DEFAULT | test_sql_parse_transaction_31 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_copy_01(self):
"""
COPY "Movie" TO STDOUT (
FORMAT CSV,
FREEZE,
DELIMITER '|',
NULL 'this is a null',
HEADER FALSE,
QUOTE '''',
ESCAPE 'e',
FORCE_QUOTE (title, year_release),
FORCE_NOT_NULL (title),
FORCE_NULL (year_release),
ENCODING 'UTF-8'
)
""" | COPY "Movie" TO STDOUT (
FORMAT CSV,
FREEZE,
DELIMITER '|',
NULL 'this is a null',
HEADER FALSE,
QUOTE '''',
ESCAPE 'e',
FORCE_QUOTE (title, year_release),
FORCE_NOT_NULL (title),
FORCE_NULL (year_release),
ENCODING 'UTF-8'
) | test_sql_parse_copy_01 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_copy_02(self):
"""
COPY ((SELECT * FROM "Movie")) TO STDOUT
""" | COPY ((SELECT * FROM "Movie")) TO STDOUT | test_sql_parse_copy_02 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_copy_03(self):
"""
COPY "Movie" (title, release_year) FROM STDIN WHERE (id > 100)
""" | COPY "Movie" (title, release_year) FROM STDIN WHERE (id > 100) | test_sql_parse_copy_03 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_copy_04(self):
"""
COPY country TO STDOUT (DELIMITER '|')
""" | COPY country TO STDOUT (DELIMITER '|') | test_sql_parse_copy_04 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_copy_05(self):
"""
COPY country FROM '/usr1/proj/bray/sql/country_data'
""" | COPY country FROM '/usr1/proj/bray/sql/country_data' | test_sql_parse_copy_05 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_copy_06(self):
"""
COPY country TO PROGRAM 'gzip > /usr1/proj/bray/sql/country_data.gz'
""" | COPY country TO PROGRAM 'gzip > /usr1/proj/bray/sql/country_data.gz' | test_sql_parse_copy_06 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_table(self):
"""
TABLE hello_world
% OK %
SELECT * FROM hello_world
""" | TABLE hello_world
% OK %
SELECT * FROM hello_world | test_sql_parse_table | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_select_locking_00(self):
"""
SELECT id FROM a FOR UPDATE
""" | SELECT id FROM a FOR UPDATE | test_sql_parse_select_locking_00 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_select_locking_01(self):
"""
SELECT id FROM a FOR NO KEY UPDATE
""" | SELECT id FROM a FOR NO KEY UPDATE | test_sql_parse_select_locking_01 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_select_locking_02(self):
"""
SELECT id FROM a FOR SHARE
""" | SELECT id FROM a FOR SHARE | test_sql_parse_select_locking_02 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_select_locking_03(self):
"""
SELECT id FROM a FOR KEY SHARE
""" | SELECT id FROM a FOR KEY SHARE | test_sql_parse_select_locking_03 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_select_locking_04(self):
"""
SELECT id FROM a FOR UPDATE NOWAIT
""" | SELECT id FROM a FOR UPDATE NOWAIT | test_sql_parse_select_locking_04 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_select_locking_05(self):
"""
SELECT id FROM a FOR UPDATE SKIP LOCKED
""" | SELECT id FROM a FOR UPDATE SKIP LOCKED | test_sql_parse_select_locking_05 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
def test_sql_parse_select_locking_06(self):
"""
SELECT id FROM a FOR UPDATE OF b
""" | SELECT id FROM a FOR UPDATE OF b | test_sql_parse_select_locking_06 | python | geldata/gel | tests/test_sql_parse.py | https://github.com/geldata/gel/blob/master/tests/test_sql_parse.py | Apache-2.0 |
async def do_basic_work(self):
"""Do a standardized set of DML operations.
We'll run this with different triggers and observe the results
"""
# This is multiple queries instead of one so that if one of them
# errors, it is immediately obvious which.
#
# ... I forgot this at some point and merged them, so now I am
# adding a note.
await self.con.execute('''
insert InsertTest { name := "a" };
''')
await self.con.execute('''
select {
(insert InsertTest { name := "b" }),
(update InsertTest filter .name = 'a'
set { name := 'a!' }),
};
''')
await self.con.execute('''
select {
(insert InsertTest { name := "c" }),
(insert DerivedTest { name := "d" }),
(update InsertTest filter .name = 'b'
set { name := 'b!' }),
(delete InsertTest filter .name = "a!"),
};
''')
await self.con.execute('''
select {
(for x in {'e', 'f'} union (insert DerivedTest { name := x })),
(delete InsertTest filter .name = "b!"),
};
''')
await self.con.execute('''
update InsertTest filter .name = 'd'
set { name := .name ++ '!' };
''')
await self.con.execute('''
for x in {'c', 'e'} union (
update InsertTest filter .name = x
set { name := x ++ '!' }
);
''')
await self.con.execute('''
select {
(update DerivedTest filter .name = 'f'
set { name := 'f!' }),
(delete DerivedTest filter .name = 'd!'),
};
''')
await self.con.execute('''
delete InsertTest;
''') | Do a standardized set of DML operations.
We'll run this with different triggers and observe the results | do_basic_work | python | geldata/gel | tests/test_edgeql_triggers.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_triggers.py | Apache-2.0 |
async def test_edgeql_triggers_insert_01(self):
await self.con.execute('''
alter type InsertTest {
create trigger log after insert for each do (
insert Note { name := "insert", note := __new__.name }
);
};
''')
await self.do_basic_work()
await self.assert_notes([
{'name': "insert", 'notes': set("abcdef")},
])
# We should still be able to insert Note normally
await self.con.execute('''
select {
(insert InsertTest { name := "foo" }),
(insert Note { name := "manual", note := "!" }),
};
''') | )
await self.do_basic_work()
await self.assert_notes([
{'name': "insert", 'notes': set("abcdef")},
])
# We should still be able to insert Note normally
await self.con.execute( | test_edgeql_triggers_insert_01 | python | geldata/gel | tests/test_edgeql_triggers.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_triggers.py | Apache-2.0 |
async def test_edgeql_triggers_mixed_all_01(self):
# Install FOR ALL triggers for everything
await self.con.execute('''
alter type InsertTest {
create trigger log_del after delete for all do (
insert Note { name := "delete", notes := __old__.name }
);
create trigger log_ins after insert for all do (
insert Note { name := "insert", notes := __new__.name }
);
create trigger log_upd after update for all do (
insert Note {
name := "update",
notes := __old__.name,
subject := (insert DerivedNote {
name := "", notes := __new__.name
})
}
)
};
''')
await self.do_basic_work()
res = tb.bag([
{"name": "insert", "notes": ["a"], "subject": None},
{"name": "insert", "notes": ["b"], "subject": None},
{"name": "insert", "notes": {"c", "d"}, "subject": None},
{"name": "insert", "notes": {"e", "f"}, "subject": None},
{"name": "update", "notes": ["a"], "subject": {"notes": ["a!"]}},
{"name": "update", "notes": ["b"], "subject": {"notes": ["b!"]}},
{"name": "update", "notes": ["d"], "subject": {"notes": ["d!"]}},
{
"name": "update",
"notes": {"c", "e"},
"subject": {"notes": {"c!", "e!"}}
},
{"name": "update", "notes": ["f"], "subject": {"notes": ["f!"]}},
{"name": "delete", "notes": ["b!"], "subject": None},
{"name": "delete", "notes": ["d!"], "subject": None},
{"name": "delete", "notes": ["a!"], "subject": None},
{"name": "delete", "notes": {"c!", "e!", "f!"}, "subject": None},
])
await self.assert_query_result(
'''
select Note { name, notes, subject[is Note]: {notes} }
filter .name != "";
''',
res,
) | )
await self.do_basic_work()
res = tb.bag([
{"name": "insert", "notes": ["a"], "subject": None},
{"name": "insert", "notes": ["b"], "subject": None},
{"name": "insert", "notes": {"c", "d"}, "subject": None},
{"name": "insert", "notes": {"e", "f"}, "subject": None},
{"name": "update", "notes": ["a"], "subject": {"notes": ["a!"]}},
{"name": "update", "notes": ["b"], "subject": {"notes": ["b!"]}},
{"name": "update", "notes": ["d"], "subject": {"notes": ["d!"]}},
{
"name": "update",
"notes": {"c", "e"},
"subject": {"notes": {"c!", "e!"}}
},
{"name": "update", "notes": ["f"], "subject": {"notes": ["f!"]}},
{"name": "delete", "notes": ["b!"], "subject": None},
{"name": "delete", "notes": ["d!"], "subject": None},
{"name": "delete", "notes": ["a!"], "subject": None},
{"name": "delete", "notes": {"c!", "e!", "f!"}, "subject": None},
])
await self.assert_query_result( | test_edgeql_triggers_mixed_all_01 | python | geldata/gel | tests/test_edgeql_triggers.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_triggers.py | Apache-2.0 |
async def test_edgeql_triggers_mixed_all_02(self):
# Install FOR ALL triggers for everything
await self.con.execute('''
alter type InsertTest {
create trigger log_new after insert, update for all do (
insert Note { name := "new", notes := __new__.name }
);
create trigger log_old after delete, update for all do (
insert Note { name := "old", notes := __old__.name }
);
create trigger log_all after delete, update, insert for all do (
insert Note { name := "all", notes := "." }
);
};
''')
await self.do_basic_work()
res = tb.bag([
{"name": "all", "notes": {"."}},
{"name": "all", "notes": {"."}},
{"name": "all", "notes": {"."}},
{"name": "all", "notes": {"."}},
{"name": "all", "notes": {"."}},
{"name": "all", "notes": {"."}},
{"name": "all", "notes": {"."}},
{"name": "all", "notes": {"."}},
{"name": "new", "notes": {"a"}},
{"name": "new", "notes": {"c!", "e!"}},
{"name": "new", "notes": {"d!"}},
{"name": "new", "notes": {"e", "f"}},
{"name": "new", "notes": {"f!"}},
{"name": "new", "notes": {"b", "a!"}},
{"name": "new", "notes": {"b!", "d", "c"}},
{"name": "old", "notes": {"f", "d!"}},
{"name": "old", "notes": {"a"}},
{"name": "old", "notes": {"b", "a!"}},
{"name": "old", "notes": {"b!"}},
{"name": "old", "notes": {"d"}},
{"name": "old", "notes": {"c", "e"}},
{"name": "old", "notes": {"c!", "e!", "f!"}},
])
await self.assert_query_result(
'''
select Note { name, notes } order by .name
''',
res,
) | )
await self.do_basic_work()
res = tb.bag([
{"name": "all", "notes": {"."}},
{"name": "all", "notes": {"."}},
{"name": "all", "notes": {"."}},
{"name": "all", "notes": {"."}},
{"name": "all", "notes": {"."}},
{"name": "all", "notes": {"."}},
{"name": "all", "notes": {"."}},
{"name": "all", "notes": {"."}},
{"name": "new", "notes": {"a"}},
{"name": "new", "notes": {"c!", "e!"}},
{"name": "new", "notes": {"d!"}},
{"name": "new", "notes": {"e", "f"}},
{"name": "new", "notes": {"f!"}},
{"name": "new", "notes": {"b", "a!"}},
{"name": "new", "notes": {"b!", "d", "c"}},
{"name": "old", "notes": {"f", "d!"}},
{"name": "old", "notes": {"a"}},
{"name": "old", "notes": {"b", "a!"}},
{"name": "old", "notes": {"b!"}},
{"name": "old", "notes": {"d"}},
{"name": "old", "notes": {"c", "e"}},
{"name": "old", "notes": {"c!", "e!", "f!"}},
])
await self.assert_query_result( | test_edgeql_triggers_mixed_all_02 | python | geldata/gel | tests/test_edgeql_triggers.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_triggers.py | Apache-2.0 |
async def test_edgeql_triggers_chain_01(self):
await self.con.execute('''
alter type InsertTest {
create trigger log after insert for each do (
insert Note { name := "insert", note := __new__.name }
);
};
alter type Note {
create trigger log after insert for each do (
insert Subordinate { val := 1, name := __new__.note }
);
};
''')
await self.do_basic_work()
await self.assert_notes([
{'name': "insert", 'notes': set("abcdef")},
])
await self.assert_query_result(
'''
select Subordinate.name
''',
set("abcdef"),
) | )
await self.do_basic_work()
await self.assert_notes([
{'name': "insert", 'notes': set("abcdef")},
])
await self.assert_query_result( | test_edgeql_triggers_chain_01 | python | geldata/gel | tests/test_edgeql_triggers.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_triggers.py | Apache-2.0 |
async def test_edgeql_triggers_chain_03(self):
await self.con.execute('''
alter type InsertTest {
create trigger log after insert for each do (
insert Note { name := "insert", note := __new__.name }
);
};
alter type Note {
create trigger log after insert for each do (
insert Subordinate { val := 1, name := __new__.note }
);
};
''')
async with self.assertRaisesRegexTx(
edgedb.QueryError,
'would need to be executed in multiple stages on default::Note '
'after insert'):
await self.con.execute('''
select {
(insert InsertTest { name := "foo" }),
(insert Note { name := "foo" }),
}
''') | )
async with self.assertRaisesRegexTx(
edgedb.QueryError,
'would need to be executed in multiple stages on default::Note '
'after insert'):
await self.con.execute( | test_edgeql_triggers_chain_03 | python | geldata/gel | tests/test_edgeql_triggers.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_triggers.py | Apache-2.0 |
async def test_edgeql_triggers_when_01(self):
await self.con.execute('''
alter type InsertTest {
create trigger log_new after insert, update for each
when (__new__.name not in {'a', 'f!'})
do (
insert Note { name := "new", note := __new__.name }
);
};
''')
await self.do_basic_work()
await self.assert_query_result(
'''
select Note.note
''',
tb.bag(['a!', 'b', 'b!', 'c', 'c!', 'd', 'd!', 'e', 'e!', 'f']),
) | )
await self.do_basic_work()
await self.assert_query_result( | test_edgeql_triggers_when_01 | python | geldata/gel | tests/test_edgeql_triggers.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_triggers.py | Apache-2.0 |
async def test_edgeql_triggers_when_03(self):
# Install FOR ALL triggers for everything
await self.con.execute('''
alter type InsertTest {
create trigger log_new after insert, update for all
when (count(__new__) >= 2)
do (
insert Note { name := "new", notes := __new__.name }
);
create trigger log_old after delete, update for all
when (count(__old__) >= 2)
do (
insert Note { name := "old", notes := __old__.name }
);
};
''')
await self.do_basic_work()
res = tb.bag([
{"name": "new", "notes": {"c!", "e!"}},
{"name": "new", "notes": {"e", "f"}},
{"name": "new", "notes": {"b", "a!"}},
{"name": "new", "notes": {"b!", "d", "c"}},
{"name": "old", "notes": {"f", "d!"}},
{"name": "old", "notes": {"b", "a!"}},
{"name": "old", "notes": {"c", "e"}},
{"name": "old", "notes": {"c!", "e!", "f!"}},
])
await self.assert_query_result(
'''
select Note { name, notes } order by .name
''',
res,
) | )
await self.do_basic_work()
res = tb.bag([
{"name": "new", "notes": {"c!", "e!"}},
{"name": "new", "notes": {"e", "f"}},
{"name": "new", "notes": {"b", "a!"}},
{"name": "new", "notes": {"b!", "d", "c"}},
{"name": "old", "notes": {"f", "d!"}},
{"name": "old", "notes": {"b", "a!"}},
{"name": "old", "notes": {"c", "e"}},
{"name": "old", "notes": {"c!", "e!", "f!"}},
])
await self.assert_query_result( | test_edgeql_triggers_when_03 | python | geldata/gel | tests/test_edgeql_triggers.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_triggers.py | Apache-2.0 |
async def test_edgeql_igroup_result_alias_01(self):
await self.assert_query_result(
r'''
FOR GROUP Issue
USING _ := Issue.time_estimate
BY _
IN Issue
UNION _ := (
count := count(Issue.status.id),
te := array_agg(DISTINCT Issue.time_estimate > 0),
) ORDER BY _.te;
''',
[{'count': 2, 'te': []}, {'count': 1, 'te': [True]}]
)
await self.assert_query_result(
r'''
FOR GROUP Issue
USING _ := Issue.time_estimate
BY _
IN Issue
UNION _ := (
count := count(Issue.status.id),
te := array_agg(DISTINCT Issue.time_estimate > 0),
) ORDER BY _.te DESC;
''',
[{'count': 1, 'te': [True]}, {'count': 2, 'te': []}],
) | ,
[{'count': 2, 'te': []}, {'count': 1, 'te': [True]}]
)
await self.assert_query_result(
r | test_edgeql_igroup_result_alias_01 | python | geldata/gel | tests/test_edgeql_internal_group.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_internal_group.py | Apache-2.0 |
def test_model_group_00(self):
res = bag([
{
"el": "Air",
"cards": bag([
{"name": "Djinn"},
{"name": "Giant eagle"},
{"name": "Sprite"},
]),
},
{
"el": "Earth",
"cards": bag([{"name": "Dwarf"}, {"name": "Golem"}]),
},
{"el": "Fire", "cards": bag([
{"name": "Dragon"}, {"name": "Imp"}])},
{
"el": "Water",
"cards": bag([
{"name": "Bog monster"},
{"name": "Giant turtle"},
]),
},
])
# Two implementations of the same query
self.assert_test_query(
"""
FOR g in (GROUP Card {name} BY .element)
UNION g {
el := .key.element,
cards := .elements {name}
}
""",
res,
)
self.assert_test_query(
"""
SELECT (GROUP Card {name} BY .element) {
el := .key.element,
cards := (SELECT .elements {name} ORDER BY .name)
}
""",
res,
) | FOR g in (GROUP Card {name} BY .element)
UNION g {
el := .key.element,
cards := .elements {name}
}
""",
res,
)
self.assert_test_query( | test_model_group_00 | python | geldata/gel | tests/test_eval_model_group.py | https://github.com/geldata/gel/blob/master/tests/test_eval_model_group.py | Apache-2.0 |
def test_model_group_01(self):
res = [
{
"el": "Air",
"cards": [
{"name": "Djinn"},
{"name": "Giant eagle"},
{"name": "Sprite"},
],
},
{
"el": "Earth",
"cards": [{"name": "Dwarf"}, {"name": "Golem"}],
},
{"el": "Fire", "cards": [{"name": "Dragon"}, {"name": "Imp"}]},
{
"el": "Water",
"cards": [
{"name": "Bog monster"},
{"name": "Giant turtle"},
],
},
]
# Two implementations of the same query
self.assert_test_query(
"""
SELECT (
FOR g in (GROUP Card {name} BY .element)
UNION g {
el := .key.element,
cards := (SELECT .elements {name} ORDER BY .name)
}) ORDER BY .el
""",
res,
)
self.assert_test_query(
"""
SELECT (GROUP Card {name} BY .element) {
el := .key.element,
cards := (SELECT .elements {name} ORDER BY .name)
} ORDER BY .el
""",
res,
) | SELECT (
FOR g in (GROUP Card {name} BY .element)
UNION g {
el := .key.element,
cards := (SELECT .elements {name} ORDER BY .name)
}) ORDER BY .el
""",
res,
)
self.assert_test_query( | test_model_group_01 | python | geldata/gel | tests/test_eval_model_group.py | https://github.com/geldata/gel/blob/master/tests/test_eval_model_group.py | Apache-2.0 |
def test_model_group_02(self):
res = [
{"el": "Air", "avg_cost": 2.3333333333333335},
{"el": "Earth", "avg_cost": 2.0},
{"el": "Fire", "avg_cost": 3.0},
{"el": "Water", "avg_cost": 2.5},
]
# Two implementations of the same query
self.assert_test_query(
"""
SELECT (
FOR g in (GROUP Card {name} BY .element) UNION g {
el := .key.element,
avg_cost := sum(.elements.cost) / count(.elements)
}
) ORDER BY .el
""",
res,
)
self.assert_test_query(
"""
SELECT (GROUP Card {name} BY .element) {
el := .key.element,
avg_cost := sum(.elements.cost) / count(.elements)
} ORDER BY .el
""",
res,
) | SELECT (
FOR g in (GROUP Card {name} BY .element) UNION g {
el := .key.element,
avg_cost := sum(.elements.cost) / count(.elements)
}
) ORDER BY .el
""",
res,
)
self.assert_test_query( | test_model_group_02 | python | geldata/gel | tests/test_eval_model_group.py | https://github.com/geldata/gel/blob/master/tests/test_eval_model_group.py | Apache-2.0 |
async def test_edgeql_update_simple_01(self):
await self.assert_query_result(
r"""
UPDATE UpdateTest
# bad name doesn't exist, so no update is expected
FILTER .name = 'bad name'
SET {
status := (SELECT Status FILTER Status.name = 'Closed')
};
""",
[]
)
await self.assert_query_result(
r"""
SELECT UpdateTest {
id,
name,
comment,
status: {
name
}
} ORDER BY .name;
""",
self.original,
) | ,
[]
)
await self.assert_query_result(
r | test_edgeql_update_simple_01 | python | geldata/gel | tests/test_edgeql_update.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_update.py | Apache-2.0 |
async def test_edgeql_update_simple_02(self):
orig1, orig2, orig3 = self.original
await self.assert_query_result(
r"""
UPDATE UpdateTest
FILTER UpdateTest.name = 'update-test1'
SET {
name := 'update-test1-updated',
status := (SELECT Status FILTER Status.name = 'Closed')
};
""",
[{}]
)
await self.assert_query_result(
r"""
SELECT UpdateTest {
id,
name,
comment,
status: {
name
}
} ORDER BY .name;
""",
[
{
'id': orig1['id'],
'name': 'update-test1-updated',
'status': {
'name': 'Closed'
}
},
orig2,
orig3,
]
) | ,
[{}]
)
await self.assert_query_result(
r | test_edgeql_update_simple_02 | python | geldata/gel | tests/test_edgeql_update.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_update.py | Apache-2.0 |
async def test_edgeql_update_simple_03(self):
orig1, orig2, orig3 = self.original
await self.assert_query_result(
r"""
UPDATE UpdateTest
FILTER UpdateTest.name = 'update-test2'
SET {
comment := 'updated ' ++ UpdateTest.comment
};
""",
[{}],
)
await self.assert_query_result(
r"""
SELECT UpdateTest {
id,
name,
comment,
} ORDER BY .name;
""",
[
{
'id': orig1['id'],
'name': orig1['name'],
'comment': orig1['comment'],
}, {
'id': orig2['id'],
'name': 'update-test2',
'comment': 'updated second',
}, {
'id': orig3['id'],
'name': orig3['name'],
'comment': orig3['comment'],
},
]
) | ,
[{}],
)
await self.assert_query_result(
r | test_edgeql_update_simple_03 | python | geldata/gel | tests/test_edgeql_update.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_update.py | Apache-2.0 |
async def test_edgeql_update_simple_04(self):
orig1, orig2, orig3 = self.original
await self.assert_query_result(
r"""
UPDATE UpdateTest
SET {
comment := UpdateTest.comment ++ "!",
status := (SELECT Status FILTER Status.name = 'Closed')
};
""",
[{}, {}, {}],
)
await self.assert_query_result(
r"""
SELECT UpdateTest {
id,
name,
comment,
status: {
name
}
} ORDER BY .name;
""",
[
{
'id': orig1['id'],
'name': 'update-test1',
'comment': None,
'status': {
'name': 'Closed'
}
}, {
'id': orig2['id'],
'name': 'update-test2',
'comment': 'second!',
'status': {
'name': 'Closed'
}
}, {
'id': orig3['id'],
'name': 'update-test3',
'comment': 'third!',
'status': {
'name': 'Closed'
}
},
]
) | ,
[{}, {}, {}],
)
await self.assert_query_result(
r | test_edgeql_update_simple_04 | python | geldata/gel | tests/test_edgeql_update.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_update.py | Apache-2.0 |
async def test_edgeql_update_returning_05(self):
# test that plain INSERT and UPDATE return objects they have
# manipulated
try:
data = []
data.append(await self.con.query_single(r"""
INSERT UpdateTest {
name := 'ret5.1'
};
"""))
data.append(await self.con.query_single(r"""
INSERT UpdateTest {
name := 'ret5.2'
};
"""))
data = [str(o.id) for o in data]
await self.assert_query_result(
r"""
SELECT UpdateTest {
id,
name
}
FILTER .name LIKE '%ret5._'
ORDER BY .name;
""",
[
{
'id': data[0],
'name': 'ret5.1',
},
{
'id': data[1],
'name': 'ret5.2',
}
],
)
await self.assert_query_result(
r"""
UPDATE UpdateTest
FILTER UpdateTest.name LIKE '%ret5._'
SET {
name := 'new ' ++ UpdateTest.name
};
""",
[{'id': data_id} for data_id in sorted(data)],
sort=lambda x: x['id']
)
await self.assert_query_result(
r"""
SELECT UpdateTest {
id,
name
}
FILTER .name LIKE '%ret5._'
ORDER BY .name;
""",
[
{
'id': data[0],
'name': 'new ret5.1',
},
{
'id': data[1],
'name': 'new ret5.2',
}
],
)
objs = await self.con._fetchall(
r"""
UPDATE UpdateTest
FILTER UpdateTest.name LIKE '%ret5._'
SET {
name := 'new ' ++ UpdateTest.name
};
""",
__typenames__=True,
__typeids__=True
)
self.assertTrue(hasattr(objs[0], '__tid__'))
self.assertEqual(objs[0].__tname__, 'default::UpdateTest')
finally:
await self.con.execute(r"""
DELETE (
SELECT UpdateTest
FILTER .name LIKE '%ret5._'
);
""") | ))
data.append(await self.con.query_single(r | test_edgeql_update_returning_05 | python | geldata/gel | tests/test_edgeql_update.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_update.py | Apache-2.0 |
async def test_edgeql_update_generic_01(self):
status = await self.con.query_single(r"""
SELECT Status{id}
FILTER Status.name = 'Open'
LIMIT 1;
""")
status = str(status.id)
updated = await self.con.query(
r"""
UPDATE UpdateTest
FILTER UpdateTest.name = 'update-test3'
SET {
status := (
SELECT Status
FILTER Status.id = <uuid>$status
)
};
""",
status=status
)
self.assertGreater(len(updated), 0)
await self.assert_query_result(
r"""
SELECT UpdateTest {
name,
status: {
name
}
} FILTER UpdateTest.name = 'update-test3';
""",
[
{
'name': 'update-test3',
'status': {
'name': 'Open',
},
},
]
) | )
status = str(status.id)
updated = await self.con.query(
r | test_edgeql_update_generic_01 | python | geldata/gel | tests/test_edgeql_update.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_update.py | Apache-2.0 |
async def test_edgeql_update_props_09(self):
# Check that we can update a link property on a specific link.
# Setup some multi links
await self.con.execute(
r"""
UPDATE UpdateTest
FILTER UpdateTest.name = 'update-test1'
SET {
weighted_tags := (SELECT Tag FILTER .name != 'boring')
};
""",
)
# Update the @weight for Tag 'wow'
await self.con.execute(
r"""
UPDATE UpdateTest
FILTER UpdateTest.name = 'update-test1'
SET {
weighted_tags += (
SELECT .weighted_tags {@weight := 1}
FILTER .name = 'wow'
)
};
""",
)
# Update the @weight for Tag 'boring', which should do nothing
# because that Tag is not actually linked.
await self.con.execute(
r"""
UPDATE UpdateTest
FILTER UpdateTest.name = 'update-test1'
SET {
weighted_tags += (
SELECT .weighted_tags {@weight := 2}
FILTER .name = 'boring'
)
};
""",
)
await self.assert_query_result(
r"""
SELECT UpdateTest {
name,
weighted_tags: {
name,
@weight
} ORDER BY .name
} FILTER UpdateTest.name = 'update-test1';
""",
[
{
'name': 'update-test1',
'weighted_tags': [{
'name': 'fun',
'@weight': None,
}, {
'name': 'wow',
'@weight': 1,
}],
},
]
) | ,
)
# Update the @weight for Tag 'wow'
await self.con.execute(
r | test_edgeql_update_props_09 | python | geldata/gel | tests/test_edgeql_update.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_update.py | Apache-2.0 |
async def test_edgeql_update_props_10(self):
# Check that we can update a link property on a specific link.
# Setup some multi links on several objects
await self.con.execute(
r"""
UPDATE UpdateTest
FILTER UpdateTest.name = 'update-test1'
SET {
weighted_tags := (
SELECT Tag {@weight := 2}
FILTER .name != 'boring'
)
};
UPDATE UpdateTest
FILTER UpdateTest.name = 'update-test2'
SET {
weighted_tags := (
SELECT Tag {@weight := len(.name)}
FILTER .name != 'wow'
)
};
UPDATE UpdateTest
FILTER UpdateTest.name = 'update-test3'
SET {
weighted_tags := (
SELECT Tag {
@weight := 10,
@note := 'original'
}
FILTER .name = 'fun'
)
};
""",
)
await self.assert_query_result(
r"""
SELECT UpdateTest {
name,
weighted_tags: {
name,
@weight,
@note,
} ORDER BY .name
} ORDER BY .name;
""",
[
{
'name': 'update-test1',
'weighted_tags': [{
'name': 'fun',
'@weight': 2,
'@note': None,
}, {
'name': 'wow',
'@weight': 2,
'@note': None,
}],
},
{
'name': 'update-test2',
'weighted_tags': [{
'name': 'boring',
'@weight': 6,
'@note': None,
}, {
'name': 'fun',
'@weight': 3,
'@note': None,
}],
},
{
'name': 'update-test3',
'weighted_tags': [{
'name': 'fun',
'@weight': 10,
'@note': 'original',
}],
},
]
)
# Update the @weight, @note for some tags on all of the
# UpdateTest objects.
await self.con.execute(
r"""
UPDATE UpdateTest
SET {
weighted_tags += (
FOR x IN {
(
name := 'fun',
weight_adj := -1,
empty_note := 'new fun'
),
(
name := 'wow',
weight_adj := 5,
empty_note := 'new wow'
),
(
name := 'boring',
weight_adj := -2,
empty_note := 'new boring'
),
} UNION (
SELECT .weighted_tags {
@weight := @weight + x.weight_adj,
@note := @note ?? x.empty_note,
}
FILTER .name = x.name
)
)
};
""",
)
await self.assert_query_result(
r"""
SELECT UpdateTest {
name,
weighted_tags: {
name,
@weight,
@note,
} ORDER BY .name
} ORDER BY .name;
""",
[
{
'name': 'update-test1',
'weighted_tags': [{
'name': 'fun',
'@weight': 1,
'@note': 'new fun',
}, {
'name': 'wow',
'@weight': 7,
'@note': 'new wow',
}],
},
{
'name': 'update-test2',
'weighted_tags': [{
'name': 'boring',
'@weight': 4,
'@note': 'new boring',
}, {
'name': 'fun',
'@weight': 2,
'@note': 'new fun',
}],
},
{
'name': 'update-test3',
'weighted_tags': [{
'name': 'fun',
'@weight': 9,
'@note': 'original',
}],
},
]
) | ,
)
await self.assert_query_result(
r | test_edgeql_update_props_10 | python | geldata/gel | tests/test_edgeql_update.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_update.py | Apache-2.0 |
async def test_edgeql_update_for_01(self):
await self.assert_query_result(
r"""
FOR x IN {
(name := 'update-test1', comment := 'foo'),
(name := 'update-test2', comment := 'bar')
}
UNION (
UPDATE UpdateTest
FILTER UpdateTest.name = x.name
SET {
comment := x.comment
}
);
""",
[{}, {}], # since updates are in FOR they return objects
)
await self.assert_query_result(
r"""
SELECT UpdateTest {
name,
comment
} ORDER BY UpdateTest.name;
""",
[
{
'name': 'update-test1',
'comment': 'foo'
},
{
'name': 'update-test2',
'comment': 'bar'
},
{
'name': 'update-test3',
'comment': 'third'
},
]
) | ,
[{}, {}], # since updates are in FOR they return objects
)
await self.assert_query_result(
r | test_edgeql_update_for_01 | python | geldata/gel | tests/test_edgeql_update.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_update.py | Apache-2.0 |
async def test_edgeql_update_covariant_01(self):
await self.con.execute("""
INSERT UpdateTestSubSubType {
name := 'update-covariant',
};
""")
# Covariant updates should work if the types actually work at
# runtime
await self.con.execute("""
UPDATE UpdateTestSubType
FILTER .name = "update-covariant"
SET {
status := (SELECT Status FILTER .name = "Broke a Type System")
}
""")
# But fail if they don't
async with self.assertRaisesRegexTx(
edgedb.InvalidLinkTargetError,
r"invalid target for link 'status' of object type "
r"'default::UpdateTestSubSubType': 'default::Status' "
r"\(expecting 'default::MajorLifeEvent'\)"):
await self.con.execute("""
UPDATE UpdateTestSubType
FILTER .name = "update-covariant"
SET {
status := (SELECT Status FILTER .name = "Open")
}
""")
async with self.assertRaisesRegexTx(
edgedb.InvalidLinkTargetError,
r"invalid target for link 'status' of object type "
r"'default::UpdateTestSubSubType': 'default::Status' "
r"\(expecting 'default::MajorLifeEvent'\)"):
await self.con.execute("""
UPDATE UpdateTestSubType
FILTER .name = "update-covariant"
SET {
status := (INSERT Status { name := "Yolo" })
}
""") | )
# Covariant updates should work if the types actually work at
# runtime
await self.con.execute( | test_edgeql_update_covariant_01 | python | geldata/gel | tests/test_edgeql_update.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_update.py | Apache-2.0 |
async def test_edgeql_update_covariant_03(self):
await self.con.execute("""
INSERT UpdateTestSubSubType {
name := 'update-covariant',
};
""")
# Tests with a multi link, actually using multiple things
# Covariant updates should work if the types actually work at
# runtime
await self.con.execute("""
UPDATE UpdateTestSubType
FILTER .name = "update-covariant"
SET {
statuses := (SELECT Status FILTER .name IN {
"Broke a Type System",
"Downloaded a Car",
})
}
""")
async with self.assertRaisesRegexTx(
edgedb.InvalidLinkTargetError,
r"invalid target for link 'statuses' of object type "
r"'default::UpdateTestSubSubType': 'default::Status' "
r"\(expecting 'default::MajorLifeEvent'\)"):
await self.con.execute("""
UPDATE UpdateTestSubType
FILTER .name = "update-covariant"
SET {
statuses := (SELECT Status FILTER .name IN {
"Broke a Type System",
"Downloaded a Car",
"Open",
})
}
""")
async with self.assertRaisesRegexTx(
edgedb.InvalidLinkTargetError,
r"invalid target for link 'statuses' of object type "
r"'default::UpdateTestSubSubType': 'default::Status' "
r"\(expecting 'default::MajorLifeEvent'\)"):
await self.con.execute("""
UPDATE UpdateTestSubType
FILTER .name = "update-covariant"
SET {
statuses := (FOR x in {"Foo", "Bar"} UNION (
INSERT Status {name := x}))
}
""") | )
# Tests with a multi link, actually using multiple things
# Covariant updates should work if the types actually work at
# runtime
await self.con.execute( | test_edgeql_update_covariant_03 | python | geldata/gel | tests/test_edgeql_update.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_update.py | Apache-2.0 |
async def test_edgeql_update_inject_intersection_01(self):
await self.con.execute(r"""
CREATE ABSTRACT TYPE default::I;
CREATE TYPE default::S EXTENDING default::I {
CREATE REQUIRED PROPERTY Depth -> std::float64;
};
CREATE TYPE default::P {
CREATE REQUIRED MULTI LINK Items -> default::I;
CREATE PROPERTY name -> std::str;
};
""")
await self.con._fetchall(
r"""
with
obj1 := (select P FILTER .name = 'foo'),
obj3 := (select obj1.Items limit 1)[is S]
UPDATE obj3
SET {
Depth := 11.3781298010066
};
""",
__typenames__=True
)
await self.con._fetchall(
r"""
with
obj1 := (select P FILTER .name = 'foo'),
obj3 := (select obj1.Items limit 1)[is S]
DELETE obj3
""",
__typenames__=True
) | )
await self.con._fetchall(
r | test_edgeql_update_inject_intersection_01 | python | geldata/gel | tests/test_edgeql_update.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_update.py | Apache-2.0 |
async def test_edgeql_update_dunder_default_01(self):
await self.con.execute(r"""
INSERT DunderDefaultTest01 { a := 1, b := 2, c := 3 };
""")
async with self.assertRaisesRegexTx(
edgedb.InvalidReferenceError,
r"__default__ cannot be used in this expression",
_hint='No default expression exists',
):
await self.con.execute(r'''
UPDATE DunderDefaultTest01 set { a := __default__ };
''')
async with self.assertRaisesRegexTx(
edgedb.InvalidReferenceError,
r"__default__ cannot be used in this expression",
_hint='Default expression uses __source__',
):
await self.con.execute(r'''
UPDATE DunderDefaultTest01 set { b := __default__ };
''')
await self.con.execute(r"""
UPDATE DunderDefaultTest01 set { c := __default__ };
""")
await self.assert_query_result(
r'''
SELECT DunderDefaultTest01 { a, b, c };
''',
[
{'a': 1, 'b': 2, 'c': 1},
]
) | )
async with self.assertRaisesRegexTx(
edgedb.InvalidReferenceError,
r"__default__ cannot be used in this expression",
_hint='No default expression exists',
):
await self.con.execute(r | test_edgeql_update_dunder_default_01 | python | geldata/gel | tests/test_edgeql_update.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_update.py | Apache-2.0 |
async def test_edgeql_group_grouping_sets_01(self):
res = [
{"grouping": [], "num": 9},
{"grouping": ["element"], "num": int},
{"grouping": ["element"], "num": int},
{"grouping": ["element"], "num": int},
{"grouping": ["element"], "num": int},
{"grouping": ["element", "nowners"], "num": int},
{"grouping": ["element", "nowners"], "num": int},
{"grouping": ["element", "nowners"], "num": int},
{"grouping": ["element", "nowners"], "num": int},
{"grouping": ["element", "nowners"], "num": int},
{"grouping": ["element", "nowners"], "num": int},
{"grouping": ["nowners"], "num": int},
{"grouping": ["nowners"], "num": int},
{"grouping": ["nowners"], "num": int},
{"grouping": ["nowners"], "num": int},
]
await self.assert_query_result(
r'''
WITH MODULE cards
SELECT (
GROUP Card
USING nowners := count(.owners)
BY CUBE (.element, nowners)
) {
num := count(.elements),
grouping
} ORDER BY array_agg((SELECT _ := .grouping ORDER BY _))
''',
res
)
# With an extra SELECT
await self.assert_query_result(
r'''
WITH MODULE cards
SELECT (SELECT (
GROUP Card
USING nowners := count(.owners)
BY CUBE (.element, nowners)
) {
num := count(.elements),
grouping
}) ORDER BY array_agg((SELECT _ := .grouping ORDER BY _))
''',
res
)
await self.assert_query_result(
r'''
WITH MODULE cards
SELECT (
GROUP Card
USING x := count(.owners), nowners := x,
BY CUBE (.element, nowners)
) {
num := count(.elements),
grouping
} ORDER BY array_agg((SELECT _ := .grouping ORDER BY _))
''',
res
) | ,
res
)
# With an extra SELECT
await self.assert_query_result(
r | test_edgeql_group_grouping_sets_01 | python | geldata/gel | tests/test_edgeql_group.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_group.py | Apache-2.0 |
async def test_edgeql_group_duplicate_rejected_02(self):
async with self.assertRaisesRegexTx(
edgedb.QueryError,
"BY clause cannot refer to link property and object property with "
"the same name",
):
await self.con.execute('''
WITH MODULE cards
SELECT Card {
invalid := (
GROUP .avatar
BY @text, .text
)
}
''')
async with self.assertRaisesRegexTx(
edgedb.QueryError,
"BY clause cannot refer to link property and object property with "
"the same name",
):
await self.con.execute('''
WITH MODULE cards
SELECT Card {
invalid := (
GROUP .avatar
BY .text, @text
)
}
''') | )
async with self.assertRaisesRegexTx(
edgedb.QueryError,
"BY clause cannot refer to link property and object property with "
"the same name",
):
await self.con.execute( | test_edgeql_group_duplicate_rejected_02 | python | geldata/gel | tests/test_edgeql_group.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_group.py | Apache-2.0 |
async def test_edgeql_group_by_group_by_02(self):
res = tb.bag([
{
"elements": tb.bag([
{"key": {"cost": 1, "element": None}, "n": 3},
{"key": {"cost": 2, "element": None}, "n": 2},
{"key": {"cost": 3, "element": None}, "n": 2},
{"key": {"cost": 4, "element": None}, "n": 1},
{"key": {"cost": 5, "element": None}, "n": 1},
]),
"key": {"grouping": ["cost"]}
},
{
"elements": tb.bag([
{"key": {"cost": None, "element": "Water"}, "n": 2},
{"key": {"cost": None, "element": "Earth"}, "n": 2},
{"key": {"cost": None, "element": "Fire"}, "n": 2},
{"key": {"cost": None, "element": "Air"}, "n": 3},
]),
"key": {"grouping": ["element"]}
}
])
await self.assert_query_result(
'''
WITH MODULE cards, G := (
GROUP (
GROUP Card
BY {.element, .cost}
)
USING grouping := array_agg(.grouping)
BY grouping),
SELECT G {
key: {grouping},
elements: { n := count(.elements), key: {element, cost}}
}
''',
res,
)
await self.assert_query_result(
'''
WITH MODULE cards,
SELECT (
GROUP (
GROUP Card
BY {.element, .cost}
)
USING grouping := array_agg(.grouping)
BY grouping) {
key: {grouping},
elements: { n := count(.elements), key: {element, cost}}
}
''',
res,
) | WITH MODULE cards, G := (
GROUP (
GROUP Card
BY {.element, .cost}
)
USING grouping := array_agg(.grouping)
BY grouping),
SELECT G {
key: {grouping},
elements: { n := count(.elements), key: {element, cost}}
}
''',
res,
)
await self.assert_query_result( | test_edgeql_group_by_group_by_02 | python | geldata/gel | tests/test_edgeql_group.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_group.py | Apache-2.0 |
async def test_edgeql_group_by_group_by_03a(self):
await self._test_edgeql_group_by_group_by_03(
'''
with module cards
select (group Card by .element) {
el := .key.element,
groups := (
with z := (group .elements using x := .cost%2 by x)
for z in z union (
even := z.key.x,
elements := array_agg(z.elements{name, cost}),
)
)
};
'''
) | with module cards
select (group Card by .element) {
el := .key.element,
groups := (
with z := (group .elements using x := .cost%2 by x)
for z in z union (
even := z.key.x,
elements := array_agg(z.elements{name, cost}),
)
)
}; | test_edgeql_group_by_group_by_03a | python | geldata/gel | tests/test_edgeql_group.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_group.py | Apache-2.0 |
async def test_edgeql_group_by_group_by_03b(self):
await self._test_edgeql_group_by_group_by_03(
'''
with module cards
select (group Card by .element) {
el := .key.element,
groups := (
with z := (group .elements using x := .cost%2 by x)
select (
even := z.key.x,
elements := array_agg(z.elements{name, cost}),
)
)
};
'''
) | with module cards
select (group Card by .element) {
el := .key.element,
groups := (
with z := (group .elements using x := .cost%2 by x)
select (
even := z.key.x,
elements := array_agg(z.elements{name, cost}),
)
)
}; | test_edgeql_group_by_group_by_03b | python | geldata/gel | tests/test_edgeql_group.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_group.py | Apache-2.0 |
async def test_edgeql_group_by_group_by_03c(self):
await self._test_edgeql_group_by_group_by_03(
'''
with module cards
select (group Card by .element) {
el := .key.element,
groups := (
for z in (group .elements using x := .cost%2 by x) union (
even := z.key.x,
elements := array_agg(z.elements{name, cost}),
)
)
};
'''
) | with module cards
select (group Card by .element) {
el := .key.element,
groups := (
for z in (group .elements using x := .cost%2 by x) union (
even := z.key.x,
elements := array_agg(z.elements{name, cost}),
)
)
}; | test_edgeql_group_by_group_by_03c | python | geldata/gel | tests/test_edgeql_group.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_group.py | Apache-2.0 |
async def test_edgeql_group_errors_id(self):
async with self.assertRaisesRegexTx(
edgedb.UnsupportedFeatureError,
r"may not name a grouping alias 'id'"
):
await self.con.execute('''
group cards::Card{name} using id := .id by id
''')
async with self.assertRaisesRegexTx(
edgedb.UnsupportedFeatureError,
r"may not group by a field named id",
_position=44,
):
await self.con.execute('''
group cards::Card{name} by .id
''') | )
async with self.assertRaisesRegexTx(
edgedb.UnsupportedFeatureError,
r"may not group by a field named id",
_position=44,
):
await self.con.execute( | test_edgeql_group_errors_id | python | geldata/gel | tests/test_edgeql_group.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_group.py | Apache-2.0 |
async def test_edgeql_group_ordering_01(self):
res = [
{
"elements": tb.bag([
{"name": "Sprite"},
{"name": "Giant eagle"},
{"name": "Djinn"}
]),
},
{
"elements": tb.bag([{"name": "Dwarf"}, {"name": "Golem"}]),
},
{
"elements": tb.bag([{"name": "Imp"}, {"name": "Dragon"}]),
},
{
"elements": tb.bag(
[{"name": "Bog monster"}, {"name": "Giant turtle"}]),
},
]
await self.assert_query_result(
'''
with GR := (group cards::Card BY .element)
select GR {
elements: {name},
}
order by .key.element;
''',
res,
)
await self.assert_query_result(
'''
with GR := (group cards::Card BY .element)
select GR {
key: {element},
elements: {name},
}
order by .key.element;
''',
res,
) | with GR := (group cards::Card BY .element)
select GR {
elements: {name},
}
order by .key.element;
''',
res,
)
await self.assert_query_result( | test_edgeql_group_ordering_01 | python | geldata/gel | tests/test_edgeql_group.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_group.py | Apache-2.0 |
async def test_edgeql_group_policies_01(self):
await self.con.execute('''
with module cards
alter type User {
create access policy ok allow select, delete, update read;
create access policy two_elements allow insert, update write
using (count((group .deck by .element)) = 2);
}
''')
async with self.assertRaisesRegexTx(
edgedb.InvalidValueError,
r"access policy violation on insert"):
await self.con.query('''
with module cards
insert User {
name := 'Sully',
deck := (select Card filter .element = 'Water')
};
''')
await self.con.query('''
with module cards
insert User {
name := 'Sully',
deck := (select Card filter .element IN {'Water', 'Air'})
};
''')
async with self.assertRaisesRegexTx(
edgedb.InvalidValueError,
r"access policy violation on update"):
await self.con.query('''
with module cards
update User filter .name = 'Sully' set {
deck += (select Card filter .element = 'Earth')
};
''')
async with self.assertRaisesRegexTx(
edgedb.InvalidValueError,
r"access policy violation on update"):
await self.con.query('''
with module cards
update User filter .name = 'Sully' set {
deck -= (select Card filter .element = 'Water')
};
''') | )
async with self.assertRaisesRegexTx(
edgedb.InvalidValueError,
r"access policy violation on insert"):
await self.con.query( | test_edgeql_group_policies_01 | python | geldata/gel | tests/test_edgeql_group.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_group.py | Apache-2.0 |
async def test_edgeql_group_policies_02(self):
await self.con.execute(
'''
create type T {
create multi property vals -> int64;
create access policy foo allow all using (
# This is pretty pointless but should always be true
sum(((
(group x := .vals using v := x by v))
{ x := count(.elements) }).x)
= count(.vals)
)
};
insert T { vals := {1,1,2,3} };
'''
)
await self.assert_query_result(
r'''select T { vals }''',
[{'vals': tb.bag([1, 1, 2, 3])}],
) | create type T {
create multi property vals -> int64;
create access policy foo allow all using (
# This is pretty pointless but should always be true
sum(((
(group x := .vals using v := x by v))
{ x := count(.elements) }).x)
= count(.vals)
)
};
insert T { vals := {1,1,2,3} }; | test_edgeql_group_policies_02 | python | geldata/gel | tests/test_edgeql_group.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_group.py | Apache-2.0 |
async def test_edgeql_group_link_property_01(self):
await self.assert_query_result(
r'''
with module cards
select User {
cards_by_count := (group .deck by @count) {
key : {count},
elements: {name},
}
}
filter .name = 'Alice';
''',
[
{
"cards_by_count": [
{
"key": {"count": 2},
"elements": [
{"name": "Imp"},
{"name": "Dragon"}
]
},
{
"key": {"count": 3},
"elements": [
{"name": "Bog monster"},
{"name": "Giant turtle"}
]
}
]
}
],
)
await self.assert_query_result(
r'''
with module cards
select User {
cards_by_count := (group .deck by (@count, @count)) {
key : {count},
elements: {name},
}
}
filter .name = 'Alice';
''',
[
{
"cards_by_count": [
{
"key": {"count": 2},
"elements": [
{"name": "Imp"},
{"name": "Dragon"}
]
},
{
"key": {"count": 3},
"elements": [
{"name": "Bog monster"},
{"name": "Giant turtle"}
]
}
]
}
],
) | ,
[
{
"cards_by_count": [
{
"key": {"count": 2},
"elements": [
{"name": "Imp"},
{"name": "Dragon"}
]
},
{
"key": {"count": 3},
"elements": [
{"name": "Bog monster"},
{"name": "Giant turtle"}
]
}
]
}
],
)
await self.assert_query_result(
r | test_edgeql_group_link_property_01 | python | geldata/gel | tests/test_edgeql_group.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_group.py | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.