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
194
| url
stringlengths 46
254
| license
stringclasses 4
values |
---|---|---|---|---|---|---|---|
async def test_sql_query_32(self):
# range functions
res = await self.squery_values(
'''
SELECT *, '_' || value::text
FROM json_each_text('{"a":"foo", "b":"bar"}') t
'''
)
self.assertEqual(res, [["a", "foo", "_foo"], ["b", "bar", "_bar"]])
res = await self.scon.fetch(
'''
SELECT * FROM
(SELECT ARRAY[1, 2, 3] a, ARRAY[4, 5, 6] b) t,
LATERAL unnest(a, b)
'''
)
self.assert_shape(res, 3, ['a', 'b', 'unnest', 'unnest'])
res = await self.scon.fetch(
'''
SELECT unnest(ARRAY[1, 2, 3]) a
'''
)
self.assert_shape(res, 3, ['a'])
res = await self.scon.fetch(
'''
SELECT unnest(ARRAY[]::int8[]) a
'''
)
self.assertEqual(len(res), 0)
res = await self.scon.fetch(
'''
SELECT *, unnested_b + 1 computed
FROM
(SELECT ARRAY[1, 2, 3] a, ARRAY[4, 5, 6] b) t,
LATERAL unnest(a, b) awesome_table(unnested_a, unnested_b)
'''
)
self.assert_shape(
res, 3, ['a', 'b', 'unnested_a', 'unnested_b', 'computed']
) | SELECT *, '_' || value::text
FROM json_each_text('{"a":"foo", "b":"bar"}') t | test_sql_query_32 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_33(self):
# system columns
res = await self.squery_values(
'''
SELECT tableoid, xmin, cmin, xmax, cmax, ctid FROM ONLY "Content"
'''
)
# these numbers change, so let's just check that there are 6 of them
self.assertEqual(len(res[0]), 6)
res = await self.squery_values(
'''
SELECT tableoid, xmin, cmin, xmax, cmax, ctid FROM "Content"
'''
)
self.assertEqual(len(res[0]), 6)
res = await self.squery_values(
'''
SELECT tableoid, xmin, cmin, xmax, cmax, ctid FROM "Movie.actors"
'''
)
self.assertEqual(len(res[0]), 6) | SELECT tableoid, xmin, cmin, xmax, cmax, ctid FROM ONLY "Content" | test_sql_query_33 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_33a(self):
# system columns when access policies are applied
await self.scon.execute('SET LOCAL apply_access_policies_pg TO true')
await self.scon.execute(
"""SET LOCAL "global default::filter_title" TO 'Halo 3'"""
)
res = await self.squery_values(
'''
SELECT tableoid, xmin, cmin, xmax, cmax, ctid FROM ONLY "Content"
'''
)
# these numbers change, so let's just check that there are 6 of them
self.assertEqual(len(res[0]), 6)
res = await self.squery_values(
'''
SELECT tableoid, xmin, cmin, xmax, cmax, ctid FROM "Content"
'''
)
self.assertEqual(len(res[0]), 6)
res = await self.squery_values(
'''
SELECT tableoid, xmin, cmin, xmax, cmax, ctid FROM "Movie.actors"
'''
)
self.assertEqual(len(res[0]), 6) | SET LOCAL "global default::filter_title" TO 'Halo 3 | test_sql_query_33a | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_34(self):
# GROUP and ORDER BY aliased column
res = await self.squery_values(
"""
SELECT substr(title, 2, 4) AS itl, count(*) FROM "Movie"
GROUP BY itl
ORDER BY itl
"""
)
self.assertEqual(res, [["avin", 1], ["orre", 1]]) | SELECT substr(title, 2, 4) AS itl, count(*) FROM "Movie"
GROUP BY itl
ORDER BY itl | test_sql_query_34 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_35(self):
# ORDER BY original column
res = await self.squery_values(
"""
SELECT title AS aliased_title, count(*) FROM "Movie"
GROUP BY title
ORDER BY title
"""
)
self.assertEqual(res, [['Forrest Gump', 1], ['Saving Private Ryan', 1]]) | SELECT title AS aliased_title, count(*) FROM "Movie"
GROUP BY title
ORDER BY title | test_sql_query_35 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_36(self):
# ColumnRef to relation
res = await self.squery_values(
"""
select rel from (select 1 as a, 2 as b) rel
"""
)
self.assertEqual(res, [[(1, 2)]]) | select rel from (select 1 as a, 2 as b) rel | test_sql_query_36 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_37(self):
res = await self.squery_values(
"""
SELECT (pg_column_size(ROW()))::text
"""
)
self.assertEqual(res, [['24']]) | SELECT (pg_column_size(ROW()))::text | test_sql_query_37 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_38(self):
res = await self.squery_values(
'''
WITH users AS (
SELECT 1 as id, NULL as managed_by
UNION ALL
SELECT 2 as id, 1 as managed_by
)
SELECT id, (
SELECT id FROM users e WHERE id = users.managed_by
) as managed_by
FROM users
ORDER BY id
'''
)
self.assertEqual(
res,
[
[1, None],
[2, 1],
],
) | WITH users AS (
SELECT 1 as id, NULL as managed_by
UNION ALL
SELECT 2 as id, 1 as managed_by
)
SELECT id, (
SELECT id FROM users e WHERE id = users.managed_by
) as managed_by
FROM users
ORDER BY id | test_sql_query_38 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_39(self):
res = await self.squery_values(
'''
SELECT pages, __type__ FROM "Book" ORDER BY pages;
'''
)
self.assert_data_shape(
res,
[
[206, str],
[374, str],
],
)
# there should be one `Book` and one `novel`
self.assertNotEqual(res[0][1], res[1][1])
res2 = await self.squery_values(
'''
SELECT pages, __type__ FROM ONLY "Book" ORDER BY pages;
'''
)
self.assert_data_shape(
res2,
[
[206, str],
],
)
self.assertEqual(res[0][1], res2[0][1]) | SELECT pages, __type__ FROM "Book" ORDER BY pages; | test_sql_query_39 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_43(self):
# USING factoring
res = await self.squery_values(
'''
WITH
a(id) AS (SELECT 1 UNION SELECT 2),
b(id) AS (SELECT 1 UNION SELECT 3)
SELECT a.id, b.id, id
FROM a LEFT JOIN b USING (id);
'''
)
self.assertEqual(res, [[1, 1, 1], [2, None, 2]])
res = await self.squery_values(
'''
WITH
a(id, sub_id) AS (SELECT 1, 'a' UNION SELECT 2, 'b'),
b(id, sub_id) AS (SELECT 1, 'a' UNION SELECT 3, 'c')
SELECT a.id, a.sub_id, b.id, b.sub_id, id, sub_id
FROM a JOIN b USING (id, sub_id);
'''
)
self.assertEqual(res, [[1, 'a', 1, 'a', 1, 'a']])
res = await self.squery_values(
'''
WITH
a(id) AS (SELECT 1 UNION SELECT 2),
b(id) AS (SELECT 1 UNION SELECT 3)
SELECT a.id, b.id, id
FROM a INNER JOIN b USING (id);
'''
)
self.assertEqual(res, [[1, 1, 1]])
res = await self.squery_values(
'''
WITH
a(id) AS (SELECT 1 UNION SELECT 2),
b(id) AS (SELECT 1 UNION SELECT 3)
SELECT a.id, b.id, id
FROM a RIGHT JOIN b USING (id);
'''
)
self.assertEqual(res, [[1, 1, 1], [None, 3, 3]])
res = await self.squery_values(
'''
WITH
a(id) AS (SELECT 1 UNION SELECT 2),
b(id) AS (SELECT 1 UNION SELECT 3)
SELECT a.id, b.id, id
FROM a RIGHT OUTER JOIN b USING (id);
'''
)
self.assertEqual(res, [[1, 1, 1], [None, 3, 3]])
res = await self.squery_values(
'''
WITH
a(id) AS (SELECT 1 UNION SELECT 2),
b(id) AS (SELECT 1 UNION SELECT 3)
SELECT a.id, b.id, id
FROM a FULL JOIN b USING (id);
'''
)
self.assertEqual(res, [[1, 1, 1], [2, None, 2], [None, 3, 3]]) | WITH
a(id) AS (SELECT 1 UNION SELECT 2),
b(id) AS (SELECT 1 UNION SELECT 3)
SELECT a.id, b.id, id
FROM a LEFT JOIN b USING (id); | test_sql_query_43 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_46(self):
res = await self.scon.fetch(
'''
WITH
x(a) AS (VALUES (1)),
y(a) AS (VALUES (2)),
z(a) AS (VALUES (3))
SELECT * FROM x, y JOIN z u on TRUE
'''
)
# `a` would be duplicated,
# so second and third instance are prefixed with rel var name
self.assert_shape(res, 1, ['a', 'y_a', 'u_a']) | WITH
x(a) AS (VALUES (1)),
y(a) AS (VALUES (2)),
z(a) AS (VALUES (3))
SELECT * FROM x, y JOIN z u on TRUE | test_sql_query_46 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_47(self):
res = await self.scon.fetch(
'''
WITH
x(a) AS (VALUES (1)),
y(a) AS (VALUES (2), (3))
SELECT x.*, u.* FROM x, y as u
'''
)
self.assert_shape(res, 2, ['a', 'u_a']) | WITH
x(a) AS (VALUES (1)),
y(a) AS (VALUES (2), (3))
SELECT x.*, u.* FROM x, y as u | test_sql_query_47 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_48(self):
res = await self.scon.fetch(
'''
WITH
x(a) AS (VALUES (1)),
y(a) AS (VALUES (2), (3))
SELECT * FROM x, y, y
'''
)
# duplicate rel var names can yield duplicate column names
self.assert_shape(res, 4, ['a', 'y_a', 'y_a']) | WITH
x(a) AS (VALUES (1)),
y(a) AS (VALUES (2), (3))
SELECT * FROM x, y, y | test_sql_query_48 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_49(self):
res = await self.scon.fetch(
'''
WITH
x(a) AS (VALUES (2))
SELECT 1 as x_a, * FROM x, x
'''
)
# duplicate rel var names can yield duplicate column names
self.assert_shape(res, 1, ['x_a', 'a', 'x_a']) | WITH
x(a) AS (VALUES (2))
SELECT 1 as x_a, * FROM x, x | test_sql_query_49 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_50(self):
res = await self.scon.fetch(
'''
WITH
x(a) AS (VALUES (2))
SELECT 1 as a, * FROM x
'''
)
# duplicate rel var names can yield duplicate column names
self.assert_shape(res, 1, ['a', 'x_a']) | WITH
x(a) AS (VALUES (2))
SELECT 1 as a, * FROM x | test_sql_query_50 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_51(self):
res = await self.scon.fetch(
'''
TABLE "Movie"
'''
)
self.assert_shape(res, 2, 6) | TABLE "Movie" | test_sql_query_51 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_53(self):
await self.scon.execute(
'''
SELECT 'hello' as t;
SELECT 42 as i;
'''
)
# query params will make asyncpg use the extended protocol,
# where you can issue only one statement.
with self.assertRaisesRegex(
asyncpg.PostgresSyntaxError,
'cannot insert multiple commands into a prepared statement',
):
await self.scon.execute(
'''
SELECT $1::text as t;
SELECT $2::int as i;
''',
'hello',
42,
) | SELECT 'hello' as t;
SELECT 42 as i; | test_sql_query_53 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_56(self):
# recursive
res = await self.squery_values(
'''
WITH RECURSIVE
integers(n) AS (
SELECT 0
UNION ALL
SELECT n + 1 FROM integers
WHERE n + 1 < 5
)
SELECT n FROM integers
''',
)
self.assertEqual(res, [
[0],
[1],
[2],
[3],
[4],
])
res = await self.squery_values(
'''
WITH RECURSIVE
fibonacci(n, prev, val) AS (
SELECT 1, 0, 1
UNION ALL
SELECT n + 1, val, prev + val
FROM fibonacci
WHERE n + 1 < 10
)
SELECT n, val FROM fibonacci;
'''
)
self.assertEqual(res, [
[1, 1],
[2, 1],
[3, 2],
[4, 3],
[5, 5],
[6, 8],
[7, 13],
[8, 21],
[9, 34],
])
res = await self.squery_values(
'''
WITH RECURSIVE
fibonacci(n, prev, val) AS (
SELECT 1, 0, 1
UNION ALL
SELECT n + 1, val, prev + val
FROM fibonacci
WHERE n + 1 < 8
),
integers(n) AS (
SELECT 0
UNION ALL
SELECT n + 1 FROM integers
WHERE n + 1 < 5
)
SELECT f.n, f.val FROM fibonacci f, integers i where f.n = i.n;
'''
)
self.assertEqual(res, [
[1, 1],
[2, 1],
[3, 2],
[4, 3],
])
res = await self.squery_values(
'''
WITH RECURSIVE
a as (SELECT 12 as n),
integers(n) AS (
SELECT 0
UNION ALL
SELECT n + 1 FROM integers
WHERE n + 1 < 5
)
SELECT * FROM a, integers;
'''
)
self.assertEqual(res, [
[12, 0],
[12, 1],
[12, 2],
[12, 3],
[12, 4],
]) | WITH RECURSIVE
integers(n) AS (
SELECT 0
UNION ALL
SELECT n + 1 FROM integers
WHERE n + 1 < 5
)
SELECT n FROM integers
''',
)
self.assertEqual(res, [
[0],
[1],
[2],
[3],
[4],
])
res = await self.squery_values( | test_sql_query_56 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_57(self):
res = await self.squery_values(
f'''
(select 1 limit 1) union (select 2 limit 1);
'''
)
self.assertEqual(
res,
[
[1],
[2],
]
)
res = await self.squery_values(
f'''
(select 1) union (select 2) LIMIT $1;
''',
1
)
self.assertEqual(
res,
[
[1],
]
) | )
self.assertEqual(
res,
[
[1],
[2],
]
)
res = await self.squery_values(
f | test_sql_query_57 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_introspection_01(self):
res = await self.squery_values(
'''
SELECT table_name, column_name, is_nullable, ordinal_position
FROM information_schema.columns
WHERE table_schema = 'public'
ORDER BY table_name, ordinal_position
'''
)
self.assertEqual(
res,
[
['Book', 'id', 'NO', 1],
['Book', '__type__', 'NO', 2],
['Book', 'genre_id', 'YES', 3],
['Book', 'pages', 'NO', 4],
['Book', 'title', 'NO', 5],
['Book.chapters', 'source', 'NO', 1],
['Book.chapters', 'target', 'NO', 2],
['Content', 'id', 'NO', 1],
['Content', '__type__', 'NO', 2],
['Content', 'genre_id', 'YES', 3],
['Content', 'title', 'NO', 4],
['ContentSummary', 'id', 'NO', 1],
['ContentSummary', '__type__', 'NO', 2],
['ContentSummary', 'x', 'NO', 3],
['Genre', 'id', 'NO', 1],
['Genre', '__type__', 'NO', 2],
['Genre', 'name', 'NO', 3],
['Movie', 'id', 'NO', 1],
['Movie', '__type__', 'NO', 2],
['Movie', 'director_id', 'YES', 3],
['Movie', 'genre_id', 'YES', 4],
['Movie', 'release_year', 'YES', 5],
['Movie', 'title', 'NO', 6],
['Movie.actors', 'source', 'NO', 1],
['Movie.actors', 'target', 'NO', 2],
['Movie.actors', 'role', 'YES', 3],
['Movie.actors', 'role_lower', 'YES', 4],
['Movie.director', 'source', 'NO', 1],
['Movie.director', 'target', 'NO', 2],
['Movie.director', 'bar', 'YES', 3],
['Person', 'id', 'NO', 1],
['Person', '__type__', 'NO', 2],
['Person', 'favorite_genre_id', 'YES', 3],
['Person', 'first_name', 'NO', 4],
['Person', 'full_name', 'NO', 5],
['Person', 'last_name', 'YES', 6],
['Person', 'username', 'NO', 7],
['novel', 'id', 'NO', 1],
['novel', '__type__', 'NO', 2],
['novel', 'foo', 'YES', 3],
['novel', 'genre_id', 'YES', 4],
['novel', 'pages', 'NO', 5],
['novel', 'title', 'NO', 6],
['novel.chapters', 'source', 'NO', 1],
['novel.chapters', 'target', 'NO', 2],
],
) | SELECT table_name, column_name, is_nullable, ordinal_position
FROM information_schema.columns
WHERE table_schema = 'public'
ORDER BY table_name, ordinal_position | test_sql_query_introspection_01 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_introspection_02(self):
tables = await self.squery_values(
'''
SELECT
tbl_name, array_agg(column_name)
FROM (
SELECT
'"' || table_schema || '"."' || table_name || '"'
AS tbl_name,
column_name
FROM information_schema.columns
ORDER BY tbl_name, ordinal_position
) t
GROUP BY tbl_name
'''
)
for [tbl_name, columns_from_information_schema] in tables:
if tbl_name.split('.')[0] in ('cfg', 'schema', 'sys', '"ext::ai"'):
continue
try:
prepared = await self.scon.prepare(f'SELECT * FROM {tbl_name}')
attributes = prepared.get_attributes()
columns_from_resolver = [a.name for a in attributes]
self.assertEqual(
columns_from_resolver,
columns_from_information_schema,
)
except Exception:
raise Exception(f'introspecting {tbl_name}') | SELECT
tbl_name, array_agg(column_name)
FROM (
SELECT
'"' || table_schema || '"."' || table_name || '"'
AS tbl_name,
column_name
FROM information_schema.columns
ORDER BY tbl_name, ordinal_position
) t
GROUP BY tbl_name | test_sql_query_introspection_02 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_introspection_03(self):
res = await self.squery_values(
'''
SELECT relname FROM pg_class c
JOIN pg_namespace n ON n.oid = c.relnamespace
WHERE n.nspname = 'pg_toast'
AND has_schema_privilege(n.oid, 'USAGE')
ORDER BY relname
'''
)
if len(res) == 0:
return
# verify that at least one of the pg_toast tables exists
had_success = False
exception = None
for [toast_table] in res:
try:
# Result will probably be empty, so we cannot validate column
# names
await self.squery_values(
f'SELECT * FROM pg_toast.{toast_table}'
)
had_success = True
except BaseException as e:
exception = e
if not had_success:
raise exception | SELECT relname FROM pg_class c
JOIN pg_namespace n ON n.oid = c.relnamespace
WHERE n.nspname = 'pg_toast'
AND has_schema_privilege(n.oid, 'USAGE')
ORDER BY relname | test_sql_query_introspection_03 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_introspection_04(self):
res = await self.squery_values(
'''
SELECT pc.relname, pa.attname, pa.attnotnull
FROM pg_attribute pa
JOIN pg_class pc ON pc.oid = pa.attrelid
JOIN pg_namespace n ON n.oid = pc.relnamespace
WHERE n.nspname = 'public' AND pc.relname = 'novel'
ORDER BY attnum
'''
)
self.assertEqual(
res,
[
['novel', 'tableoid', True],
['novel', 'cmax', True],
['novel', 'xmax', True],
['novel', 'cmin', True],
['novel', 'xmin', True],
['novel', 'ctid', True],
['novel', 'id', True],
['novel', '__type__', True],
['novel', 'foo', False],
['novel', 'genre_id', False],
['novel', 'pages', True],
['novel', 'title', True],
],
) | SELECT pc.relname, pa.attname, pa.attnotnull
FROM pg_attribute pa
JOIN pg_class pc ON pc.oid = pa.attrelid
JOIN pg_namespace n ON n.oid = pc.relnamespace
WHERE n.nspname = 'public' AND pc.relname = 'novel'
ORDER BY attnum | test_sql_query_introspection_04 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_introspection_05(self):
# test pg_constraint
res = await self.squery_values(
'''
SELECT pc.relname, pcon.contype, pa.key, pcf.relname, paf.key
FROM pg_constraint pcon
JOIN pg_class pc ON pc.oid = pcon.conrelid
LEFT JOIN pg_class pcf ON pcf.oid = pcon.confrelid
LEFT JOIN LATERAL (
SELECT string_agg(attname, ',') as key
FROM pg_attribute
WHERE attrelid = pcon.conrelid
AND attnum = ANY(pcon.conkey)
) pa ON TRUE
LEFT JOIN LATERAL (
SELECT string_agg(attname, ',') as key
FROM pg_attribute
WHERE attrelid = pcon.confrelid
AND attnum = ANY(pcon.confkey)
) paf ON TRUE
WHERE pc.relname IN (
'Book.chapters', 'Movie', 'Movie.director', 'Movie.actors'
)
ORDER BY pc.relname ASC, pcon.contype DESC, pa.key
'''
)
self.assertEqual(
res,
[
['Book.chapters', b'f', 'source', 'Book', 'id'],
['Movie', b'p', 'id', None, None],
['Movie', b'f', 'director_id', 'Person', 'id'],
['Movie', b'f', 'genre_id', 'Genre', 'id'],
['Movie.actors', b'p', 'source,target', None, None],
['Movie.actors', b'f', 'source', 'Movie', 'id'],
['Movie.actors', b'f', 'target', 'Person', 'id'],
['Movie.director', b'p', 'source,target', None, None],
['Movie.director', b'f', 'source', 'Movie', 'id'],
['Movie.director', b'f', 'target', 'Person', 'id'],
],
) | SELECT pc.relname, pcon.contype, pa.key, pcf.relname, paf.key
FROM pg_constraint pcon
JOIN pg_class pc ON pc.oid = pcon.conrelid
LEFT JOIN pg_class pcf ON pcf.oid = pcon.confrelid
LEFT JOIN LATERAL (
SELECT string_agg(attname, ',') as key
FROM pg_attribute
WHERE attrelid = pcon.conrelid
AND attnum = ANY(pcon.conkey)
) pa ON TRUE
LEFT JOIN LATERAL (
SELECT string_agg(attname, ',') as key
FROM pg_attribute
WHERE attrelid = pcon.confrelid
AND attnum = ANY(pcon.confkey)
) paf ON TRUE
WHERE pc.relname IN (
'Book.chapters', 'Movie', 'Movie.director', 'Movie.actors'
)
ORDER BY pc.relname ASC, pcon.contype DESC, pa.key | test_sql_query_introspection_05 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_schemas_01(self):
await self.scon.fetch('SELECT id FROM "inventory"."Item";')
await self.scon.fetch('SELECT id FROM "public"."Person";')
await self.scon.execute('SET search_path TO inventory, public;')
await self.scon.fetch('SELECT id FROM "Item";')
await self.scon.execute('SET search_path TO inventory, public;')
await self.scon.fetch('SELECT id FROM "Person";')
await self.scon.execute('SET search_path TO public;')
await self.scon.fetch('SELECT id FROM "Person";')
await self.scon.execute('SET search_path TO inventory;')
await self.scon.fetch('SELECT id FROM "Item";')
await self.scon.execute('SET search_path TO public;')
with self.assertRaisesRegex(
asyncpg.UndefinedTableError,
"unknown table",
position="16",
):
await self.squery_values('SELECT id FROM "Item"')
await self.scon.execute('SET search_path TO inventory;')
with self.assertRaisesRegex(
asyncpg.UndefinedTableError,
"unknown table",
position="17",
):
await self.scon.fetch('SELECT id FROM "Person";')
await self.scon.execute(
'''
SELECT set_config('search_path', '', FALSE);
'''
)
# HACK: Set search_path back to public
await self.scon.execute('SET search_path TO public;') | SELECT set_config('search_path', '', FALSE); | test_sql_query_schemas_01 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_static_eval_02(self):
await self.scon.execute(
'''
SELECT nspname as table_schema,
relname as table_name
FROM pg_class c
JOIN pg_namespace n on c.relnamespace = n.oid
WHERE has_table_privilege(c.oid, 'SELECT')
AND has_schema_privilege(current_user, nspname, 'USAGE')
AND relkind in ('r', 'm', 'v', 't', 'f', 'p')
'''
) | SELECT nspname as table_schema,
relname as table_name
FROM pg_class c
JOIN pg_namespace n on c.relnamespace = n.oid
WHERE has_table_privilege(c.oid, 'SELECT')
AND has_schema_privilege(current_user, nspname, 'USAGE')
AND relkind in ('r', 'm', 'v', 't', 'f', 'p') | test_sql_query_static_eval_02 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_static_eval_03(self):
await self.scon.execute(
'''
SELECT information_schema._pg_truetypid(a.*, t.*)
FROM pg_attribute a
JOIN pg_type t ON t.oid = a.atttypid
LIMIT 500
'''
) | SELECT information_schema._pg_truetypid(a.*, t.*)
FROM pg_attribute a
JOIN pg_type t ON t.oid = a.atttypid
LIMIT 500 | test_sql_query_static_eval_03 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_static_eval_04(self):
[[res1, res2]] = await self.squery_values(
'''
SELECT to_regclass('"Movie.actors"'),
'"public"."Movie.actors"'::regclass
'''
)
self.assertEqual(res1, res2)
res = await self.squery_values(
r'''
SELECT tbloid
FROM unnest('{11}'::pg_catalog.oid[]) as src(tbloid)
'''
)
self.assertEqual(res, [[11]]) | SELECT to_regclass('"Movie.actors"'),
'"public"."Movie.actors"'::regclass | test_sql_query_static_eval_04 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_static_eval_05(self):
# pg_get_serial_sequence always returns NULL, we don't expose sequences
res = await self.squery_values(
'''
SELECT
CAST(
CAST(
pg_catalog.pg_get_serial_sequence('a', 'b')
AS REGCLASS
)
AS OID
)
'''
)
self.assertEqual(res, [[None]]) | SELECT
CAST(
CAST(
pg_catalog.pg_get_serial_sequence('a', 'b')
AS REGCLASS
)
AS OID
) | test_sql_query_static_eval_05 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_static_eval_06(self):
# pg_relation_size requires regclass argument
res = await self.squery_values(
"""
SELECT relname, pg_relation_size(tables.oid)
FROM pg_catalog.pg_class AS tables
JOIN pg_namespace pn ON (pn.oid = tables.relnamespace)
WHERE tables.relkind = 'r' AND pn.nspname = 'public'
ORDER BY relname;
"""
)
self.assertEqual(
res,
[
["Book", 8192],
["Book.chapters", 8192],
["Content", 8192],
["ContentSummary", 8192],
["Genre", 8192],
["Movie", 8192],
["Movie.actors", 8192],
["Movie.director", 8192],
["Person", 8192],
["novel", 8192],
["novel.chapters", 0],
],
) | SELECT relname, pg_relation_size(tables.oid)
FROM pg_catalog.pg_class AS tables
JOIN pg_namespace pn ON (pn.oid = tables.relnamespace)
WHERE tables.relkind = 'r' AND pn.nspname = 'public'
ORDER BY relname; | test_sql_query_static_eval_06 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_be_state(self):
con = await self.connect(database=self.con.dbname)
try:
await con.execute(
'''
CONFIGURE SESSION SET __internal_sess_testvalue := 1;
'''
)
await self.squery_values(
"set default_transaction_isolation to 'read committed'"
)
self.assertEqual(
await con.query_single(
'''
SELECT assert_single(cfg::Config.__internal_sess_testvalue)
'''
),
1,
)
res = await self.squery_values('show default_transaction_isolation')
self.assertEqual(res, [['read committed']])
finally:
await con.aclose() | CONFIGURE SESSION SET __internal_sess_testvalue := 1; | test_sql_query_be_state | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_error_03(self):
with self.assertRaisesRegex(
asyncpg.UndefinedFunctionError,
"does not exist",
position="28",
):
await self.scon.execute(
"""SELECT 1 +
asdf()"""
) | SELECT 1 +
asdf() | test_sql_query_error_03 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_error_04(self):
with self.assertRaisesRegex(
asyncpg.UndefinedFunctionError,
"does not exist",
position="12",
):
await self.scon.execute(
'''SELECT 1 + asdf() FROM "Movie" ORDER BY id'''
) | SELECT 1 + asdf() FROM "Movie" ORDER BY id | test_sql_query_error_04 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_error_05(self):
with self.assertRaisesRegex(
asyncpg.UndefinedFunctionError,
"does not exist",
position="28",
):
await self.scon.execute(
'''SELECT 1 +
asdf() FROM "Movie" ORDER BY id'''
) | SELECT 1 +
asdf() FROM "Movie" ORDER BY id | test_sql_query_error_05 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_error_08(self):
with self.assertRaisesRegex(
asyncpg.UndefinedFunctionError,
"does not exist",
position="28",
):
await self.scon.fetch(
"""SELECT 1 +
asdf()"""
) | SELECT 1 +
asdf() | test_sql_query_error_08 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_error_09(self):
with self.assertRaisesRegex(
asyncpg.UndefinedFunctionError,
"does not exist",
position="12",
):
await self.scon.fetch(
'''SELECT 1 + asdf() FROM "Movie" ORDER BY id'''
) | SELECT 1 + asdf() FROM "Movie" ORDER BY id | test_sql_query_error_09 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_error_10(self):
with self.assertRaisesRegex(
asyncpg.UndefinedFunctionError,
"does not exist",
position="28",
):
await self.scon.fetch(
'''SELECT 1 +
asdf() FROM "Movie" ORDER BY id'''
) | SELECT 1 +
asdf() FROM "Movie" ORDER BY id | test_sql_query_error_10 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_prepare_01(self):
await self.scon.execute(
"""
PREPARE ps1(int) AS (
SELECT $1
)
""",
)
res = await self.squery_values(
"""
EXECUTE ps1(100)
""",
)
self.assertEqual(res, [[100]])
await self.scon.execute(
"""
DEALLOCATE ps1
""",
)
with self.assertRaises(
asyncpg.InvalidSQLStatementNameError,
):
await self.scon.execute(
"""
EXECUTE ps1(101)
""",
)
with self.assertRaises(
asyncpg.InvalidSQLStatementNameError,
):
await self.scon.execute(
"""
DEALLOCATE ps1
""",
)
# Prepare again to make sure DEALLOCATE worked
await self.scon.execute(
"""
PREPARE ps1(int) AS (
SELECT $1 + 4
)
""",
)
res = await self.squery_values(
"""
EXECUTE ps1(100)
""",
)
self.assertEqual(res, [[104]])
# Check that simple query works too.
res = await self.scon.execute(
"""
EXECUTE ps1(100)
""",
) | PREPARE ps1(int) AS (
SELECT $1
)
""",
)
res = await self.squery_values( | test_sql_query_prepare_01 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_computed_01(self):
# single property
res = await self.squery_values(
"""
SELECT full_name
FROM "Person" p
ORDER BY first_name
"""
)
self.assertEqual(res, [["Robin"], ["Steven Spielberg"], ["Tom Hanks"]]) | SELECT full_name
FROM "Person" p
ORDER BY first_name | test_sql_query_computed_01 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_computed_02(self):
# computeds can only be accessed on the table, not rel vars
with self.assertRaisesRegex(
asyncpg.UndefinedColumnError, "column \"full_name\" does not exist"
):
await self.squery_values(
"""
SELECT t.full_name
FROM (
SELECT first_name, last_name
FROM "Person"
) t
"""
) | SELECT t.full_name
FROM (
SELECT first_name, last_name
FROM "Person"
) t | test_sql_query_computed_02 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_computed_03(self):
# computed in a sublink
res = await self.squery_values(
"""
SELECT (SELECT 'Hello ' || full_name) as hello
FROM "Person"
ORDER BY first_name DESC
LIMIT 1
"""
)
self.assertEqual(res, [["Hello Tom Hanks"]]) | SELECT (SELECT 'Hello ' || full_name) as hello
FROM "Person"
ORDER BY first_name DESC
LIMIT 1 | test_sql_query_computed_03 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_computed_04(self):
# computed in a lateral
res = await self.squery_values(
"""
SELECT t.hello
FROM "Person",
LATERAL (SELECT ('Hello ' || full_name) as hello) t
ORDER BY first_name DESC
LIMIT 1
"""
)
self.assertEqual(res, [["Hello Tom Hanks"]]) | SELECT t.hello
FROM "Person",
LATERAL (SELECT ('Hello ' || full_name) as hello) t
ORDER BY first_name DESC
LIMIT 1 | test_sql_query_computed_04 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_computed_05(self):
# computed in ORDER BY
res = await self.squery_values(
"""
SELECT first_name
FROM "Person"
ORDER BY full_name
"""
)
self.assertEqual(res, [["Robin"], ["Steven"], ["Tom"]]) | SELECT first_name
FROM "Person"
ORDER BY full_name | test_sql_query_computed_05 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_computed_06(self):
# globals are empty
res = await self.squery_values(
"""
SELECT username FROM "Person"
ORDER BY first_name LIMIT 1
"""
)
self.assertEqual(res, [["u_robin"]]) | SELECT username FROM "Person"
ORDER BY first_name LIMIT 1 | test_sql_query_computed_06 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_computed_07(self):
# single link
res = await self.scon.fetch(
"""
SELECT favorite_genre_id FROM "Person"
"""
)
self.assert_shape(res, 3, ['favorite_genre_id'])
res = await self.squery_values(
"""
SELECT g.name
FROM "Person" p
LEFT JOIN "Genre" g ON (p.favorite_genre_id = g.id)
"""
)
self.assertEqual(res, [["Drama"], ["Drama"], ["Drama"]]) | SELECT favorite_genre_id FROM "Person" | test_sql_query_computed_07 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_computed_08(self):
# multi property
await self.scon.fetch(
"""
SELECT actor_names FROM "Movie"
"""
) | SELECT actor_names FROM "Movie" | test_sql_query_computed_08 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_computed_09(self):
# multi link
await self.scon.fetch(
"""
SELECT similar_to FROM "Movie"
"""
) | SELECT similar_to FROM "Movie" | test_sql_query_computed_09 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_computed_10(self):
# globals
await self.scon.execute(
"""
SET LOCAL "global default::username_prefix" TO user_;
"""
)
res = await self.squery_values(
"""
SELECT username FROM "Person"
ORDER BY first_name LIMIT 1
"""
)
self.assertEqual(res, [["user_robin"]]) | SET LOCAL "global default::username_prefix" TO user_; | test_sql_query_computed_10 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_computed_11(self):
# globals
await self.scon.execute(
f"""
SET LOCAL "global glob_mod::glob_str" TO hello;
SET LOCAL "global glob_mod::glob_uuid" TO
'f527c032-ad4c-461e-95e2-67c4e2b42ca7';
SET LOCAL "global glob_mod::glob_int64" TO 42;
SET LOCAL "global glob_mod::glob_int32" TO 42;
SET LOCAL "global glob_mod::glob_int16" TO 42;
SET LOCAL "global glob_mod::glob_bool" TO 1;
SET LOCAL "global glob_mod::glob_float64" TO 42.1;
SET LOCAL "global glob_mod::glob_float32" TO 42.1;
"""
)
await self.scon.execute('INSERT INTO glob_mod."G" DEFAULT VALUES')
res = await self.squery_values(
'''
SELECT
p_str,
p_uuid,
p_int64,
p_int32,
p_int16,
p_bool,
p_float64,
p_float32
FROM glob_mod."G"
'''
)
self.assertEqual(
res,
[
[
'hello',
uuid.UUID('f527c032-ad4c-461e-95e2-67c4e2b42ca7'),
42,
42,
42,
True,
42.1,
42.099998474121094,
]
],
) | )
await self.scon.execute('INSERT INTO glob_mod."G" DEFAULT VALUES')
res = await self.squery_values( | test_sql_query_computed_11 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_computed_12(self):
# globals
res = await self.squery_values(
'''
SELECT a, b FROM glob_mod."Computed"
'''
)
self.assertEqual(res, [[None, None]])
await self.scon.execute(
f"""
SET LOCAL "global glob_mod::a" TO hello;
SET LOCAL "global glob_mod::b" TO no;
"""
)
res = await self.squery_values(
'''
SELECT a, b FROM glob_mod."Computed"
'''
)
self.assertEqual(res, [["hello", False]]) | SELECT a, b FROM glob_mod."Computed" | test_sql_query_computed_12 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def query_glob_bool(value: str) -> bool:
await self.scon.execute(
f"""
SET LOCAL "global glob_mod::b" TO {value};
"""
)
res = await self.squery_values(
'''
SELECT b FROM glob_mod."Computed"
'''
)
return res[0][0] | )
res = await self.squery_values( | test_sql_query_computed_13.query_glob_bool | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_computed_13(self):
# globals bool values
async def query_glob_bool(value: str) -> bool:
await self.scon.execute(
f"""
SET LOCAL "global glob_mod::b" TO {value};
"""
)
res = await self.squery_values(
'''
SELECT b FROM glob_mod."Computed"
'''
)
return res[0][0]
self.assertEqual(await query_glob_bool('on'), True)
self.assertEqual(await query_glob_bool('off'), False)
self.assertEqual(await query_glob_bool('o'), None)
self.assertEqual(await query_glob_bool('of'), False)
self.assertEqual(await query_glob_bool('true'), True)
self.assertEqual(await query_glob_bool('tru'), True)
self.assertEqual(await query_glob_bool('tr'), True)
self.assertEqual(await query_glob_bool('t'), True)
self.assertEqual(await query_glob_bool('false'), False)
self.assertEqual(await query_glob_bool('fals'), False)
self.assertEqual(await query_glob_bool('fal'), False)
self.assertEqual(await query_glob_bool('fa'), False)
self.assertEqual(await query_glob_bool('f'), False)
self.assertEqual(await query_glob_bool('yes'), True)
self.assertEqual(await query_glob_bool('ye'), True)
self.assertEqual(await query_glob_bool('y'), True)
self.assertEqual(await query_glob_bool('no'), False)
self.assertEqual(await query_glob_bool('n'), False)
self.assertEqual(await query_glob_bool('"1"'), True)
self.assertEqual(await query_glob_bool('"0"'), False)
self.assertEqual(await query_glob_bool('1'), True)
self.assertEqual(await query_glob_bool('0'), False)
self.assertEqual(await query_glob_bool('1231231'), True)
self.assertEqual(await query_glob_bool('hello'), None)
self.assertEqual(await query_glob_bool("'ON'"), True)
self.assertEqual(await query_glob_bool("'OFF'"), False)
self.assertEqual(await query_glob_bool("'HELLO'"), None) | )
res = await self.squery_values( | test_sql_query_computed_13 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_access_policy_01(self):
# no access policies
res = await self.squery_values(
'SELECT title FROM "Content" ORDER BY title'
)
self.assertEqual(
res,
[
['Chronicles of Narnia'],
['Forrest Gump'],
['Halo 3'],
['Hunger Games'],
['Saving Private Ryan'],
],
)
await self.scon.execute('SET LOCAL apply_access_policies_pg TO true')
# access policies applied
res = await self.squery_values(
'SELECT title FROM "Content" ORDER BY title'
)
self.assertEqual(res, [])
# access policies use globals
await self.scon.execute(
"""SET LOCAL "global default::filter_title" TO 'Forrest Gump'"""
)
res = await self.squery_values(
'SELECT title FROM "Content" ORDER BY title'
)
self.assertEqual(res, [['Forrest Gump']]) | SET LOCAL "global default::filter_title" TO 'Forrest Gump | test_sql_query_access_policy_01 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_access_policy_02(self):
# access policies from computeds
# no access policies
res = await self.squery_values('SELECT x FROM "ContentSummary"')
self.assertEqual(res, [[5]])
await self.scon.execute('SET LOCAL apply_access_policies_pg TO true')
# access policies applied
res = await self.squery_values('SELECT x FROM "ContentSummary"')
self.assertEqual(res, [[0]])
# access policies use globals
await self.scon.execute(
"""SET LOCAL "global default::filter_title" TO 'Forrest Gump'"""
)
res = await self.squery_values('SELECT x FROM "ContentSummary"')
self.assertEqual(res, [[1]]) | SET LOCAL "global default::filter_title" TO 'Forrest Gump | test_sql_query_access_policy_02 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_access_policy_03(self):
# access policies for dml
# allowed without applying access policies
await self.scon.execute('SET LOCAL apply_access_policies_pg TO true')
# allowed when filter_title == 'summary'
await self.scon.execute(
"""SET LOCAL "global default::filter_title" TO 'summary'"""
)
# not allowed when filter_title is something else
await self.scon.execute(
"""SET LOCAL "global default::filter_title" TO 'something else'"""
)
with self.assertRaisesRegex(
asyncpg.exceptions.InsufficientPrivilegeError,
'access policy violation on insert of default::ContentSummary',
):
await self.scon.execute(
'INSERT INTO "ContentSummary" DEFAULT VALUES'
) | SET LOCAL "global default::filter_title" TO 'summary | test_sql_query_access_policy_03 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_access_policy_04(self):
# access policies without inheritance
# there is only one object that is of exactly type Content
res = await self.squery_values('SELECT * FROM ONLY "Content"')
self.assertEqual(len(res), 1)
await self.scon.execute('SET LOCAL apply_access_policies_pg TO true')
await self.scon.execute(
"""SET LOCAL "global default::filter_title" TO 'Halo 3'"""
)
res = await self.squery_values('SELECT * FROM ONLY "Content"')
self.assertEqual(len(res), 1)
await self.scon.execute(
"""SET LOCAL "global default::filter_title" TO 'Forrest Gump'"""
)
res = await self.squery_values('SELECT * FROM ONLY "Content"')
self.assertEqual(len(res), 0) | SET LOCAL "global default::filter_title" TO 'Halo 3 | test_sql_query_access_policy_04 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_subquery_splat_01(self):
res = await self.squery_values(
'''
with "average_pages" as (select avg("pages") as "value" from "Book")
select pages from "Book"
where "Book".pages < (select * from "average_pages")
'''
)
self.assertEqual(
res,
[[206]],
) | with "average_pages" as (select avg("pages") as "value" from "Book")
select pages from "Book"
where "Book".pages < (select * from "average_pages") | test_sql_query_subquery_splat_01 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_having_01(self):
res = await self.squery_values(
'''
select 1 having false
'''
)
self.assertEqual(
res,
[],
) | select 1 having false | test_sql_query_having_01 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_locking_00(self):
# Movie is allowed because it has no sub-types and access policies are
# not enabled.
await self.squery_values(
'''
SELECT id FROM "Movie" LIMIT 1 FOR UPDATE;
'''
)
await self.squery_values(
'''
SELECT id FROM "Movie" LIMIT 1 FOR NO KEY UPDATE NOWAIT;
'''
)
await self.squery_values(
'''
SELECT id FROM "Movie" LIMIT 1 FOR KEY SHARE SKIP LOCKED;
'''
) | SELECT id FROM "Movie" LIMIT 1 FOR UPDATE; | test_sql_query_locking_00 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_locking_01(self):
# fail because sub-types
with self.assertRaisesRegex(
asyncpg.FeatureNotSupportedError,
"locking clause not supported",
):
await self.squery_values(
'''
SELECT id FROM "Content" LIMIT 1 FOR UPDATE;
'''
)
# fail because access policies
with self.assertRaisesRegex(
asyncpg.FeatureNotSupportedError,
"locking clause not supported",
):
await self.scon.execute(
'SET LOCAL apply_access_policies_pg TO TRUE'
)
await self.squery_values(
'''
SELECT id FROM "Movie" LIMIT 1 FOR UPDATE;
'''
) | SELECT id FROM "Content" LIMIT 1 FOR UPDATE; | test_sql_query_locking_01 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_locking_02(self):
# we are locking just Movie
await self.squery_values(
'''
SELECT * FROM "Movie", "Content" LIMIT 1 FOR UPDATE OF "Movie";
'''
)
# we are locking just Movie
await self.squery_values(
'''
SELECT * FROM "Movie" m, "Content" LIMIT 1 FOR UPDATE OF m;
'''
)
# we are locking just Content
with self.assertRaisesRegex(
asyncpg.FeatureNotSupportedError,
"locking clause not supported",
):
await self.squery_values(
'''
SELECT * FROM "Movie", "Content" c LIMIT 1 FOR UPDATE OF c;
'''
) | SELECT * FROM "Movie", "Content" LIMIT 1 FOR UPDATE OF "Movie"; | test_sql_query_locking_02 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_locking_03(self):
# allowed, but this won't lock anything
await self.squery_values(
'''
SELECT * FROM (VALUES (1)) t FOR UPDATE;
'''
)
# allowed, will not lock Content
await self.squery_values(
'''
WITH c AS (SELECT * FROM "Content")
SELECT * FROM "Movie" FOR UPDATE;
'''
) | SELECT * FROM (VALUES (1)) t FOR UPDATE; | test_sql_query_locking_03 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_native_query_03(self):
# No output at all
await self.assert_sql_query_result(
"""
SELECT
WHERE NULL
""",
[],
)
# Empty tuples
await self.assert_sql_query_result(
"""
SELECT
FROM "Movie"
LIMIT 1
""",
[{}],
apply_access_policies=False,
) | SELECT
WHERE NULL
""",
[],
)
# Empty tuples
await self.assert_sql_query_result( | test_sql_native_query_03 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_native_query_13(self):
# globals
await self.assert_sql_query_result(
"""
SELECT username FROM "Person"
ORDER BY first_name LIMIT 1
""",
[{'username': "u_robin"}],
)
await self.con.execute(
'''
SET GLOBAL default::username_prefix := 'user_';
'''
)
await self.assert_sql_query_result(
"""
SELECT username FROM "Person"
ORDER BY first_name LIMIT 1
""",
[{'username': "user_robin"}],
) | SELECT username FROM "Person"
ORDER BY first_name LIMIT 1
""",
[{'username': "u_robin"}],
)
await self.con.execute( | test_sql_native_query_13 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_native_query_14(self):
# globals
await self.con.execute(
f"""
SET GLOBAL glob_mod::glob_str := 'hello';
SET GLOBAL glob_mod::glob_uuid :=
<uuid>'f527c032-ad4c-461e-95e2-67c4e2b42ca7';
SET GLOBAL glob_mod::glob_int64 := 42;
SET GLOBAL glob_mod::glob_int32 := 42;
SET GLOBAL glob_mod::glob_int16 := 42;
SET GLOBAL glob_mod::glob_bool := true;
SET GLOBAL glob_mod::glob_float64 := 42.1;
SET GLOBAL glob_mod::glob_float32 := 42.1;
"""
)
await self.con.execute_sql('INSERT INTO glob_mod."G" DEFAULT VALUES')
await self.assert_sql_query_result(
'''
SELECT
p_str,
p_uuid,
p_int64,
p_int32,
p_int16,
p_bool,
p_float64,
p_float32
FROM glob_mod."G"
''',
[
{
'p_str': 'hello',
'p_uuid': uuid.UUID('f527c032-ad4c-461e-95e2-67c4e2b42ca7'),
'p_int64': 42,
'p_int32': 42,
'p_int16': 42,
'p_bool': True,
'p_float64': 42.1,
'p_float32': 42.099998474121094,
}
],
) | )
await self.con.execute_sql('INSERT INTO glob_mod."G" DEFAULT VALUES')
await self.assert_sql_query_result( | test_sql_native_query_14 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_native_query_17(self):
await self.assert_sql_query_result(
"""SELECT $1::text as t, $2::int as i""",
[{"t": "Hello", "i": 42}],
variables={
"1": "Hello",
"2": 42,
},
apply_access_policies=False,
)
async with self.assertRaisesRegexTx(
edgedb.UnsupportedFeatureError,
'multi-statement SQL scripts are not supported yet',
):
await self.assert_sql_query_result(
"""
SELECT 'Hello' as t;
SELECT 42 as i;
""",
[],
apply_access_policies=False,
)
async with self.assertRaisesRegexTx(
edgedb.UnsupportedFeatureError,
'multi-statement SQL scripts are not supported yet',
):
await self.assert_sql_query_result(
"""
SELECT 'hello'::text as t;
SELECT $1::int as i;
""",
[],
variables={
"1": 42,
},
apply_access_policies=False,
)
async with self.assertRaisesRegexTx(
edgedb.UnsupportedFeatureError,
'multi-statement SQL scripts are not supported yet',
):
await self.assert_sql_query_result(
"""
SELECT $1::text as t;
SELECT 42::int as i;
""",
[],
variables={
"1": "Hello",
},
apply_access_policies=False,
)
async with self.assertRaisesRegexTx(
edgedb.UnsupportedFeatureError,
'multi-statement SQL scripts are not supported yet',
):
await self.assert_sql_query_result(
"""
SELECT $1::text as t;
SELECT $2::int as i;
""",
[],
variables={
"1": "Hello",
"2": 42,
},
apply_access_policies=False,
) | SELECT $1::text as t, $2::int as i""",
[{"t": "Hello", "i": 42}],
variables={
"1": "Hello",
"2": 42,
},
apply_access_policies=False,
)
async with self.assertRaisesRegexTx(
edgedb.UnsupportedFeatureError,
'multi-statement SQL scripts are not supported yet',
):
await self.assert_sql_query_result( | test_sql_native_query_17 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_native_query_18(self):
with self.assertRaisesRegex(
edgedb.errors.QueryError,
'column \"asdf\" does not exist',
_position=35,
):
await self.con.query_sql(
'''select title, 'aaaaaaaaaaaaaaaaa', asdf from "Content";'''
) | select title, 'aaaaaaaaaaaaaaaaa', asdf from "Content"; | test_sql_native_query_18 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_native_query_19(self):
with self.assertRaisesRegex(
edgedb.errors.ExecutionError,
'does not exist',
_position=35,
_hint=(
'No function matches the given name and argument types. '
'You might need to add explicit type casts.'
),
):
await self.con.query_sql(
'''select title, 'aaaaaaaaaaaaaaaaa', asdf() from "Content";'''
) | select title, 'aaaaaaaaaaaaaaaaa', asdf() from "Content"; | test_sql_native_query_19 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_native_query_29(self):
# test that we can query internal pg_catalog types
# (such as oid and name)
await self.con.query_sql('''
select oid, relname from pg_class limit 1
''')
await self.con.query_sql('''
select oid, typname, typtype, typsubscript, typdefaultbin
from pg_type limit 1
''') | )
await self.con.query_sql( | test_sql_native_query_29 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def set_current_database(val: Optional[bool]):
# for this to have effect, it must not be ran within a transaction
if val is None:
await self.con.execute(
f'''
configure current database
reset apply_access_policies_pg;
'''
)
else:
await self.con.execute(
f'''
configure current database
set apply_access_policies_pg := {str(val).lower()};
'''
) | )
else:
await self.con.execute(
f | test_sql_query_set_04.set_current_database | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def set_sql(val: Optional[bool]):
if val is None:
await self.scon.execute(
f'''
RESET apply_access_policies_pg;
'''
)
else:
await self.scon.execute(
f'''
SET apply_access_policies_pg TO '{str(val).lower()}';
'''
) | )
else:
await self.scon.execute(
f | test_sql_query_set_04.set_sql | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_set_04(self):
# database settings allow_user_specified_ids & apply_access_policies_pg
# should be unified over EdgeQL and SQL adapter
async def set_current_database(val: Optional[bool]):
# for this to have effect, it must not be ran within a transaction
if val is None:
await self.con.execute(
f'''
configure current database
reset apply_access_policies_pg;
'''
)
else:
await self.con.execute(
f'''
configure current database
set apply_access_policies_pg := {str(val).lower()};
'''
)
async def set_sql(val: Optional[bool]):
if val is None:
await self.scon.execute(
f'''
RESET apply_access_policies_pg;
'''
)
else:
await self.scon.execute(
f'''
SET apply_access_policies_pg TO '{str(val).lower()}';
'''
)
async def are_policies_applied() -> bool:
res = await self.squery_values(
'SELECT title FROM "Content" ORDER BY title'
)
return len(res) == 0
await set_current_database(True)
await set_sql(True)
self.assertEqual(await are_policies_applied(), True)
await set_sql(False)
self.assertEqual(await are_policies_applied(), False)
await set_sql(None)
self.assertEqual(await are_policies_applied(), True)
await set_current_database(False)
await set_sql(True)
self.assertEqual(await are_policies_applied(), True)
await set_sql(False)
self.assertEqual(await are_policies_applied(), False)
await set_sql(None)
self.assertEqual(await are_policies_applied(), False)
await set_current_database(None)
await set_sql(True)
self.assertEqual(await are_policies_applied(), True)
await set_sql(False)
self.assertEqual(await are_policies_applied(), False)
await set_sql(None)
self.assertEqual(await are_policies_applied(), False) | )
else:
await self.con.execute(
f | test_sql_query_set_04 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_sql_query_locking_04(self):
# test that we really obtain a lock
# we will obtain a lock on the main connection
# and then check that another connection is blocked
con_other = await self.create_sql_connection()
tran = self.scon.transaction()
await tran.start()
# obtain a lock
await self.scon.execute(
'''
SELECT * FROM "Movie" WHERE title = 'Forrest Gump'
FOR UPDATE;
'''
)
async def assert_not_blocked(coroutine: Coroutine) -> None:
await asyncio.wait_for(coroutine, 0.25)
async def assert_blocked(coroutine: Coroutine) -> Tuple[asyncio.Task]:
task: asyncio.Task = asyncio.create_task(coroutine)
done, pending = await asyncio.wait((task,), timeout=0.25)
if len(done) != 0:
self.fail("expected this action to block, but it completed")
task_t = (next(iter(pending)),)
return task_t
# querying is allowed
await assert_not_blocked(
con_other.execute(
'''
SELECT title FROM "Movie" WHERE title = 'Forrest Gump';
'''
)
)
# another FOR UPDATE is now blocked
(task,) = await assert_blocked(
con_other.execute(
'''
SELECT * FROM "Movie" WHERE title = 'Forrest Gump'
FOR UPDATE;
'''
)
)
# release the lock
await tran.rollback()
# now we can finish the second SELECT FOR UPDATE
await task
# and subsequent FOR UPDATE are not blocked
await assert_not_blocked(
con_other.execute(
'''
SELECT * FROM "Movie" WHERE title = 'Forrest Gump'
FOR UPDATE;
'''
)
)
await con_other.close() | SELECT * FROM "Movie" WHERE title = 'Forrest Gump'
FOR UPDATE; | test_sql_query_locking_04 | python | geldata/gel | tests/test_sql_query.py | https://github.com/geldata/gel/blob/master/tests/test_sql_query.py | Apache-2.0 |
async def test_immediate_connection_drop(self):
"""Test handling of a connection that is dropped immediately by the
server"""
async def mock_drop_server(
reader: asyncio.StreamReader, writer: asyncio.StreamWriter
):
# Close connection immediately after reading a byte without sending
# any response
await reader.read(1)
writer.close()
await writer.wait_closed()
server = await asyncio.start_server(mock_drop_server, '127.0.0.1', 0)
addr = server.sockets[0].getsockname()
url = f'http://{addr[0]}:{addr[1]}/drop'
try:
async with http.HttpClient(100) as client:
with self.assertRaisesRegex(
Exception, "Connection reset by peer|IncompleteMessage"
):
await client.get(url)
finally:
server.close()
await server.wait_closed() | Test handling of a connection that is dropped immediately by the
server | test_immediate_connection_drop | python | geldata/gel | tests/test_http.py | https://github.com/geldata/gel/blob/master/tests/test_http.py | Apache-2.0 |
async def test_immediate_connection_drop_streaming(self):
"""Test handling of a connection that is dropped immediately by the
server"""
async def mock_drop_server(
reader: asyncio.StreamReader, writer: asyncio.StreamWriter
):
# Close connection immediately after reading a byte without sending
# any response
await reader.read(1)
writer.close()
await writer.wait_closed()
server = await asyncio.start_server(mock_drop_server, '127.0.0.1', 0)
addr = server.sockets[0].getsockname()
url = f'http://{addr[0]}:{addr[1]}/drop'
try:
async with http.HttpClient(100) as client:
with self.assertRaisesRegex(
Exception, "Connection reset by peer|IncompleteMessage"
):
await client.stream_sse(url)
finally:
server.close()
await server.wait_closed() | Test handling of a connection that is dropped immediately by the
server | test_immediate_connection_drop_streaming | python | geldata/gel | tests/test_http.py | https://github.com/geldata/gel/blob/master/tests/test_http.py | Apache-2.0 |
async def test_sse_with_mock_server_client_close(self):
"""Since the regular mock server doesn't support SSE, we need to test
with a real socket. We handle just enough HTTP to get the job done."""
is_closed = False
async def mock_sse_server(
reader: asyncio.StreamReader, writer: asyncio.StreamWriter
):
nonlocal is_closed
await reader.readline()
headers = (
b"HTTP/1.1 200 OK\r\n"
b"Content-Type: text/event-stream\r\n"
b"Cache-Control: no-cache\r\n"
b"Connection: keep-alive\r\n\r\n"
)
writer.write(headers)
await writer.drain()
for i in range(3):
writer.write(b": test comment that should be ignored\n\n")
await writer.drain()
writer.write(
f"event: message\ndata: Event {i + 1}\n\n".encode()
)
await writer.drain()
await asyncio.sleep(0.1)
# Write enough messages that we get a broken pipe. The response gets
# closed below and will refuse any further messages.
try:
for _ in range(50):
writer.writelines([b"event: message", b"data: XX", b""])
await writer.drain()
writer.close()
await writer.wait_closed()
except Exception:
is_closed = True
server = await asyncio.start_server(mock_sse_server, '127.0.0.1', 0)
addr = server.sockets[0].getsockname()
url = f'http://{addr[0]}:{addr[1]}/sse'
async def client_task():
async with http.HttpClient(100) as client:
async with await client.stream_sse(
url, method="GET"
) as response:
assert response.status_code == 200
assert (
response.headers['Content-Type'] == 'text/event-stream'
)
assert isinstance(response, http.ResponseSSE)
events = []
async for event in response:
self.assertEqual(event.event, 'message')
events.append(event)
if len(events) == 3:
break
assert len(events) == 3
assert events[0].data == 'Event 1'
assert events[1].data == 'Event 2'
assert events[2].data == 'Event 3'
async with server:
client_future = asyncio.create_task(client_task())
await asyncio.wait_for(client_future, timeout=5.0)
assert is_closed | Since the regular mock server doesn't support SSE, we need to test
with a real socket. We handle just enough HTTP to get the job done. | test_sse_with_mock_server_client_close | python | geldata/gel | tests/test_http.py | https://github.com/geldata/gel/blob/master/tests/test_http.py | Apache-2.0 |
async def test_sse_with_mock_server_close(self):
"""Try to close the server-side stream and see if the client detects
an end for the iterator. Note that this is technically not correct SSE:
the client should actually try to reconnect after the specified retry
interval, _but_ we don't handle retries yet."""
is_closed = False
async def mock_sse_server(
reader: asyncio.StreamReader, writer: asyncio.StreamWriter
):
nonlocal is_closed
# Read until empty line
while True:
line = await reader.readline()
if line == b'\r\n':
break
headers = (
b"HTTP/1.1 200 OK\r\n"
b"Content-Type: text/event-stream\r\n"
b"Cache-Control: no-cache\r\n\r\n"
)
writer.write(headers)
await writer.drain()
for i in range(3):
writer.write(b": test comment that should be ignored\n\n")
await writer.drain()
writer.write(
f"event: message\ndata: Event {i + 1}\n\n".encode()
)
await writer.drain()
await asyncio.sleep(0.1)
await writer.drain()
writer.close()
is_closed = True
server = await asyncio.start_server(mock_sse_server, '127.0.0.1', 0)
addr = server.sockets[0].getsockname()
url = f'http://{addr[0]}:{addr[1]}/sse'
async def client_task():
async with http.HttpClient(100) as client:
async with await client.stream_sse(
url, method="GET", headers={"Connection": "close"}
) as response:
assert response.status_code == 200
assert (
response.headers['Content-Type'] == 'text/event-stream'
)
assert isinstance(response, http.ResponseSSE)
events = []
async for event in response:
self.assertEqual(event.event, 'message')
events.append(event)
assert len(events) == 3
assert events[0].data == 'Event 1'
assert events[1].data == 'Event 2'
assert events[2].data == 'Event 3'
async with server:
client_future = asyncio.create_task(client_task())
await asyncio.wait_for(client_future, timeout=5.0)
assert is_closed | Try to close the server-side stream and see if the client detects
an end for the iterator. Note that this is technically not correct SSE:
the client should actually try to reconnect after the specified retry
interval, _but_ we don't handle retries yet. | test_sse_with_mock_server_close | python | geldata/gel | tests/test_http.py | https://github.com/geldata/gel/blob/master/tests/test_http.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_00(self):
"""
SELECT Card
% OK %
UNIQUE
""" | SELECT Card
% OK %
UNIQUE | test_edgeql_ir_mult_inference_00 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_01(self):
"""
SELECT Card.id
% OK %
UNIQUE
""" | SELECT Card.id
% OK %
UNIQUE | test_edgeql_ir_mult_inference_01 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_02(self):
"""
SELECT User.name
% OK %
UNIQUE
""" | SELECT User.name
% OK %
UNIQUE | test_edgeql_ir_mult_inference_02 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_03(self):
# Unconstrained property
"""
SELECT User.deck_cost
% OK %
DUPLICATE
""" | SELECT User.deck_cost
% OK %
DUPLICATE | test_edgeql_ir_mult_inference_03 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_04(self):
"""
SELECT Card FILTER Card.name = 'Djinn'
% OK %
UNIQUE
""" | SELECT Card FILTER Card.name = 'Djinn'
% OK %
UNIQUE | test_edgeql_ir_mult_inference_04 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_05(self):
"""
SELECT Card LIMIT 1
% OK %
UNIQUE
""" | SELECT Card LIMIT 1
% OK %
UNIQUE | test_edgeql_ir_mult_inference_05 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_06(self):
"""
SELECT 1
% OK %
UNIQUE
""" | SELECT 1
% OK %
UNIQUE | test_edgeql_ir_mult_inference_06 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_07(self):
"""
SELECT {1, 2}
% OK %
UNIQUE
""" | SELECT {1, 2}
% OK %
UNIQUE | test_edgeql_ir_mult_inference_07 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_08(self):
"""
SELECT {1, 1}
% OK %
DUPLICATE
""" | SELECT {1, 1}
% OK %
DUPLICATE | test_edgeql_ir_mult_inference_08 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_09(self):
"""
SELECT User.deck
% OK %
UNIQUE
""" | SELECT User.deck
% OK %
UNIQUE | test_edgeql_ir_mult_inference_09 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_10(self):
"""
SELECT Card.cost
% OK %
DUPLICATE
""" | SELECT Card.cost
% OK %
DUPLICATE | test_edgeql_ir_mult_inference_10 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_11(self):
"""
SELECT Card.owners
% OK %
UNIQUE
""" | SELECT Card.owners
% OK %
UNIQUE | test_edgeql_ir_mult_inference_11 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_12(self):
"""
SELECT {Card, User}
% OK %
UNIQUE
""" | SELECT {Card, User}
% OK %
UNIQUE | test_edgeql_ir_mult_inference_12 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_13(self):
"""
SELECT 1 + 2
% OK %
UNIQUE
""" | SELECT 1 + 2
% OK %
UNIQUE | test_edgeql_ir_mult_inference_13 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_14a(self):
"""
SELECT 1 + {2, 3}
% OK %
UNIQUE
""" | SELECT 1 + {2, 3}
% OK %
UNIQUE | test_edgeql_ir_mult_inference_14a | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_14b(self):
"""
SELECT 0 * {2, 3}
% OK %
DUPLICATE
""" | SELECT 0 * {2, 3}
% OK %
DUPLICATE | test_edgeql_ir_mult_inference_14b | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_15(self):
"""
SELECT {1, 2} + {2, 3}
% OK %
DUPLICATE
""" | SELECT {1, 2} + {2, 3}
% OK %
DUPLICATE | test_edgeql_ir_mult_inference_15 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_16(self):
"""
SELECT 'pre_' ++ Card.name
% OK %
UNIQUE
""" | SELECT 'pre_' ++ Card.name
% OK %
UNIQUE | test_edgeql_ir_mult_inference_16 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_17(self):
"""
SELECT User.name ++ Card.name
% OK %
DUPLICATE
""" | SELECT User.name ++ Card.name
% OK %
DUPLICATE | test_edgeql_ir_mult_inference_17 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_18(self):
"""
SELECT (1, {'a', 'b'})
% OK %
UNIQUE
""" | SELECT (1, {'a', 'b'})
% OK %
UNIQUE | test_edgeql_ir_mult_inference_18 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_19(self):
"""
SELECT (1, Card.name)
% OK %
UNIQUE
""" | SELECT (1, Card.name)
% OK %
UNIQUE | test_edgeql_ir_mult_inference_19 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_20(self):
"""
SELECT [1, {1, 2}]
% OK %
UNIQUE
""" | SELECT [1, {1, 2}]
% OK %
UNIQUE | test_edgeql_ir_mult_inference_20 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_21(self):
"""
SELECT ['card', Card.name]
% OK %
UNIQUE
""" | SELECT ['card', Card.name]
% OK %
UNIQUE | test_edgeql_ir_mult_inference_21 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.