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 |
---|---|---|---|---|---|---|---|
def test_edgeql_ir_type_inference_03(self):
"""
SELECT {Card, User}
% OK %
__derived__::(default:Card | default:User)
""" | SELECT {Card, User}
% OK %
__derived__::(default:Card | default:User) | test_edgeql_ir_type_inference_03 | python | geldata/gel | tests/test_edgeql_ir_type_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_type_inference.py | Apache-2.0 |
def test_edgeql_ir_type_inference_04(self):
"""
SELECT Card if true else User
% OK %
__derived__::(default:Card | default:User)
""" | SELECT Card if true else User
% OK %
__derived__::(default:Card | default:User) | test_edgeql_ir_type_inference_04 | python | geldata/gel | tests/test_edgeql_ir_type_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_type_inference.py | Apache-2.0 |
def test_edgeql_ir_type_inference_05(self):
"""
SELECT Card ?? User
% OK %
__derived__::(default:Card | default:User)
""" | SELECT Card ?? User
% OK %
__derived__::(default:Card | default:User) | test_edgeql_ir_type_inference_05 | python | geldata/gel | tests/test_edgeql_ir_type_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_type_inference.py | Apache-2.0 |
async def test_edgeql_props_setops_01(self):
await self.assert_query_result(
r'''
SELECT DISTINCT User.deck@count;
''',
{1, 2, 3, 4},
)
await self.assert_query_result(
r'''
SELECT User.deck@count FILTER User.deck.element = 'Fire'
''',
tb.bag([1, 2, 2]),
)
await self.assert_query_result(
r'''
SELECT DISTINCT (
SELECT User.deck@count FILTER User.deck.element = 'Fire'
);
''',
{1, 2},
)
await self.assert_query_result(
r'''
SELECT DISTINCT (
SELECT User.deck@count FILTER User.deck.element = 'Water'
);
''',
{1, 2, 3},
)
await self.assert_query_result(
r'''
SELECT DISTINCT (
SELECT (
SELECT Card FILTER Card.element = 'Water'
).<deck[IS User]@count
);
''',
{1, 2, 3},
) | ,
{1, 2, 3, 4},
)
await self.assert_query_result(
r | test_edgeql_props_setops_01 | python | geldata/gel | tests/test_edgeql_linkprops.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_linkprops.py | Apache-2.0 |
async def test_edgeql_props_setops_02(self):
await self.assert_query_result(
r'''
WITH
C := (
SELECT User FILTER User.name = 'Carol').deck.name,
D := (
SELECT User FILTER User.name = 'Dave').deck.name
SELECT _ := C UNION D
ORDER BY _;
''',
[
'Bog monster',
'Bog monster',
'Djinn',
'Djinn',
'Dragon',
'Dwarf',
'Giant eagle',
'Giant eagle',
'Giant turtle',
'Giant turtle',
'Golem',
'Golem',
'Sprite',
'Sprite'
],
)
await self.assert_query_result(
r'''
WITH
C := (
SELECT User FILTER User.name = 'Carol').deck.name,
D := (
SELECT User FILTER User.name = 'Dave').deck.name
SELECT _ := DISTINCT (C UNION D)
ORDER BY _;
''',
[
'Bog monster',
'Djinn',
'Dragon',
'Dwarf',
'Giant eagle',
'Giant turtle',
'Golem',
'Sprite'
],
) | ,
[
'Bog monster',
'Bog monster',
'Djinn',
'Djinn',
'Dragon',
'Dwarf',
'Giant eagle',
'Giant eagle',
'Giant turtle',
'Giant turtle',
'Golem',
'Golem',
'Sprite',
'Sprite'
],
)
await self.assert_query_result(
r | test_edgeql_props_setops_02 | python | geldata/gel | tests/test_edgeql_linkprops.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_linkprops.py | Apache-2.0 |
async def test_edgeql_props_setops_03(self):
await self.assert_query_result(
r'''
SELECT _ := {
# this is equivalent to UNION
User.name,
User.friends@nickname,
{'Foo', 'Bob'}
}
ORDER BY _;
''',
[
'Alice', 'Bob', 'Bob', 'Carol', 'Dave', 'Firefighter',
'Foo', 'Grumpy', 'Swampy'
],
)
await self.assert_query_result(
r'''
SELECT _ := DISTINCT {
User.name,
User.friends@nickname,
{'Foo', 'Bob'}
}
ORDER BY _;
''',
[
'Alice', 'Bob', 'Carol', 'Dave', 'Firefighter', 'Foo',
'Grumpy', 'Swampy',
],
) | ,
[
'Alice', 'Bob', 'Bob', 'Carol', 'Dave', 'Firefighter',
'Foo', 'Grumpy', 'Swampy'
],
)
await self.assert_query_result(
r | test_edgeql_props_setops_03 | python | geldata/gel | tests/test_edgeql_linkprops.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_linkprops.py | Apache-2.0 |
async def test_edgeql_props_agg_01(self):
await self.assert_query_result(
r'''
SELECT sum(User.deck@count);
''',
[51],
)
await self.assert_query_result(
r'''
SELECT _ := (
FOR User in User
SELECT (sum(User.deck@count), User.name)
)
ORDER BY _;
''',
[
[10, 'Alice'], [10, 'Dave'], [12, 'Bob'], [19, 'Carol'],
],
) | ,
[51],
)
await self.assert_query_result(
r | test_edgeql_props_agg_01 | python | geldata/gel | tests/test_edgeql_linkprops.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_linkprops.py | Apache-2.0 |
async def test_edgeql_props_link_union_01(self):
await self.con.execute(r'''
CREATE TYPE Tgt;
CREATE TYPE Tgt2 EXTENDING Tgt;
CREATE TYPE Bar {
CREATE LINK l -> Tgt {
CREATE PROPERTY x -> str;
};
};
CREATE TYPE Foo {
CREATE LINK l -> Tgt {
CREATE PROPERTY x -> str;
};
};
CREATE TYPE Baz {
CREATE LINK fubar -> (Bar | Foo);
};
INSERT Baz {
fubar := (INSERT Bar {
l := (INSERT Tgt2 { @x := "test" })
})
};
''')
await self.assert_query_result(
r'''
SELECT Baz.fubar.l@x;
''',
["test"],
)
await self.assert_query_result(
r'''
SELECT Baz.fubar.l[IS Tgt2]@x;
''',
["test"],
)
await self.assert_query_result(
r'''
SELECT (Foo UNION Bar).l@x;
''',
["test"],
) | )
await self.assert_query_result(
r | test_edgeql_props_link_union_01 | python | geldata/gel | tests/test_edgeql_linkprops.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_linkprops.py | Apache-2.0 |
async def test_edgeql_props_link_union_02(self):
await self.con.execute(r'''
CREATE TYPE Tgt;
CREATE TYPE Tgt2 EXTENDING Tgt;
CREATE TYPE Bar {
CREATE MULTI LINK l -> Tgt {
CREATE PROPERTY x -> str;
};
};
CREATE TYPE Foo {
CREATE MULTI LINK l -> Tgt {
CREATE PROPERTY x -> str;
};
};
CREATE TYPE Baz {
CREATE LINK fubar -> (Bar | Foo);
};
INSERT Baz {
fubar := (INSERT Bar {
l := (INSERT Tgt2 { @x := "test" })
})
};
''')
await self.assert_query_result(
r'''
SELECT Baz.fubar.l@x;
''',
["test"],
)
await self.assert_query_result(
r'''
SELECT Baz.fubar.l[IS Tgt2]@x;
''',
["test"],
)
await self.assert_query_result(
r'''
SELECT (Foo UNION Bar).l@x;
''',
["test"],
) | )
await self.assert_query_result(
r | test_edgeql_props_link_union_02 | python | geldata/gel | tests/test_edgeql_linkprops.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_linkprops.py | Apache-2.0 |
async def test_edgeql_props_link_union_03(self):
await self.con.execute(r'''
CREATE TYPE Tgt;
CREATE TYPE Tgt2 EXTENDING Tgt;
CREATE TYPE Bar {
CREATE LINK l -> Tgt {
CREATE PROPERTY x -> str;
};
};
CREATE TYPE Foo {
CREATE MULTI LINK l -> Tgt {
CREATE PROPERTY x -> str;
};
};
CREATE TYPE Baz {
CREATE LINK fubar -> (Bar | Foo);
};
INSERT Baz {
fubar := (INSERT Bar {
l := (INSERT Tgt2 { @x := "test" })
})
};
''')
await self.assert_query_result(
r'''
SELECT Baz.fubar.l@x;
''',
["test"],
)
await self.assert_query_result(
r'''
SELECT Baz.fubar.l[IS Tgt2]@x;
''',
["test"],
)
await self.assert_query_result(
r'''
SELECT (Foo UNION Bar).l@x;
''',
["test"],
) | )
await self.assert_query_result(
r | test_edgeql_props_link_union_03 | python | geldata/gel | tests/test_edgeql_linkprops.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_linkprops.py | Apache-2.0 |
async def test_edgeql_props_schema_back_02(self):
await self.assert_query_result(
r'''
select Card { name, z := .owners { name, @count }}
filter .name = 'Dragon';
''',
[
{
"name": "Dragon",
"z": tb.bag([
{"@count": 2, "name": "Alice"},
{"@count": 1, "name": "Dave"},
])
}
]
)
await self.assert_query_result(
r'''
select Card { name, owners: { name, @count }}
filter .name = 'Dragon';
''',
[
{
"name": "Dragon",
"owners": tb.bag([
{"@count": 2, "name": "Alice"},
{"@count": 1, "name": "Dave"},
])
}
]
)
await self.assert_query_result(
r'''
select SpecialCard { name, owners: { name, @count }}
filter .name = 'Djinn';
''',
[
{
"name": "Djinn",
"owners": tb.bag([
{"@count": 1, "name": "Carol"},
{"@count": 1, "name": "Dave"},
])
}
]
) | ,
[
{
"name": "Dragon",
"z": tb.bag([
{"@count": 2, "name": "Alice"},
{"@count": 1, "name": "Dave"},
])
}
]
)
await self.assert_query_result(
r | test_edgeql_props_schema_back_02 | python | geldata/gel | tests/test_edgeql_linkprops.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_linkprops.py | Apache-2.0 |
async def test_edgeql_props_schema_back_03(self):
await self.assert_query_result(
r'''
select Card { name, z := .owners { name, x := @count }}
filter .name = 'Dragon';
''',
[
{
"name": "Dragon",
"z": tb.bag([
{"x": 2, "name": "Alice"},
{"x": 1, "name": "Dave"},
])
}
]
)
await self.assert_query_result(
r'''
select Card { name, owners: { name, x := @count }}
filter .name = 'Dragon';
''',
[
{
"name": "Dragon",
"owners": tb.bag([
{"x": 2, "name": "Alice"},
{"x": 1, "name": "Dave"},
])
}
]
) | ,
[
{
"name": "Dragon",
"z": tb.bag([
{"x": 2, "name": "Alice"},
{"x": 1, "name": "Dave"},
])
}
]
)
await self.assert_query_result(
r | test_edgeql_props_schema_back_03 | python | geldata/gel | tests/test_edgeql_linkprops.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_linkprops.py | Apache-2.0 |
async def test_edgeql_props_schema_back_04(self):
await self.assert_query_result(
r'''
select assert_exists((
select Card { name, z := .owners { name, @count }}
filter .name = 'Dragon'
));
''',
[
{
"name": "Dragon",
"z": tb.bag([
{"@count": 2, "name": "Alice"},
{"@count": 1, "name": "Dave"},
])
}
]
)
await self.assert_query_result(
r'''
select assert_exists((
select Card { name, owners: { name, @count }}
filter .name = 'Dragon'
));
''',
[
{
"name": "Dragon",
"owners": tb.bag([
{"@count": 2, "name": "Alice"},
{"@count": 1, "name": "Dave"},
])
}
]
) | ,
[
{
"name": "Dragon",
"z": tb.bag([
{"@count": 2, "name": "Alice"},
{"@count": 1, "name": "Dave"},
])
}
]
)
await self.assert_query_result(
r | test_edgeql_props_schema_back_04 | python | geldata/gel | tests/test_edgeql_linkprops.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_linkprops.py | Apache-2.0 |
async def test_edgeql_props_schema_back_05(self):
await self.assert_query_result(
r'''
select assert_exists((
select Card { name, z := .owners { name, x := @count }}
filter .name = 'Dragon'
));
''',
[
{
"name": "Dragon",
"z": tb.bag([
{"x": 2, "name": "Alice"},
{"x": 1, "name": "Dave"},
])
}
]
)
await self.assert_query_result(
r'''
select assert_exists((
select Card { name, owners: { name, x := @count }}
filter .name = 'Dragon'
));
''',
[
{
"name": "Dragon",
"owners": tb.bag([
{"x": 2, "name": "Alice"},
{"x": 1, "name": "Dave"},
])
}
]
) | ,
[
{
"name": "Dragon",
"z": tb.bag([
{"x": 2, "name": "Alice"},
{"x": 1, "name": "Dave"},
])
}
]
)
await self.assert_query_result(
r | test_edgeql_props_schema_back_05 | python | geldata/gel | tests/test_edgeql_linkprops.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_linkprops.py | Apache-2.0 |
async def test_edgeql_props_modification_01(self):
await self.con.execute(r'''
CREATE TYPE Tgt;
CREATE TYPE Src {
CREATE LINK l -> Tgt {
CREATE PROPERTY x -> str;
};
};
''')
with self.assertRaisesRegex(
edgedb.InvalidReferenceError,
r"link 'l' of object type 'default::Src' has no property 'y'",
_hint="did you mean 'x'?"):
await self.con.query(
r'''
insert Src { l := assert_single(Tgt { @y := "..." }) };
'''
) | )
with self.assertRaisesRegex(
edgedb.InvalidReferenceError,
r"link 'l' of object type 'default::Src' has no property 'y'",
_hint="did you mean 'x'?"):
await self.con.query(
r | test_edgeql_props_modification_01 | python | geldata/gel | tests/test_edgeql_linkprops.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_linkprops.py | Apache-2.0 |
async def test_edgeql_props_tuples_01(self):
await self.con.execute(r'''
create type Org;
create type Foo {
create multi link orgs -> Org {
create property roles -> tuple<role1: bool, role2: bool>;
}
};
insert Org;
insert Foo { orgs := (select Org {
@roles := (role1 := true, role2 := false) }) };
''')
await self.assert_query_result(
'''
select [email protected];
''',
[True],
) | )
await self.assert_query_result( | test_edgeql_props_tuples_01 | python | geldata/gel | tests/test_edgeql_linkprops.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_linkprops.py | Apache-2.0 |
async def test_edgeql_pure_computed_linkprops_01(self):
await self.con.execute(r'''
CREATE TYPE default::Test3 {
CREATE PROPERTY name: std::str {
SET default := 'test3';
};
};
CREATE TYPE default::Test4 {
CREATE LINK test3ref: default::Test3 {
CREATE PROPERTY note := (.name);
};
CREATE PROPERTY name: std::str {
SET default := 'test4';
};
};
insert Test3;
''')
await self.assert_query_result(
'''
insert Test4 { test3ref := (select Test3 limit 1)};
''',
[{}],
) | )
await self.assert_query_result( | test_edgeql_pure_computed_linkprops_01 | python | geldata/gel | tests/test_edgeql_linkprops.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_linkprops.py | Apache-2.0 |
async def test_edgeql_functions_array_agg_03(self):
await self.assert_query_result(
r'''
WITH x := {3, 1, 2}
SELECT array_agg(x ORDER BY x);
''',
[[1, 2, 3]],
)
await self.assert_query_result(
r'''
WITH x := {3, 1, 2}
SELECT array_agg(x ORDER BY x) = [1, 2, 3];
''',
[True],
) | ,
[[1, 2, 3]],
)
await self.assert_query_result(
r | test_edgeql_functions_array_agg_03 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_array_agg_04(self):
await self.assert_query_result(
r'''
WITH x := {3, 1, 2}
SELECT contains(array_agg(x ORDER BY x), 2);
''',
[True],
)
await self.assert_query_result(
r'''
WITH x := {3, 1, 2}
SELECT contains(array_agg(x ORDER BY x), 5);
''',
[False],
)
await self.assert_query_result(
r'''
WITH x := {3, 1, 2}
SELECT contains(array_agg(x ORDER BY x), 5);
''',
[False],
) | ,
[True],
)
await self.assert_query_result(
r | test_edgeql_functions_array_agg_04 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_array_agg_07(self):
await self.assert_query_result(
r'''
SELECT array_agg((SELECT schema::ObjectType FILTER False));
''',
[[]]
)
await self.assert_query_result(
r'''
SELECT array_agg(
(SELECT schema::ObjectType
FILTER <str>schema::ObjectType.id = '~')
);
''',
[[]]
) | ,
[[]]
)
await self.assert_query_result(
r | test_edgeql_functions_array_agg_07 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_array_agg_08(self):
await self.assert_query_result(
r'''
WITH x := <int64>{}
SELECT array_agg(x);
''',
[[]]
)
await self.assert_query_result(
r'''
WITH x := (SELECT schema::ObjectType FILTER False)
SELECT array_agg(x);
''',
[[]]
)
await self.assert_query_result(
r'''
WITH x := (
SELECT schema::ObjectType
FILTER <str>schema::ObjectType.id = '~'
)
SELECT array_agg(x);
''',
[[]]
) | ,
[[]]
)
await self.assert_query_result(
r | test_edgeql_functions_array_agg_08 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_array_agg_12(self):
await self.assert_query_result(
r'''
SELECT
array_agg(User{name} ORDER BY User.name);
''',
[[{'name': 'Elvis'}, {'name': 'Yury'}]]
)
result = await self.con.query(r'''
SELECT
array_agg(User{name} ORDER BY User.name);
''')
self.assertEqual(result[0][0].name, 'Elvis')
self.assertEqual(result[0][1].name, 'Yury') | ,
[[{'name': 'Elvis'}, {'name': 'Yury'}]]
)
result = await self.con.query(r | test_edgeql_functions_array_agg_12 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_array_agg_20(self):
await self.assert_query_result(
r'''
SELECT Issue { te := array_agg(.time_estimate) };
''',
tb.bag([{"te": [3000]}, {"te": []}, {"te": []}, {"te": []}]),
)
await self.assert_query_result(
r'''
SELECT Issue { te := array_agg(.time_estimate UNION 3000) };
''',
tb.bag(
[{"te": [3000, 3000]}, {"te": [3000]},
{"te": [3000]}, {"te": [3000]}],
)
) | ,
tb.bag([{"te": [3000]}, {"te": []}, {"te": []}, {"te": []}]),
)
await self.assert_query_result(
r | test_edgeql_functions_array_agg_20 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_array_unpack_06(self):
# We have a special case optimization for "IN array_unpack" so
# it's worth testing it.
await self.assert_query_result(
r'''SELECT 1 IN array_unpack([1]);''',
[True],
)
await self.assert_query_result(
r'''SELECT 2 IN array_unpack([1]);''',
[False],
)
await self.assert_query_result(
r'''SELECT 2 NOT IN array_unpack([1]);''',
[True],
)
await self.assert_query_result(
r'''SELECT 1 IN array_unpack({[1,2,3], [4,5,6]});''',
[True],
)
await self.assert_query_result(
r'''SELECT 0 IN array_unpack({[1,2,3], [4,5,6]});''',
[False],
)
await self.assert_query_result(
r'''SELECT 1 NOT IN array_unpack({[1,2,3], [4,5,6]});''',
[False],
)
await self.assert_query_result(
r'''SELECT 0 NOT IN array_unpack({[1,2,3], [4,5,6]});''',
[True],
)
await self.assert_query_result(
r"""
SELECT ("foo", 1) IN array_unpack([("foo", 1), ("bar", 2)]);
""",
[True],
)
await self.assert_query_result(
r'''SELECT 2 IN array_unpack(<array<int64>>{});''',
[False],
)
await self.assert_query_result(
r'''SELECT 2 NOT IN array_unpack(<array<int64>>{});''',
[True],
)
await self.assert_query_result(
r'''SELECT 1n IN array_unpack([1n]);''',
[True],
)
await self.assert_query_result(
r'''
select 1n in array_unpack(
<array<bigint>><array<str>>to_json('["1"]'))
''',
[True],
) | ,
[True],
)
await self.assert_query_result(
r'''SELECT 2 IN array_unpack(<array<int64>>{});''',
[False],
)
await self.assert_query_result(
r'''SELECT 2 NOT IN array_unpack(<array<int64>>{});''',
[True],
)
await self.assert_query_result(
r'''SELECT 1n IN array_unpack([1n]);''',
[True],
)
await self.assert_query_result(
r | test_edgeql_functions_array_unpack_06 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_array_replace_03(self):
await self.assert_query_result(
r'''
select array_replace(
[(0, 'a'), (10, 'b'), (3, 'hello'), (0, 'a')],
(0, 'a'), (99, '!')
);
''',
[[(99, '!'), (10, 'b'), (3, 'hello'), (99, '!')]],
)
await self.assert_query_result(
r'''
select array_replace(
[(0, 'a'), (10, 'b'), (3, 'hello'), (0, 'a')],
(1, 'a'), (99, '!')
);
''',
[[(0, 'a'), (10, 'b'), (3, 'hello'), (0, 'a')]],
) | ,
[[(99, '!'), (10, 'b'), (3, 'hello'), (99, '!')]],
)
await self.assert_query_result(
r | test_edgeql_functions_array_replace_03 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_array_replace_04(self):
await self.assert_query_result(
r'''
select array_replace(
[
(a := 0, b := 'a'),
(a := 10, b := 'b'),
(a := 3, b := 'hello'),
(a := 0, b := 'a')
],
(a := 0, b := 'a'), (a := 99, b := '!')
);
''',
[[
{"a": 99, "b": "!"},
{"a": 10, "b": "b"},
{"a": 3, "b": "hello"},
{"a": 99, "b": "!"}
]],
)
await self.assert_query_result(
r'''
select array_replace(
[
(a := 0, b := 'a'),
(a := 10, b := 'b'),
(a := 3, b := 'hello'),
(a := 0, b := 'a')
],
(a := 1, b := 'a'), (a := 99, b := '!')
);
''',
[[
{"a": 0, "b": "a"},
{"a": 10, "b": "b"},
{"a": 3, "b": "hello"},
{"a": 0, "b": "a"}
]],
) | ,
[[
{"a": 99, "b": "!"},
{"a": 10, "b": "b"},
{"a": 3, "b": "hello"},
{"a": 99, "b": "!"}
]],
)
await self.assert_query_result(
r | test_edgeql_functions_array_replace_04 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_enumerate_08(self):
await self.assert_query_result(
r'''
SELECT Issue { te := enumerate(.time_estimate) };
''',
tb.bag(
[{"te": [0, 3000]}, {"te": None}, {"te": None}, {"te": None}]
)
)
await self.assert_query_result(
r'''
SELECT Issue { te := enumerate(.time_estimate UNION 3000) };
''',
tb.bag([
{"te": [[0, 3000], [1, 3000]]},
{"te": [[0, 3000]]},
{"te": [[0, 3000]]},
{"te": [[0, 3000]]}
])
) | ,
tb.bag(
[{"te": [0, 3000]}, {"te": None}, {"te": None}, {"te": None}]
)
)
await self.assert_query_result(
r | test_edgeql_functions_enumerate_08 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_array_get_02(self):
await self.assert_query_result(
r'''
SELECT array_get(array_agg(
Issue.number ORDER BY Issue.number), 2);
''',
['3'],
)
await self.assert_query_result(
r'''
SELECT array_get(array_agg(
Issue.number ORDER BY Issue.number), -2);
''',
['3'],
)
await self.assert_query_result(
r'''SELECT array_get(array_agg(Issue.number), 20);''',
[]
)
await self.assert_query_result(
r'''SELECT array_get(array_agg(Issue.number), -20);''',
[]
) | ,
['3'],
)
await self.assert_query_result(
r | test_edgeql_functions_array_get_02 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_re_match_01(self):
await self.assert_query_result(
r'''SELECT re_match('ab', 'AbabaB');''',
[['ab']],
)
await self.assert_query_result(
r'''SELECT re_match('AB', 'AbabaB');''',
[],
)
await self.assert_query_result(
r'''SELECT re_match('(?i)AB', 'AbabaB');''',
[['Ab']],
)
await self.assert_query_result(
r'''SELECT re_match('ac', 'AbabaB');''',
[],
)
await self.assert_query_result(
r'''SELECT EXISTS re_match('ac', 'AbabaB');''',
[False],
)
await self.assert_query_result(
r'''SELECT NOT EXISTS re_match('ac', 'AbabaB');''',
[True],
)
await self.assert_query_result(
r'''SELECT EXISTS re_match('ab', 'AbabaB');''',
[True],
)
await self.assert_query_result(
r'''SELECT NOT EXISTS re_match('ab', 'AbabaB');''',
[False],
)
await self.assert_query_result(
r'''SELECT x := re_match({'(?i)ab', 'a'}, 'AbabaB') ORDER BY x;''',
[['Ab'], ['a']],
)
await self.assert_query_result(
r'''
SELECT x := re_match({'(?i)ab', 'a'}, {'AbabaB', 'qwerty'})
ORDER BY x;
''',
[['Ab'], ['a']],
)
await self.assert_query_result(
r'''
select re_match(
r"(foo)?bar",
'barbar',
)
''',
[[""]],
) | ,
[['Ab'], ['a']],
)
await self.assert_query_result(
r | test_edgeql_functions_re_match_01 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_re_match_all_01(self):
await self.assert_query_result(
r'''SELECT re_match_all('ab', 'AbabaB');''',
[['ab']],
)
await self.assert_query_result(
r'''SELECT re_match_all('AB', 'AbabaB');''',
[],
)
await self.assert_query_result(
r'''SELECT re_match_all('(?i)AB', 'AbabaB');''',
[['Ab'], ['ab'], ['aB']],
)
await self.assert_query_result(
r'''SELECT re_match_all('ac', 'AbabaB');''',
[],
)
await self.assert_query_result(
r'''SELECT EXISTS re_match_all('ac', 'AbabaB');''',
[False],
)
await self.assert_query_result(
r'''SELECT NOT EXISTS re_match_all('ac', 'AbabaB');''',
[True],
)
await self.assert_query_result(
r'''SELECT EXISTS re_match_all('(?i)ab', 'AbabaB');''',
[True],
)
await self.assert_query_result(
r'''SELECT NOT EXISTS re_match_all('(?i)ab', 'AbabaB');''',
[False],
)
await self.assert_query_result(
r'''
SELECT x := re_match_all({'(?i)ab', 'a'}, 'AbabaB')
ORDER BY x;''',
[['Ab'], ['a'], ['a'], ['aB'], ['ab']],
)
await self.assert_query_result(
r'''
SELECT x := re_match_all({'(?i)ab', 'a'},
{'AbabaB', 'qwerty'})
ORDER BY x;
''',
[['Ab'], ['a'], ['a'], ['aB'], ['ab']],
)
await self.assert_query_result(
r'''
select re_match_all(
r"(foo)?bar",
'barbar',
)
''',
[[""], [""]],
) | ,
[['Ab'], ['a'], ['a'], ['aB'], ['ab']],
)
await self.assert_query_result(
r | test_edgeql_functions_re_match_all_01 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_re_replace_02(self):
await self.assert_query_result(
r'''SELECT re_replace('[aeiou]', '~', User.name);''',
{'Elv~s', 'Y~ry'},
)
await self.assert_query_result(
r'''
SELECT re_replace('[aeiou]', '~', User.name,
flags := 'g');
''',
{'Elv~s', 'Y~ry'},
)
await self.assert_query_result(
r'''
SELECT re_replace('[aeiou]', '~', User.name,
flags := 'i');
''',
{'~lvis', 'Y~ry'},
)
await self.assert_query_result(
r'''
SELECT re_replace('[aeiou]', '~', User.name,
flags := 'gi');
''',
{'~lv~s', 'Y~ry'},
) | ,
{'Elv~s', 'Y~ry'},
)
await self.assert_query_result(
r | test_edgeql_functions_re_replace_02 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_datetime_current_02(self):
batch1 = await self.con.query_json(r'''
WITH MODULE schema
SELECT Type {
dt_t := datetime_of_transaction(),
dt_s := datetime_of_statement(),
dt_n := datetime_current(),
};
''')
batch2 = await self.con.query_json(r'''
# NOTE: this test assumes that there's at least 1 microsecond
# time difference between statements
WITH MODULE schema
SELECT Type {
dt_t := datetime_of_transaction(),
dt_s := datetime_of_statement(),
dt_n := datetime_current(),
};
''')
batch1 = json.loads(batch1)
batch2 = json.loads(batch2)
batches = batch1 + batch2
# all of the dt_t should be the same
set_dt_t = {t['dt_t'] for t in batches}
self.assertTrue(len(set_dt_t) == 1)
# all of the dt_s should be the same in each batch
set_dt_s1 = {t['dt_s'] for t in batch1}
set_dt_s2 = {t['dt_s'] for t in batch2}
self.assertTrue(len(set_dt_s1) == 1)
self.assertTrue(len(set_dt_s1) == 1)
# the transaction and statement datetimes should be in
# chronological order
dt_t = set_dt_t.pop()
dt_s1 = set_dt_s1.pop()
dt_s2 = set_dt_s2.pop()
self.assertTrue(dt_t <= dt_s1 < dt_s2)
# the first "now" datetime is no earlier than the statement
# for each batch
self.assertTrue(dt_s1 <= batch1[0]['dt_n'])
self.assertTrue(dt_s2 <= batch2[0]['dt_n'])
# every dt_n is already in chronological order
self.assertEqual(
[t['dt_n'] for t in batches],
sorted([t['dt_n'] for t in batches])
)
# the first dt_n is strictly earlier than the last
self.assertTrue(batches[0]['dt_n'] < batches[-1]['dt_n']) | )
batch2 = await self.con.query_json(r | test_edgeql_functions_datetime_current_02 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_datetime_get_01(self):
await self.assert_query_result(
r'''
SELECT datetime_get(
<datetime>'2018-05-07T15:01:22.306916-05', 'millennium');
''',
{3},
)
await self.assert_query_result(
r'''
SELECT datetime_get(
<datetime>'2018-05-07T15:01:22.306916-05', 'century');
''',
{21},
)
await self.assert_query_result(
r'''
SELECT datetime_get(
<datetime>'2018-05-07T15:01:22.306916-05', 'decade');
''',
{201},
)
await self.assert_query_result(
r'''
SELECT datetime_get(
<datetime>'2018-05-07T15:01:22.306916-05', 'year');
''',
{2018},
)
await self.assert_query_result(
r'''
SELECT datetime_get(
<datetime>'2018-05-07T15:01:22.306916-05', 'month');
''',
{5},
)
await self.assert_query_result(
r'''
SELECT datetime_get(
<datetime>'2018-05-07T15:01:22.306916-05', 'day');
''',
{7},
)
await self.assert_query_result(
r'''
SELECT datetime_get(
<datetime>'2018-05-07T15:01:22.306916-05', 'hour');
''',
{20},
)
await self.assert_query_result(
r'''
SELECT datetime_get(
<datetime>'2018-05-07T15:01:22.306916-05', 'minutes');
''',
{1},
)
await self.assert_query_result(
r'''
SELECT datetime_get(
<datetime>'2018-05-07T15:01:22.306916-05', 'seconds');
''',
{22.306916},
)
await self.assert_query_result(
r'''
SELECT datetime_get(
<datetime>'2018-05-07T15:01:22.306916-05', 'epochseconds');
''',
{1525723282.306916},
) | ,
{3},
)
await self.assert_query_result(
r | test_edgeql_functions_datetime_get_01 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_datetime_get_02(self):
await self.assert_query_result(
r'''
SELECT datetime_get(
<cal::local_datetime>'2018-05-07T15:01:22.306916', 'year');
''',
{2018},
)
await self.assert_query_result(
r'''
SELECT datetime_get(
<cal::local_datetime>'2018-05-07T15:01:22.306916', 'month');
''',
{5},
)
await self.assert_query_result(
r'''
SELECT datetime_get(
<cal::local_datetime>'2018-05-07T15:01:22.306916', 'day');
''',
{7},
)
await self.assert_query_result(
r'''
SELECT datetime_get(
<cal::local_datetime>'2018-05-07T15:01:22.306916', 'hour');
''',
{15},
)
await self.assert_query_result(
r'''SELECT datetime_get(
<cal::local_datetime>'2018-05-07T15:01:22.306916', 'minutes');
''',
{1},
)
await self.assert_query_result(
r'''SELECT datetime_get(
<cal::local_datetime>'2018-05-07T15:01:22.306916', 'seconds');
''',
{22.306916},
) | ,
{2018},
)
await self.assert_query_result(
r | test_edgeql_functions_datetime_get_02 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_duration_get_01(self):
await self.assert_query_result(
r'''
select duration_get(
<duration>'15:01:22.306916', 'hour');
''',
{15},
)
await self.assert_query_result(
r'''
select duration_get(
<duration>'15:01:22.306916', 'minutes');
''',
{1},
)
await self.assert_query_result(
r'''
select duration_get(
<duration>'15:01:22.306916', 'seconds');
''',
{22.306916},
)
await self.assert_query_result(
r'''
select duration_get(
<duration>'15:01:22.306916', 'milliseconds');
''',
{22306.916},
)
await self.assert_query_result(
r'''
select duration_get(
<duration>'15:01:22.306916', 'microseconds');
''',
{22306916},
)
await self.assert_query_result(
r'''
select duration_get(
<duration>'15:01:22.306916', 'totalseconds');
''',
{54082.306916},
) | ,
{15},
)
await self.assert_query_result(
r | test_edgeql_functions_duration_get_01 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_duration_get_02(self):
await self.assert_query_result(
r'''
select duration_get(
<cal::relative_duration>'123 months', 'year');
''',
{10},
)
await self.assert_query_result(
r'''
select duration_get(
<cal::relative_duration>'123 months', 'month');
''',
{3},
)
await self.assert_query_result(
r'''
select duration_get(
<cal::relative_duration>'45 days', 'day');
''',
{45},
)
await self.assert_query_result(
r'''
select duration_get(
<cal::relative_duration>'15:01:22.306916', 'hour');
''',
{15},
)
await self.assert_query_result(
r'''
select duration_get(
<cal::relative_duration>'15:01:22.306916', 'minutes');
''',
{1},
)
await self.assert_query_result(
r'''
select duration_get(
<cal::relative_duration>'15:01:22.306916', 'seconds');
''',
{22.306916},
)
await self.assert_query_result(
r'''
select duration_get(
<cal::relative_duration>'15:01:22.306916', 'milliseconds'
);
''',
{22306.916},
)
await self.assert_query_result(
r'''
select duration_get(
<cal::relative_duration>'15:01:22.306916', 'microseconds'
);
''',
{22306916},
)
await self.assert_query_result(
r'''
select duration_get(
<cal::relative_duration>'15:01:22.306916', 'totalseconds'
);
''',
{54082.306916},
) | ,
{10},
)
await self.assert_query_result(
r | test_edgeql_functions_duration_get_02 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_duration_get_03(self):
await self.assert_query_result(
r'''
select duration_get(
<cal::date_duration>'123 months', 'year');
''',
{10},
)
await self.assert_query_result(
r'''
select duration_get(
<cal::date_duration>'123 months', 'month');
''',
{3},
)
await self.assert_query_result(
r'''
select duration_get(
<cal::date_duration>'45 days', 'day');
''',
{45},
)
await self.assert_query_result(
r'''
select duration_get(
<cal::date_duration>'13 months 12 days', 'day');
''',
{12},
)
await self.assert_query_result(
r'''
select duration_get(
<cal::date_duration>'2 days', 'totalseconds'
);
''',
{2 * 24 * 3600},
) | ,
{10},
)
await self.assert_query_result(
r | test_edgeql_functions_duration_get_03 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_datetime_trunc_01(self):
await self.assert_query_result(
r'''
SELECT <str>datetime_truncate(
<datetime>'2018-05-07T15:01:22.306916-05', 'years');
''',
{'2018-01-01T00:00:00+00:00'},
)
await self.assert_query_result(
r'''
SELECT <str>datetime_truncate(
<datetime>'2018-05-07T15:01:22.306916-05', 'decades');
''',
{'2010-01-01T00:00:00+00:00'},
)
await self.assert_query_result(
r'''
SELECT <str>datetime_truncate(
<datetime>'2018-05-07T15:01:22.306916-05', 'centuries');
''',
{'2001-01-01T00:00:00+00:00'},
)
await self.assert_query_result(
r'''
SELECT <str>datetime_truncate(
<datetime>'2018-05-07T15:01:22.306916-05', 'quarters');
''',
{'2018-04-01T00:00:00+00:00'},
)
await self.assert_query_result(
r'''
SELECT <str>datetime_truncate(
<datetime>'2018-05-07T15:01:22.306916-05', 'months');
''',
{'2018-05-01T00:00:00+00:00'},
)
await self.assert_query_result(
r'''
SELECT <str>datetime_truncate(
<datetime>'2018-05-07T15:01:22.306916-05', 'weeks');
''',
{'2018-05-07T00:00:00+00:00'},
)
await self.assert_query_result(
r'''
SELECT <str>datetime_truncate(
<datetime>'2018-05-07T15:01:22.306916-05', 'days');
''',
{'2018-05-07T00:00:00+00:00'},
)
await self.assert_query_result(
r'''
SELECT <str>datetime_truncate(
<datetime>'2018-05-07T15:01:22.306916-05', 'hours');
''',
{'2018-05-07T20:00:00+00:00'},
)
await self.assert_query_result(
r'''
SELECT <str>datetime_truncate(
<datetime>'2018-05-07T15:01:22.306916-05', 'minutes');
''',
{'2018-05-07T20:01:00+00:00'},
)
await self.assert_query_result(
r'''
SELECT <str>datetime_truncate(
<datetime>'2018-05-07T15:01:22.306916-05', 'seconds');
''',
{'2018-05-07T20:01:22+00:00'},
) | ,
{'2018-01-01T00:00:00+00:00'},
)
await self.assert_query_result(
r | test_edgeql_functions_datetime_trunc_01 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_duration_trunc_01(self):
await self.assert_query_result(
r'''
SELECT <str>duration_truncate(
<duration>'15:01:22.306916', 'hours');
''',
{'PT15H'},
)
await self.assert_query_result(
r'''
SELECT <str>duration_truncate(
<duration>'15:01:22.306916', 'minutes');
''',
{'PT15H1M'},
)
await self.assert_query_result(
r'''
SELECT <str>duration_truncate(
<duration>'15:01:22.306916', 'seconds');
''',
{'PT15H1M22S'},
)
await self.assert_query_result(
r'''
SELECT <str>duration_truncate(
<duration>'15:01:22.306916', 'milliseconds');
''',
{'PT15H1M22.306S'},
)
# Currently no-op but may be useful if precision is improved
await self.assert_query_result(
r'''
SELECT <str>duration_truncate(
<duration>'15:01:22.306916', 'microseconds');
''',
{'PT15H1M22.306916S'},
) | ,
{'PT15H'},
)
await self.assert_query_result(
r | test_edgeql_functions_duration_trunc_01 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_duration_trunc_03(self):
await self.assert_query_result(
r'''
SELECT <str>duration_truncate(
<cal::relative_duration>'P1312Y',
'centuries'
);
''',
{'P1300Y'},
)
await self.assert_query_result(
r'''
SELECT <str>duration_truncate(
<cal::relative_duration>'P1312Y',
'decades'
);
''',
{'P1310Y'},
)
await self.assert_query_result(
r'''
SELECT <str>duration_truncate(
cal::duration_normalize_days(
cal::duration_normalize_hours(
<cal::relative_duration>'PT15000H',
)
),
'years'
);
''',
{'P1Y'},
)
await self.assert_query_result(
r'''
SELECT <str>duration_truncate(
cal::duration_normalize_days(
cal::duration_normalize_hours(
<cal::relative_duration>'PT15000H'
)
),
'quarters'
);
''',
{'P1Y6M'},
)
await self.assert_query_result(
r'''
SELECT <str>duration_truncate(
cal::duration_normalize_days(
cal::duration_normalize_hours(
<cal::relative_duration>'PT15000H'
)
),
'months'
);
''',
{'P1Y8M'},
)
await self.assert_query_result(
r'''
SELECT <str>duration_truncate(
cal::duration_normalize_days(
cal::duration_normalize_hours(
<cal::relative_duration>'PT15000H'
)
),
'days'
);
''',
{'P1Y8M25D'},
)
await self.assert_query_result(
r'''
SELECT <str>duration_truncate(
<cal::relative_duration>'15:01:22.306916', 'hours');
''',
{'PT15H'},
)
await self.assert_query_result(
r'''
SELECT <str>duration_truncate(
<cal::relative_duration>'15:01:22.306916', 'minutes');
''',
{'PT15H1M'},
)
await self.assert_query_result(
r'''
SELECT <str>duration_truncate(
<cal::relative_duration>'15:01:22.306916', 'seconds');
''',
{'PT15H1M22S'},
)
await self.assert_query_result(
r'''
SELECT <str>duration_truncate(
<cal::relative_duration>'15:01:22.306916', 'milliseconds');
''',
{'PT15H1M22.306S'},
)
# Currently no-op but may be useful if precision is improved
await self.assert_query_result(
r'''
SELECT <str>duration_truncate(
<cal::relative_duration>'15:01:22.306916', 'microseconds');
''',
{'PT15H1M22.306916S'},
) | ,
{'P1300Y'},
)
await self.assert_query_result(
r | test_edgeql_functions_duration_trunc_03 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_duration_trunc_04(self):
await self.assert_query_result(
r'''
SELECT <str>duration_truncate(
<cal::date_duration>'P1312Y',
'centuries'
);
''',
{'P1300Y'},
)
await self.assert_query_result(
r'''
SELECT <str>duration_truncate(
<cal::date_duration>'P1312Y',
'decades'
);
''',
{'P1310Y'},
)
await self.assert_query_result(
r'''
SELECT <str>duration_truncate(
cal::duration_normalize_days(
<cal::date_duration>'P1312D'
),
'years'
);
''',
{'P3Y'},
)
await self.assert_query_result(
r'''
SELECT <str>duration_truncate(
cal::duration_normalize_days(
<cal::date_duration>'P1312D'
),
'quarters'
);
''',
{'P3Y6M'},
)
await self.assert_query_result(
r'''
SELECT <str>duration_truncate(
cal::duration_normalize_days(
<cal::date_duration>'P1312D'
),
'months'
);
''',
{'P3Y7M'},
)
await self.assert_query_result(
r'''
SELECT <str>duration_truncate(
cal::duration_normalize_days(
<cal::date_duration>'P1312D'
),
'days'
);
''',
{'P3Y7M22D'},
) | ,
{'P1300Y'},
)
await self.assert_query_result(
r | test_edgeql_functions_duration_trunc_04 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_to_datetime_01(self):
await self.assert_query_result(
r'''
SELECT <str>to_datetime(
2018, 5, 7, 15, 1, 22.306916, 'EST');
''',
['2018-05-07T20:01:22.306916+00:00'],
)
await self.assert_query_result(
r'''
SELECT <str>to_datetime(
2018, 5, 7, 15, 1, 22.306916, '-5');
''',
['2018-05-07T20:01:22.306916+00:00'],
)
with self.assertRaisesRegex(edgedb.InvalidValueError,
'"fmt" argument must be'):
async with self.con.transaction():
await self.con.query('SELECT to_datetime("2017-10-10", "")') | ,
['2018-05-07T20:01:22.306916+00:00'],
)
await self.assert_query_result(
r | test_edgeql_functions_to_datetime_01 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_to_datetime_03(self):
await self.assert_query_result(
r'''
SELECT
to_datetime('2019/01/01 00:00:00 0715',
'YYYY/MM/DD H24:MI:SS TZHTZM') =
<datetime>'2019-01-01T00:00:00+0715';
''',
[True],
)
await self.assert_query_result(
r'''
SELECT
to_datetime('2019/01/01 00:00:00 07TZM',
'YYYY/MM/DD H24:MI:SS TZH"TZM"') =
<datetime>'2019-01-01T00:00:00+07';
''',
[True],
)
await self.assert_query_result(
r'''
SELECT
to_datetime('2019/01/01 00:00:00 TZH07TZM',
'YYYY/MM/DD H24:MI:SS "TZH"TZH"TZM"') =
<datetime>'2019-01-01T00:00:00+07';
''',
[True],
)
with self.assertRaisesRegex(edgedb.InvalidValueError,
'missing required time zone in format'):
async with self.con.transaction():
await self.con.query(r'''
SELECT
to_datetime('2019/01/01 00:00:00 TZH07',
'YYYY/MM/DD H24:MI:SS "TZH"TZM') =
<datetime>'2019-01-01T00:00:00+07';
''') | ,
[True],
)
await self.assert_query_result(
r | test_edgeql_functions_to_datetime_03 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_to_datetime_06(self):
async with self.assertRaisesRegexTx(
edgedb.InvalidValueError,
'value out of range',
):
await self.con.query(r'''
SELECT to_datetime(10000, 1, 1, 1, 1, 1, 'UTC');
''')
async with self.assertRaisesRegexTx(
edgedb.InvalidValueError,
'value out of range',
):
await self.con.query(r'''
SELECT to_datetime(0, 1, 1, 1, 1, 1, 'UTC');
''')
async with self.assertRaisesRegexTx(
edgedb.InvalidValueError,
'value out of range',
):
await self.con.query(r'''
SELECT to_datetime(-1, 1, 1, 1, 1, 1, 'UTC');
''') | )
async with self.assertRaisesRegexTx(
edgedb.InvalidValueError,
'value out of range',
):
await self.con.query(r | test_edgeql_functions_to_datetime_06 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_to_local_datetime_03(self):
await self.assert_query_result(
# The time zone is ignored because the format string just
# specifies arbitrary characters in its place.
r'''
SELECT
cal::to_local_datetime('2019/01/01 00:00:00 0715',
'YYYY/MM/DD H24:MI:SS "NOTZ"') =
<cal::local_datetime>'2019-01-01T00:00:00';
''',
[True],
)
await self.assert_query_result(
# The time zone is ignored because the format string does
# not expect to parse it.
r'''
SELECT
cal::to_local_datetime('2019/01/01 00:00:00 0715',
'YYYY/MM/DD H24:MI:SS') =
<cal::local_datetime>'2019-01-01T00:00:00';
''',
[True],
) | ,
[True],
)
await self.assert_query_result(
# The time zone is ignored because the format string does
# not expect to parse it.
r | test_edgeql_functions_to_local_datetime_03 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_to_local_datetime_07(self):
async with self.assertRaisesRegexTx(
edgedb.InvalidValueError,
'value out of range',
):
await self.con.query(r'''
SELECT cal::to_local_datetime(10000, 1, 1, 1, 1, 1);
''')
async with self.assertRaisesRegexTx(
edgedb.InvalidValueError,
'value out of range',
):
await self.con.query(r'''
SELECT cal::to_local_datetime(0, 1, 1, 1, 1, 1);
''')
async with self.assertRaisesRegexTx(
edgedb.InvalidValueError,
'value out of range',
):
await self.con.query(r'''
SELECT cal::to_local_datetime(-1, 1, 1, 1, 1, 1);
''') | )
async with self.assertRaisesRegexTx(
edgedb.InvalidValueError,
'value out of range',
):
await self.con.query(r | test_edgeql_functions_to_local_datetime_07 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_to_local_date_05(self):
async with self.assertRaisesRegexTx(
edgedb.InvalidValueError,
'value out of range',
):
await self.con.query(r'''
SELECT cal::to_local_date(10000, 1, 1);
''')
async with self.assertRaisesRegexTx(
edgedb.InvalidValueError,
'value out of range',
):
await self.con.query(r'''
SELECT cal::to_local_date(0, 1, 1);
''')
async with self.assertRaisesRegexTx(
edgedb.InvalidValueError,
'value out of range',
):
await self.con.query(r'''
SELECT cal::to_local_date(-1, 1, 1);
''') | )
async with self.assertRaisesRegexTx(
edgedb.InvalidValueError,
'value out of range',
):
await self.con.query(r | test_edgeql_functions_to_local_date_05 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_to_str_01(self):
# at the very least the cast <str> should be equivalent to
# a call to to_str() without explicit format for simple scalars
await self.assert_query_result(
r'''
WITH DT := datetime_current()
# FIXME: the cast has a "T" and the str doesn't for some reason
SELECT <str>DT = to_str(DT);
''',
[True],
)
await self.assert_query_result(
r'''
WITH D := cal::to_local_date(datetime_current(), 'UTC')
SELECT <str>D = to_str(D);
''',
[True],
)
await self.assert_query_result(
r'''
WITH NT := cal::to_local_time(datetime_current(), 'UTC')
SELECT <str>NT = to_str(NT);
''',
[True],
)
await self.assert_query_result(
r'''SELECT <str>123 = to_str(123);''',
[True],
)
await self.assert_query_result(
r'''SELECT <str>123.456 = to_str(123.456);''',
[True],
)
await self.assert_query_result(
r'''SELECT <str>123.456e-20 = to_str(123.456e-20);''',
[True],
)
await self.assert_query_result(
r'''
SELECT <str><decimal>'123456789012345678901234567890.1234567890' =
to_str(123456789012345678901234567890.1234567890n);
''',
[True],
)
# Empty format string shouldn't produce an empty set.
#
with self.assertRaisesRegex(edgedb.InvalidValueError,
'"fmt" argument must be'):
async with self.con.transaction():
await self.con.query(r'''SELECT to_str(1, "")''')
with self.assertRaisesRegex(edgedb.InvalidValueError,
'"fmt" argument must be'):
async with self.con.transaction():
await self.con.query(r'''SELECT to_str(1.1, "")''')
with self.assertRaisesRegex(edgedb.InvalidValueError,
'"fmt" argument must be'):
async with self.con.transaction():
await self.con.query(r'''SELECT to_str(1.1n, "")''')
with self.assertRaisesRegex(edgedb.InvalidValueError,
'"fmt" argument must be'):
async with self.con.transaction():
await self.con.query(
r'''SELECT to_str(to_json('{}'), "")''') | ,
[True],
)
await self.assert_query_result(
r | test_edgeql_functions_to_str_01 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_to_str_02(self):
await self.assert_query_result(
r'''
WITH DT := <datetime>'2018-05-07 15:01:22.306916-05'
SELECT to_str(DT, 'YYYY-MM-DD');
''',
{'2018-05-07'},
)
await self.assert_query_result(
r'''
WITH DT := <datetime>'2018-05-07 15:01:22.306916-05'
SELECT to_str(DT, 'YYYYBC');
''',
{'2018AD'},
)
await self.assert_query_result(
r'''
WITH DT := <datetime>'2018-05-07 15:01:22.306916-05'
SELECT to_str(DT, 'FMDDth "of" FMMonth, YYYY');
''',
{'7th of May, 2018'},
)
await self.assert_query_result(
r'''
WITH DT := <datetime>'2018-05-07 15:01:22.306916-05'
SELECT to_str(DT, 'CCth "century"');
''',
{'21st century'},
)
await self.assert_query_result(
r'''
WITH DT := <datetime>'2018-05-07 15:01:22.306916-05'
SELECT to_str(DT, 'Y,YYY Month DD Day');
''',
{'2,018 May 07 Monday '},
)
await self.assert_query_result(
r'''
WITH DT := <datetime>'2018-05-07 15:01:22.306916-05'
SELECT to_str(DT, 'foo');
''',
{'foo'},
)
await self.assert_query_result(
r'''
WITH DT := <datetime>'2018-05-07 15:01:22.306916-05'
SELECT to_str(DT, ' ');
''',
{' '}
)
with self.assertRaisesRegex(edgedb.InvalidValueError,
'"fmt" argument must be'):
async with self.con.transaction():
await self.con.query(r'''
WITH DT := <datetime>'2018-05-07 15:01:22.306916-05'
SELECT to_str(DT, '');
''')
with self.assertRaisesRegex(edgedb.InvalidValueError,
'"fmt" argument must be'):
async with self.con.transaction():
await self.con.query(r'''
WITH DT := to_duration(hours:=20)
SELECT to_str(DT, '');
''') | ,
{'2018-05-07'},
)
await self.assert_query_result(
r | test_edgeql_functions_to_str_02 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_to_str_04(self):
await self.assert_query_result(
r'''
WITH DT := <cal::local_date>'2018-05-07'
SELECT to_str(DT, 'YYYY-MM-DD');
''',
{'2018-05-07'},
)
await self.assert_query_result(
r'''
WITH DT := <cal::local_date>'2018-05-07'
SELECT to_str(DT, 'YYYYBC');
''',
{'2018AD'},
)
await self.assert_query_result(
r'''
WITH DT := <cal::local_date>'2018-05-07'
SELECT to_str(DT, 'FMDDth "of" FMMonth, YYYY');
''',
{'7th of May, 2018'},
)
await self.assert_query_result(
r'''
WITH DT := <cal::local_date>'2018-05-07'
SELECT to_str(DT, 'CCth "century"');
''',
{'21st century'},
)
await self.assert_query_result(
r'''
WITH DT := <cal::local_date>'2018-05-07'
SELECT to_str(DT, 'Y,YYY Month DD Day');
''',
{'2,018 May 07 Monday '},
)
await self.assert_query_result(
r'''
# the format string doesn't have any special characters
WITH DT := <cal::local_date>'2018-05-07'
SELECT to_str(DT, 'foo');
''',
{'foo'},
)
with self.assertRaisesRegex(edgedb.InvalidValueError,
'"fmt" argument must be'):
async with self.con.transaction():
await self.con.query(r'''
WITH DT := <cal::local_time>'12:00:00'
SELECT to_str(DT, '');
''')
with self.assertRaisesRegex(edgedb.InvalidValueError,
'"fmt" argument must be'):
async with self.con.transaction():
await self.con.query(r'''
WITH DT := <cal::local_date>'2018-05-07'
SELECT to_str(DT, '');
''') | ,
{'2018-05-07'},
)
await self.assert_query_result(
r | test_edgeql_functions_to_str_04 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_int_bytes_conversion_02(self):
with self.assertRaisesRegex(
edgedb.InvalidValueError,
r'to_int16.*the argument must be exactly 2 bytes long',
):
async with self.con.transaction():
await self.con.execute(
r'''
SELECT to_int16(b'\x01', Endian.Big)
''',
)
with self.assertRaisesRegex(
edgedb.InvalidValueError,
r'to_int16.*the argument must be exactly 2 bytes long',
):
async with self.con.transaction():
await self.con.execute(
r'''
SELECT to_int16(
to_bytes(<int32>123, Endian.Big),
Endian.Big,
)
''',
) | ,
)
with self.assertRaisesRegex(
edgedb.InvalidValueError,
r'to_int16.*the argument must be exactly 2 bytes long',
):
async with self.con.transaction():
await self.con.execute(
r | test_edgeql_functions_int_bytes_conversion_02 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_int_bytes_conversion_03(self):
with self.assertRaisesRegex(
edgedb.InvalidValueError,
r'to_int32.*the argument must be exactly 4 bytes long',
):
async with self.con.transaction():
await self.con.execute(
r'''
SELECT to_int32(
to_bytes(<int16>23, Endian.Big),
Endian.Big,
)
''',
)
with self.assertRaisesRegex(
edgedb.InvalidValueError,
r'to_int32.*the argument must be exactly 4 bytes long',
):
async with self.con.transaction():
await self.con.execute(
r'''
SELECT to_int32(
to_bytes(<int64>16908295, Endian.Big),
Endian.Big,
)
''',
) | ,
)
with self.assertRaisesRegex(
edgedb.InvalidValueError,
r'to_int32.*the argument must be exactly 4 bytes long',
):
async with self.con.transaction():
await self.con.execute(
r | test_edgeql_functions_int_bytes_conversion_03 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_int_bytes_conversion_04(self):
with self.assertRaisesRegex(
edgedb.InvalidValueError,
r'to_int64.*the argument must be exactly 8 bytes long',
):
async with self.con.transaction():
await self.con.execute(
r'''
SELECT to_int64(
to_bytes(<int16>23, Endian.Big),
Endian.Big,
)
''',
)
with self.assertRaisesRegex(
edgedb.InvalidValueError,
r'to_int64.*the argument must be exactly 8 bytes long',
):
async with self.con.transaction():
await self.con.execute(
r'''
SELECT to_int64(
b'\x00' ++ to_bytes(62620574343574340, Endian.Big),
Endian.Big,
)
''',
) | ,
)
with self.assertRaisesRegex(
edgedb.InvalidValueError,
r'to_int64.*the argument must be exactly 8 bytes long',
):
async with self.con.transaction():
await self.con.execute(
r | test_edgeql_functions_int_bytes_conversion_04 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_uuid_bytes_conversion_02(self):
with self.assertRaisesRegex(
edgedb.InvalidValueError,
r'to_uuid.*the argument must be exactly 16 bytes long',
):
async with self.con.transaction():
await self.con.execute(
r'''
SELECT to_uuid(to_bytes(uuid_generate_v4())[:10])
''',
)
with self.assertRaisesRegex(
edgedb.InvalidValueError,
r'to_uuid.*the argument must be exactly 16 bytes long',
):
async with self.con.transaction():
await self.con.execute(
r'''
SELECT to_uuid(b'\xff\xff' ++ to_bytes(uuid_generate_v4()))
''',
) | ,
)
with self.assertRaisesRegex(
edgedb.InvalidValueError,
r'to_uuid.*the argument must be exactly 16 bytes long',
):
async with self.con.transaction():
await self.con.execute(
r | test_edgeql_functions_uuid_bytes_conversion_02 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_min_01(self):
await self.assert_query_result(
r'''SELECT min(<int64>{});''',
[],
)
await self.assert_query_result(
r'''SELECT min(4);''',
[4],
)
await self.assert_query_result(
r'''SELECT min({10, 20, -3, 4});''',
[-3],
)
await self.assert_query_result(
r'''SELECT min({10, 2.5, -3.1, 4});''',
[-3.1],
)
await self.assert_query_result(
r'''SELECT min({'10', '20', '-3', '4'});''',
['-3'],
)
await self.assert_query_result(
r'''SELECT min({'10', 'hello', 'world', '-3', '4'});''',
['-3'],
)
await self.assert_query_result(
r'''SELECT min({'hello', 'world'});''',
['hello'],
)
await self.assert_query_result(
r'''SELECT min({[1, 2], [3, 4]});''',
[[1, 2]],
)
await self.assert_query_result(
r'''SELECT min({[1, 2], [3, 4], <array<int64>>[]});''',
[[]],
)
await self.assert_query_result(
r'''SELECT min({[1, 2], [1, 0.4]});''',
[[1, 0.4]],
)
await self.assert_query_result(
r'''
SELECT <str>min(<datetime>{
'2018-05-07T15:01:22.306916-05',
'2017-05-07T16:01:22.306916-05',
'2017-01-07T11:01:22.306916-05',
'2018-01-07T11:12:22.306916-05',
});
''',
['2017-01-07T16:01:22.306916+00:00'],
)
await self.assert_query_result(
r'''
SELECT <str>min(<cal::local_datetime>{
'2018-05-07T15:01:22.306916',
'2017-05-07T16:01:22.306916',
'2017-01-07T11:01:22.306916',
'2018-01-07T11:12:22.306916',
});
''',
['2017-01-07T11:01:22.306916'],
)
await self.assert_query_result(
r'''
SELECT <str>min(<cal::local_date>{
'2018-05-07',
'2017-05-07',
'2017-01-07',
'2018-01-07',
});
''',
['2017-01-07'],
)
await self.assert_query_result(
r'''
SELECT <str>min(<cal::local_time>{
'15:01:22',
'16:01:22',
'11:01:22',
'11:12:22',
});
''',
['11:01:22'],
)
await self.assert_query_result(
r'''
SELECT <str>min(<duration>{
'15:01:22',
'16:01:22',
'11:01:22',
'11:12:22',
});
''',
['PT11H1M22S'],
) | ,
['2017-01-07T16:01:22.306916+00:00'],
)
await self.assert_query_result(
r | test_edgeql_functions_min_01 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_min_02(self):
await self.assert_query_result(
r'''
SELECT min(User.name);
''',
['Elvis'],
)
await self.assert_query_result(
r'''
SELECT min(Issue.time_estimate);
''',
[3000],
)
await self.assert_query_result(
r'''
SELECT min(<int64>Issue.number);
''',
[1],
) | ,
['Elvis'],
)
await self.assert_query_result(
r | test_edgeql_functions_min_02 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_max_01(self):
await self.assert_query_result(
r'''SELECT max(<int64>{});''',
[],
)
await self.assert_query_result(
r'''SELECT max(4);''',
[4],
)
await self.assert_query_result(
r'''SELECT max({10, 20, -3, 4});''',
[20],
)
await self.assert_query_result(
r'''SELECT max({10, 2.5, -3.1, 4});''',
[10],
)
await self.assert_query_result(
r'''SELECT max({'10', '20', '-3', '4'});''',
['4'],
)
await self.assert_query_result(
r'''SELECT max({'10', 'hello', 'world', '-3', '4'});''',
['world'],
)
await self.assert_query_result(
r'''SELECT max({'hello', 'world'});''',
['world'],
)
await self.assert_query_result(
r'''SELECT max({[1, 2], [3, 4]});''',
[[3, 4]],
)
await self.assert_query_result(
r'''SELECT max({[1, 2], [3, 4], <array<int64>>[]});''',
[[3, 4]],
)
await self.assert_query_result(
r'''SELECT max({[1, 2], [1, 0.4]});''',
[[1, 2]],
)
await self.assert_query_result(
r'''
SELECT <str>max(<datetime>{
'2018-05-07T15:01:22.306916-05',
'2017-05-07T16:01:22.306916-05',
'2017-01-07T11:01:22.306916-05',
'2018-01-07T11:12:22.306916-05',
});
''',
['2018-05-07T20:01:22.306916+00:00'],
)
await self.assert_query_result(
r'''
SELECT <str>max(<cal::local_datetime>{
'2018-05-07T15:01:22.306916',
'2017-05-07T16:01:22.306916',
'2017-01-07T11:01:22.306916',
'2018-01-07T11:12:22.306916',
});
''',
['2018-05-07T15:01:22.306916'],
)
await self.assert_query_result(
r'''
SELECT <str>max(<cal::local_date>{
'2018-05-07',
'2017-05-07',
'2017-01-07',
'2018-01-07',
});
''',
['2018-05-07'],
)
await self.assert_query_result(
r'''
SELECT <str>max(<cal::local_time>{
'15:01:22',
'16:01:22',
'11:01:22',
'11:12:22',
});
''',
['16:01:22'],
)
await self.assert_query_result(
r'''
SELECT <str>max(<duration>{
'15:01:22',
'16:01:22',
'11:01:22',
'11:12:22',
});
''',
['PT16H1M22S'],
) | ,
['2018-05-07T20:01:22.306916+00:00'],
)
await self.assert_query_result(
r | test_edgeql_functions_max_01 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_max_02(self):
await self.assert_query_result(
r'''
SELECT max(User.name);
''',
['Yury'],
)
await self.assert_query_result(
r'''
SELECT max(Issue.time_estimate);
''',
[3000],
)
await self.assert_query_result(
r'''
SELECT max(<int64>Issue.number);
''',
[4],
) | ,
['Yury'],
)
await self.assert_query_result(
r | test_edgeql_functions_max_02 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_all_02(self):
await self.assert_query_result(
r'''
SELECT all(len(User.name) = 4);
''',
[False],
)
await self.assert_query_result(
r'''
SELECT all(
(
FOR I IN {Issue}
UNION EXISTS I.time_estimate
)
);
''',
[False],
)
await self.assert_query_result(
r'''
SELECT all(Issue.number != '');
''',
[True],
) | ,
[False],
)
await self.assert_query_result(
r | test_edgeql_functions_all_02 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_any_02(self):
await self.assert_query_result(
r'''
SELECT any(len(User.name) = 4);
''',
[True],
)
await self.assert_query_result(
r'''
SELECT any(
(
FOR I IN {Issue}
UNION EXISTS I.time_estimate
)
);
''',
[True],
)
await self.assert_query_result(
r'''
SELECT any(Issue.number != '');
''',
[True],
) | ,
[True],
)
await self.assert_query_result(
r | test_edgeql_functions_any_02 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_any_03(self):
await self.assert_query_result(
r'''
SELECT any(len(User.name) = 4) =
NOT all(NOT (len(User.name) = 4));
''',
[True],
)
await self.assert_query_result(
r'''
SELECT any(
(
FOR I IN {Issue}
UNION EXISTS I.time_estimate
)
) = NOT all(
(
FOR I IN {Issue}
UNION NOT EXISTS I.time_estimate
)
);
''',
[True],
)
await self.assert_query_result(
r'''
SELECT any(Issue.number != '') = NOT all(Issue.number = '');
''',
[True],
) | ,
[True],
)
await self.assert_query_result(
r | test_edgeql_functions_any_03 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_round_04(self):
await self.assert_query_result(
r'''
SELECT _ := round(<int64>Issue.number / 2)
ORDER BY _;
''',
[0, 1, 2, 2],
)
await self.assert_query_result(
r'''
SELECT _ := round(<decimal>Issue.number / 2)
ORDER BY _;
''',
[1, 1, 2, 2],
) | ,
[0, 1, 2, 2],
)
await self.assert_query_result(
r | test_edgeql_functions_round_04 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_contains_02(self):
await self.assert_query_result(
r'''
WITH x := [3, 1, 2]
SELECT contains(x, 2);
''',
[True],
)
await self.assert_query_result(
r'''
WITH x := [3, 1, 2]
SELECT contains(x, 5);
''',
[False],
)
await self.assert_query_result(
r'''
WITH x := [3, 1, 2]
SELECT contains(x, 5);
''',
[False],
) | ,
[True],
)
await self.assert_query_result(
r | test_edgeql_functions_contains_02 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_find_03(self):
await self.assert_query_result(
r'''SELECT find(<array<str>>{}, <str>{});''',
[],
)
await self.assert_query_result(
r'''SELECT find(<array<str>>{}, 'the');''',
[],
)
await self.assert_query_result(
r'''SELECT find(['the', 'quick', 'brown', 'fox'], <str>{});''',
[],
)
await self.assert_query_result(
r'''SELECT find(<array<str>>[], 'the');''',
{-1},
)
await self.assert_query_result(
r'''SELECT find(['the', 'quick', 'brown', 'fox'], 'the');''',
{0},
)
await self.assert_query_result(
r'''SELECT find(['the', 'quick', 'brown', 'fox'], 'fox');''',
{3},
)
await self.assert_query_result(
r'''SELECT find(['the', 'quick', 'brown', 'fox'], 'jumps');''',
{-1},
)
await self.assert_query_result(
r'''
SELECT find(['the', 'quick', 'brown', 'fox',
'jumps', 'over', 'the', 'lazy', 'dog'],
'the');
''',
{0},
)
await self.assert_query_result(
r'''
SELECT find(['the', 'quick', 'brown', 'fox',
'jumps', 'over', 'the', 'lazy', 'dog'],
'the', 1);
''',
{6},
) | ,
{0},
)
await self.assert_query_result(
r | test_edgeql_functions_find_03 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_str_pad_03(self):
await self.assert_query_result(
r'''
FOR l IN {0, 2, 10, 20}
SELECT len(str_pad_start('Hello', l)) = l;
''',
[True, True, True, True],
)
await self.assert_query_result(
r'''
FOR l IN {0, 2, 10, 20}
SELECT len(str_pad_end('Hello', l)) = l;
''',
[True, True, True, True],
) | ,
[True, True, True, True],
)
await self.assert_query_result(
r | test_edgeql_functions_str_pad_03 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_math_mean_08(self):
await self.assert_query_result(
r'''
WITH
MODULE math,
X := {1, 2, 3, 4}
SELECT mean(X) = sum(X) / count(X);
''',
{True},
)
await self.assert_query_result(
r'''
WITH
MODULE math,
X := {0.1, 0.2, 0.3, 0.4}
SELECT mean(X) = sum(X) / count(X);
''',
{True},
) | ,
{True},
)
await self.assert_query_result(
r | test_edgeql_functions_math_mean_08 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_math_var_03(self):
await self.assert_query_result(
r'''
WITH
MODULE math,
X := {1, 1}
SELECT var(X) = stddev(X) ^ 2;
''',
{True},
)
await self.assert_query_result(
r'''
WITH
MODULE math,
X := {1, 1, -1, 1}
SELECT var(X) = stddev(X) ^ 2;
''',
{True},
)
await self.assert_query_result(
r'''
WITH
MODULE math,
X := {1, 2, 3}
SELECT var(X) = stddev(X) ^ 2;
''',
{True},
)
await self.assert_query_result(
r'''
WITH
MODULE math,
X := {0.1, 0.1, -0.1, 0.1}
SELECT var(X) = stddev(X) ^ 2;
''',
{True},
)
await self.assert_query_result(
r'''
WITH
MODULE math,
X := <decimal>{0.1, 0.2, 0.3}
SELECT var(X) = stddev(X) ^ 2;
''',
{True},
) | ,
{True},
)
await self.assert_query_result(
r | test_edgeql_functions_math_var_03 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_math_var_pop_03(self):
await self.assert_query_result(
r'''
WITH
MODULE math,
X := {1, 2, 1, 2}
SELECT abs(var_pop(X) - stddev_pop(X) ^ 2) < 1.0e-15;
''',
{True},
)
await self.assert_query_result(
r'''
WITH
MODULE math,
X := {0.1, 0.2, 0.1, 0.2}
SELECT abs(var_pop(X) - stddev_pop(X) ^ 2) < 1.0e-15;
''',
{True},
) | ,
{True},
)
await self.assert_query_result(
r | test_edgeql_functions_math_var_pop_03 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_math_atan2_01(self):
await self.assert_query_result(
r'''SELECT math::atan2(-0.0, -1);''',
{-math.pi},
abs_tol=0.0000000005,
)
await self.assert_query_result(
r'''SELECT math::atan2(-2, -2);''',
{-math.pi * 3 / 4},
abs_tol=0.0000000005,
)
await self.assert_query_result(
r'''SELECT math::atan2(-3, -0.0);''',
{-math.pi / 2},
abs_tol=0.0000000005,
)
await self.assert_query_result(
r'''SELECT math::atan2(-4, 0.0);''',
{-math.pi / 2},
abs_tol=0.0000000005,
)
await self.assert_query_result(
r'''SELECT math::atan2(-5, 5);''',
{-math.pi / 4},
abs_tol=0.0000000005,
)
await self.assert_query_result(
r'''WITH x := math::atan2(-0.0, 6) SELECT (x, <str>x);''',
[[-0.0, '-0']],
)
await self.assert_query_result(
r'''WITH x := math::atan2(0.0, 6) SELECT (x, <str>x);''',
[[0.0, '0']],
)
await self.assert_query_result(
r'''SELECT math::atan2(8, 8);''',
{math.pi / 4},
abs_tol=0.0000000005,
)
await self.assert_query_result(
r'''SELECT math::atan2(9, 0.0);''',
{math.pi / 2},
abs_tol=0.0000000005,
)
await self.assert_query_result(
r'''SELECT math::atan2(10, -0.0);''',
{math.pi / 2},
abs_tol=0.0000000005,
)
await self.assert_query_result(
r'''SELECT math::atan2(11, -11);''',
{math.pi * 3 / 4},
abs_tol=0.0000000005,
)
await self.assert_query_result(
r'''SELECT math::atan2(0.0, -12);''',
{math.pi},
abs_tol=0.0000000005,
)
await self.assert_query_result(
r'''SELECT math::atan2(-0.0, -0.0);''',
{-math.pi},
abs_tol=0.0000000005,
)
await self.assert_query_result(
r'''WITH x := math::atan2(-0.0, 0.0) SELECT (x, <str>x);''',
[[-0.0, '-0']],
)
await self.assert_query_result(
r'''WITH x := math::atan2(0.0, 0.0) SELECT (x, <str>x);''',
[[0.0, '0']],
)
await self.assert_query_result(
r'''SELECT math::atan2(0.0, -0.0);''',
{math.pi},
abs_tol=0.0000000005,
)
await self.assert_query_result(
r'''SELECT math::atan2(-0.0, -<float64>"inf");''',
{-math.pi},
abs_tol=0.0000000005,
)
await self.assert_query_result(
r'''SELECT math::atan2(-<float64>"inf", -<float64>"inf");''',
{-math.pi * 3 / 4},
abs_tol=0.0000000005,
)
await self.assert_query_result(
r'''SELECT math::atan2(-<float64>"inf", -0.0);''',
{-math.pi / 2},
abs_tol=0.0000000005,
)
await self.assert_query_result(
r'''SELECT math::atan2(-<float64>"inf", 0.0);''',
{-math.pi / 2},
abs_tol=0.0000000005,
)
await self.assert_query_result(
r'''SELECT math::atan2(-<float64>"inf", <float64>"inf");''',
{-math.pi / 4},
abs_tol=0.0000000005,
)
await self.assert_query_result(
r'''
WITH x := math::atan2(-0.0, <float64>"inf")
SELECT (x, <str>x);
''',
[[-0.0, '-0']],
)
await self.assert_query_result(
r'''
WITH x := math::atan2(0.0, <float64>"inf")
SELECT (x, <str>x);
''',
[[0.0, '0']],
)
await self.assert_query_result(
r'''SELECT math::atan2(<float64>"inf", <float64>"inf");''',
{math.pi / 4},
abs_tol=0.0000000005,
)
await self.assert_query_result(
r'''SELECT math::atan2(<float64>"inf", 0.0);''',
{math.pi / 2},
abs_tol=0.0000000005,
)
await self.assert_query_result(
r'''SELECT math::atan2(<float64>"inf", -0.0);''',
{math.pi / 2},
abs_tol=0.0000000005,
)
await self.assert_query_result(
r'''SELECT math::atan2(<float64>"inf", -<float64>"inf");''',
{math.pi * 3 / 4},
abs_tol=0.0000000005,
)
await self.assert_query_result(
r'''SELECT math::atan2(0.0, -<float64>"inf");''',
{math.pi},
abs_tol=0.0000000005,
)
await self.assert_query_result(
r'''SELECT <str>math::atan2(<float64>"NaN", 1);''',
{"NaN"},
)
await self.assert_query_result(
r'''SELECT <str>math::atan2(1, <float64>"NaN");''',
{"NaN"},
)
await self.assert_query_result(
r'''SELECT <str>math::atan2(<float64>"NaN", <float64>"NaN");''',
{"NaN"},
) | ,
[[-0.0, '-0']],
)
await self.assert_query_result(
r | test_edgeql_functions_math_atan2_01 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions__genseries_01(self):
await self.assert_query_result(
r'''
SELECT _gen_series(1, 10)
''',
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
)
await self.assert_query_result(
r'''
SELECT _gen_series(1, 10, 2)
''',
[1, 3, 5, 7, 9]
)
await self.assert_query_result(
r'''
SELECT _gen_series(1n, 10n)
''',
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
)
await self.assert_query_result(
r'''
SELECT _gen_series(1n, 10n, 2n)
''',
[1, 3, 5, 7, 9]
) | ,
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
)
await self.assert_query_result(
r | test_edgeql_functions__genseries_01 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_sequence_next_reset(self):
await self.con.execute('''
CREATE SCALAR TYPE my_seq_01 EXTENDING std::sequence;
''')
result = await self.con.query_single('''
SELECT sequence_next(INTROSPECT my_seq_01)
''')
self.assertEqual(result, 1)
result = await self.con.query_single('''
SELECT sequence_next(INTROSPECT my_seq_01)
''')
self.assertEqual(result, 2)
await self.con.execute('''
SELECT sequence_reset(INTROSPECT my_seq_01)
''')
result = await self.con.query_single('''
SELECT sequence_next(INTROSPECT my_seq_01)
''')
self.assertEqual(result, 1)
await self.con.execute('''
SELECT sequence_reset(INTROSPECT my_seq_01, 20)
''')
result = await self.con.query_single('''
SELECT sequence_next(INTROSPECT my_seq_01)
''')
self.assertEqual(result, 21) | )
result = await self.con.query_single( | test_edgeql_functions_sequence_next_reset | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions__datetime_range_buckets(self):
await self.assert_query_result(
'''
SELECT <tuple<str, str>>std::_datetime_range_buckets(
<datetime>'2021-01-01T00:00:00Z',
<datetime>'2021-04-01T00:00:00Z',
'1 month');
''',
[
('2021-01-01T00:00:00+00:00', '2021-02-01T00:00:00+00:00'),
('2021-02-01T00:00:00+00:00', '2021-03-01T00:00:00+00:00'),
('2021-03-01T00:00:00+00:00', '2021-04-01T00:00:00+00:00'),
],
)
await self.assert_query_result(
'''
SELECT <tuple<str, str>>std::_datetime_range_buckets(
<datetime>'2021-04-01T00:00:00Z',
<datetime>'2021-04-01T00:00:00Z',
'1 month');
''',
[],
)
await self.assert_query_result(
'''
SELECT <tuple<str, str>>std::_datetime_range_buckets(
<datetime>'2021-01-01T00:00:00Z',
<datetime>'2021-04-01T00:00:00Z',
'1.5 months');
''',
[
('2021-01-01T00:00:00+00:00', '2021-02-16T00:00:00+00:00'),
('2021-02-16T00:00:00+00:00', '2021-03-31T00:00:00+00:00'),
],
) | SELECT <tuple<str, str>>std::_datetime_range_buckets(
<datetime>'2021-01-01T00:00:00Z',
<datetime>'2021-04-01T00:00:00Z',
'1 month');
''',
[
('2021-01-01T00:00:00+00:00', '2021-02-01T00:00:00+00:00'),
('2021-02-01T00:00:00+00:00', '2021-03-01T00:00:00+00:00'),
('2021-03-01T00:00:00+00:00', '2021-04-01T00:00:00+00:00'),
],
)
await self.assert_query_result( | test_edgeql_functions__datetime_range_buckets | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_bitwise_05(self):
with self.assertRaisesRegex(
edgedb.InvalidValueError,
r"bit_lshift.*: cannot shift by negative amount"):
async with self.con.transaction():
await self.con.query(r'''
select bit_lshift(<int16>5, -2);
''')
with self.assertRaisesRegex(
edgedb.InvalidValueError,
r"bit_lshift.*: cannot shift by negative amount"):
async with self.con.transaction():
await self.con.query(r'''
select bit_lshift(<int32>5, -2);
''')
with self.assertRaisesRegex(
edgedb.InvalidValueError,
r"bit_lshift.*: cannot shift by negative amount"):
async with self.con.transaction():
await self.con.query(r'''
select bit_lshift(<int64>5, -2);
''')
with self.assertRaisesRegex(
edgedb.InvalidValueError,
r"bit_rshift.*: cannot shift by negative amount"):
async with self.con.transaction():
await self.con.query(r'''
select bit_rshift(<int16>5, -2);
''')
with self.assertRaisesRegex(
edgedb.InvalidValueError,
r"bit_rshift.*: cannot shift by negative amount"):
async with self.con.transaction():
await self.con.query(r'''
select bit_rshift(<int32>5, -2);
''')
with self.assertRaisesRegex(
edgedb.InvalidValueError,
r"bit_rshift.*: cannot shift by negative amount"):
async with self.con.transaction():
await self.con.query(r'''
select bit_rshift(<int64>5, -2);
''') | )
with self.assertRaisesRegex(
edgedb.InvalidValueError,
r"bit_lshift.*: cannot shift by negative amount"):
async with self.con.transaction():
await self.con.query(r | test_edgeql_functions_bitwise_05 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_range_unpack_03(self):
# Test `range_unpack` for numeric ranges with both exclusive
# boundaries.
for st in ['int32', 'int64']:
await self.assert_query_result(
f'''
select range_unpack(
range(<{st}>1, <{st}>11,
inc_lower := false,
inc_upper := false),
<{st}>3
);
''',
[2, 5, 8],
)
for st in ['float32', 'float64', 'decimal']:
await self.assert_query_result(
f'''
select range_unpack(
range(<{st}>1, <{st}>10,
inc_lower := false,
inc_upper := false),
<{st}>3
);
''',
[4, 7],
) | ,
[2, 5, 8],
)
for st in ['float32', 'float64', 'decimal']:
await self.assert_query_result(
f | test_edgeql_functions_range_unpack_03 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_range_unpack_06(self):
# Test `range_unpack` of empty ranges.
for st in ['int32', 'int64', 'float32', 'float64', 'decimal']:
await self.assert_query_result(
f'''
select range_unpack(
range(<{st}>{{}}, empty := true), <{st}>1);
''',
[],
)
await self.assert_query_result(
r'''
select range_unpack(
range(<datetime>{}, empty := true), <duration>'36:00:00');
''',
[],
)
await self.assert_query_result(
r'''
select range_unpack(
range(<cal::local_datetime>{}, empty := true),
<cal::relative_duration>'36:00:00');
''',
[],
)
await self.assert_query_result(
r'''
select range_unpack(
range(<cal::local_date>{}, empty := true));
''',
[],
) | ,
[],
)
await self.assert_query_result(
r | test_edgeql_functions_range_unpack_06 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_functions_range_unpack_07(self):
# Test errors for `range_unpack`.
for st in ['int32', 'int64', 'float32', 'float64', 'decimal']:
async with self.assertRaisesRegexTx(
edgedb.InvalidValueError,
"cannot unpack an unbounded range",
):
await self.con.execute(f"""
select range_unpack(
range(<{st}>5), <{st}>1);
""")
async with self.assertRaisesRegexTx(
edgedb.InvalidValueError,
"cannot unpack an unbounded range",
):
await self.con.execute(f"""
select range_unpack(
range(<{st}>{{}}, <{st}>5), <{st}>1);
""")
async with self.assertRaisesRegexTx(
edgedb.InvalidValueError,
"cannot unpack an unbounded range",
):
await self.con.execute(r"""
select range_unpack(
range(<datetime>'2022-06-01T07:00:00Z'),
<duration>'36:00:00');
""")
async with self.assertRaisesRegexTx(
edgedb.InvalidValueError,
"cannot unpack an unbounded range",
):
await self.con.execute(r"""
select range_unpack(
range(<datetime>{}, <datetime>'2022-06-01T07:00:00Z'),
<duration>'36:00:00');
""")
async with self.assertRaisesRegexTx(
edgedb.InvalidValueError,
"cannot unpack an unbounded range",
):
await self.con.execute(r"""
select range_unpack(
range(<cal::local_datetime>'2022-06-01T07:00:00'),
<cal::relative_duration>'36:00:00');
""")
async with self.assertRaisesRegexTx(
edgedb.InvalidValueError,
"cannot unpack an unbounded range",
):
await self.con.execute(r"""
select range_unpack(
range(<cal::local_datetime>{},
<cal::local_datetime>'2022-06-01T07:00:00'),
<cal::relative_duration>'36:00:00');
""")
async with self.assertRaisesRegexTx(
edgedb.InvalidValueError,
"cannot unpack an unbounded range",
):
await self.con.execute(r"""
select range_unpack(
range(<cal::local_date>'2022-06-01'));
""")
async with self.assertRaisesRegexTx(
edgedb.InvalidValueError,
"cannot unpack an unbounded range",
):
await self.con.execute(r"""
select range_unpack(
range(<cal::local_date>{},
<cal::local_date>'2022-06-01'));
""") | )
async with self.assertRaisesRegexTx(
edgedb.InvalidValueError,
"cannot unpack an unbounded range",
):
await self.con.execute(f | test_edgeql_functions_range_unpack_07 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test_edgeql_call_type_as_function_01(self):
async with self.assertRaisesRegexTx(
edgedb.errors.InvalidReferenceError,
"does not exist",
_hint="did you mean to cast to 'str'?",
):
await self.con.execute(f"""
select str(1);
""")
async with self.assertRaisesRegexTx(
edgedb.errors.InvalidReferenceError,
"does not exist",
_hint="did you mean to cast to 'int32'?",
):
await self.con.execute(f"""
select int32(1);
""")
async with self.assertRaisesRegexTx(
edgedb.errors.InvalidReferenceError,
"does not exist",
_hint="did you mean to cast to 'std::cal::local_date'?",
):
await self.con.execute(f"""
select cal::local_date(1);
""") | )
async with self.assertRaisesRegexTx(
edgedb.errors.InvalidReferenceError,
"does not exist",
_hint="did you mean to cast to 'int32'?",
):
await self.con.execute(f | test_edgeql_call_type_as_function_01 | python | geldata/gel | tests/test_edgeql_functions.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_functions.py | Apache-2.0 |
async def test(pgdata_path):
async with tb.start_edgedb_server(
max_allowed_connections=None,
backend_dsn=f'postgres:///?user=postgres&host={pgdata_path}',
reset_auth=True,
runstate_dir=None if devmode.is_in_dev_mode() else pgdata_path,
) as sd:
con = await sd.connect()
try:
max_connections = await con.query_single(
'''
SELECT cfg::InstanceConfig.__pg_max_connections
LIMIT 1
'''
) # TODO: remove LIMIT 1 after #2402
self.assertEqual(int(max_connections), actual)
finally:
await con.aclose() | SELECT cfg::InstanceConfig.__pg_max_connections
LIMIT 1 | test_server_ops_detect_postgres_pool_size.test | python | geldata/gel | tests/test_server_ops.py | https://github.com/geldata/gel/blob/master/tests/test_server_ops.py | Apache-2.0 |
async def test_server_ops_detect_postgres_pool_size(self):
actual = random.randint(50, 100)
async def test(pgdata_path):
async with tb.start_edgedb_server(
max_allowed_connections=None,
backend_dsn=f'postgres:///?user=postgres&host={pgdata_path}',
reset_auth=True,
runstate_dir=None if devmode.is_in_dev_mode() else pgdata_path,
) as sd:
con = await sd.connect()
try:
max_connections = await con.query_single(
'''
SELECT cfg::InstanceConfig.__pg_max_connections
LIMIT 1
'''
) # TODO: remove LIMIT 1 after #2402
self.assertEqual(int(max_connections), actual)
finally:
await con.aclose()
with tempfile.TemporaryDirectory() as td:
cluster = await pgcluster.get_local_pg_cluster(
td, max_connections=actual, log_level='s')
cluster.update_connection_params(
user='postgres',
database='template1',
)
self.assertTrue(await cluster.ensure_initialized())
await cluster.start()
try:
await test(td)
finally:
await cluster.stop() | SELECT cfg::InstanceConfig.__pg_max_connections
LIMIT 1 | test_server_ops_detect_postgres_pool_size | python | geldata/gel | tests/test_server_ops.py | https://github.com/geldata/gel/blob/master/tests/test_server_ops.py | Apache-2.0 |
async def test_server_ops_cache_recompile_01(self):
def measure_compilations(
sd: tb._EdgeDBServerData
) -> Callable[[], float | int]:
return lambda: tb.parse_metrics(sd.fetch_metrics()).get(
'edgedb_server_edgeql_query_compilations_total'
'{tenant="localtest",path="compiler"}'
) or 0
def measure_sql_compilations(
sd: tb._EdgeDBServerData
) -> Callable[[], float | int]:
return lambda: tb.parse_metrics(sd.fetch_metrics()).get(
'edgedb_server_sql_compilations_total'
'{tenant="localtest"}'
) or 0
with tempfile.TemporaryDirectory() as temp_dir:
async with tb.start_edgedb_server(
data_dir=temp_dir,
default_auth_method=args.ServerAuthMethod.Trust,
net_worker_mode='disabled',
) as sd:
con = await sd.connect()
try:
qry = 'select schema::Object { name }'
sql = '''
SELECT
n.nspname::text AS table_schema,
c.relname::text AS table_name,
CASE
WHEN c.relkind = 'r' THEN 'table'
WHEN c.relkind = 'v' THEN 'view'
WHEN c.relkind = 'm' THEN 'materialized_view'
END AS type,
c.relrowsecurity AS rls_enabled
FROM
pg_catalog.pg_class c
JOIN
pg_catalog.pg_namespace n
ON n.oid::text = c.relnamespace::text
WHERE
c.relkind IN ('r', 'v', 'm')
AND n.nspname = 'public';
'''
await con.query(qry)
await con.query_sql(sql)
# Querying a second time should hit the cache
with self.assertChange(measure_compilations(sd), 0):
await con.query(qry)
with self.assertChange(measure_sql_compilations(sd), 0):
await con.query_sql(sql)
await con.query('''
create type X
''')
# We should have recompiled the cache when we created
# the type, so doing the query shouldn't cause another
# compile!
with self.assertChange(measure_compilations(sd), 0):
await con.query(qry)
with self.assertChange(measure_compilations(sd), 0):
await con.query(qry)
# The SQL cache is reset after DDL, because recompiling SQL
# requires backend connection for amending in/out tids, and
# we don't have the infra for that yet.
with self.assertChange(measure_sql_compilations(sd), 1):
await con.query_sql(sql)
with self.assertChange(measure_sql_compilations(sd), 0):
await con.query_sql(sql)
# TODO: this does not behave the way I thing it should
# with self.assertChange(measure_compilations(sd), 1):
# con_c = con.with_config(apply_access_policies=False)
# await con_c.query(qry)
# Set the compilation timeout to 2ms.
#
# This should prevent recompilation from
# succeeding. If we ever make the compiler fast
# enough, we might need to change this :)
#
# We do 2ms instead of 1ms or something even smaller
# because uvloop's timer has ms granularity, and
# setting it to 2ms should typically ensure that it
# manages to start the compilation.
await con.execute(
"configure current database "
"set auto_rebuild_query_cache_timeout := "
"<duration>'2ms'"
)
await con.query('''
drop type X
''')
await con.query('''
create global g: str;
''')
with self.assertChange(measure_compilations(sd), 1):
await con.query(qry)
with self.assertChange(measure_compilations(sd), 0):
await con.query(qry)
with self.assertChange(measure_sql_compilations(sd), 1):
await con.query_sql(sql)
with self.assertChange(measure_sql_compilations(sd), 0):
await con.query_sql(sql)
await con.execute(
"configure current database "
"reset auto_rebuild_query_cache_timeout"
)
# Now, a similar thing for SQL queries
with self.assertChange(measure_sql_compilations(sd), 1):
await con.query_sql('select 1')
# cache hit
with self.assertChange(measure_sql_compilations(sd), 0):
await con.query_sql('select 1')
# changing globals: cache hit
with self.assertChange(measure_sql_compilations(sd), 0):
con_g = con.with_globals({'g': 'hello'})
await con_g.query_sql('select 1')
# normalization: pg_query_normalize is underwhelming
with self.assertChange(measure_sql_compilations(sd), 1):
await con.query_sql('sElEct 1')
# constant extraction: cache hit
with self.assertChange(measure_sql_compilations(sd), 0):
await con.query_sql('select 2')
# TODO: this does not behave the way I though it should
# changing certain config options: compiler call
# with self.assertChange(measure_compilations(sd), 1):
# con_c = con.with_config(apply_access_policies=False)
# await con_c.query_sql(qry_sql)
# At last, make sure recompilation switch works fine
await con.execute(
"configure current database "
"set auto_rebuild_query_cache := false"
)
await con.query('''
create type X
''')
with self.assertChange(measure_compilations(sd), 1):
await con.query(qry)
with self.assertChange(measure_compilations(sd), 0):
await con.query(qry)
with self.assertChange(measure_sql_compilations(sd), 1):
await con.query_sql(sql)
with self.assertChange(measure_sql_compilations(sd), 0):
await con.query_sql(sql)
await con.execute(
"configure current database "
"reset auto_rebuild_query_cache"
)
finally:
await con.aclose()
has_asyncpg = True
try:
import asyncpg # noqa
except ImportError:
has_asyncpg = False
if has_asyncpg:
scon = await sd.connect_pg()
try:
with self.assertChange(measure_sql_compilations(sd), 1):
await scon.fetch('select 1')
with self.assertChange(measure_sql_compilations(sd), 1):
await scon.fetch('select 1 + 1')
# cache hit
with self.assertChange(measure_sql_compilations(sd), 0):
await scon.fetch('select 1')
# cache hit because of query normalization
with self.assertChange(measure_sql_compilations(sd), 0):
await scon.fetch('select 2')
# TODO: better normalization
with self.assertChange(measure_sql_compilations(sd), 1):
await scon.fetch('sELEcT 1')
# cache hit, even after global has been changed
await scon.execute('SET "global default::g" to 1')
with self.assertChange(measure_sql_compilations(sd), 0):
await scon.execute('select 1')
# compiler call, because config was changed
await scon.execute('SET apply_access_policies_pg to 1')
with self.assertChange(measure_sql_compilations(sd), 1):
await scon.execute('select 1')
finally:
await scon.close()
# Now restart the server to test the cache persistence.
async with tb.start_edgedb_server(
data_dir=temp_dir,
default_auth_method=args.ServerAuthMethod.Trust,
net_worker_mode='disabled',
) as sd:
con = await sd.connect()
try:
# It should hit the cache no problem.
with self.assertChange(measure_compilations(sd), 0):
await con.query(qry)
# TODO(fantix): persistent SQL cache not working?
# with self.assertChange(measure_sql_compilation(sd), 0):
# await con.query_sql(sql)
finally:
await con.aclose() | await con.query(qry)
await con.query_sql(sql)
# Querying a second time should hit the cache
with self.assertChange(measure_compilations(sd), 0):
await con.query(qry)
with self.assertChange(measure_sql_compilations(sd), 0):
await con.query_sql(sql)
await con.query( | test_server_ops_cache_recompile_01 | python | geldata/gel | tests/test_server_ops.py | https://github.com/geldata/gel/blob/master/tests/test_server_ops.py | Apache-2.0 |
async def test_server_ops_schema_metrics_01(self):
def _extkey(extension: str) -> str:
return (
f'edgedb_server_extension_used_branch_count_current'
f'{{tenant="localtest",extension="{extension}"}}'
)
def _featkey(feature: str) -> str:
return (
f'edgedb_server_feature_used_branch_count_current'
f'{{tenant="localtest",feature="{feature}"}}'
)
async with tb.start_edgedb_server(
default_auth_method=args.ServerAuthMethod.Trust,
net_worker_mode='disabled',
force_new=True,
) as sd:
con = await sd.connect()
con2 = None
try:
metrics = tb.parse_metrics(sd.fetch_metrics())
self.assertEqual(metrics.get(_extkey('graphql'), 0), 0)
self.assertEqual(metrics.get(_extkey('pg_trgm'), 0), 0)
self.assertEqual(metrics.get(_featkey('function'), 0), 0)
await con.execute('create extension graphql')
await con.execute('create extension pg_trgm')
metrics = tb.parse_metrics(sd.fetch_metrics())
self.assertEqual(metrics.get(_extkey('graphql'), 0), 1)
self.assertEqual(metrics.get(_extkey('pg_trgm'), 0), 1)
# The innards of extensions shouldn't be counted in
# feature use metrics. (pg_trgm has functions.)
self.assertEqual(metrics.get(_featkey('function'), 0), 0)
await con.execute('drop extension graphql')
metrics = tb.parse_metrics(sd.fetch_metrics())
self.assertEqual(metrics.get(_extkey('graphql'), 0), 0)
self.assertEqual(metrics.get(_extkey('pg_trgm'), 0), 1)
self.assertEqual(metrics.get(_extkey('global'), 0), 0)
await con.execute('create global foo -> str;')
metrics = tb.parse_metrics(sd.fetch_metrics())
self.assertEqual(metrics.get(_featkey('global'), 0), 1)
# Make sure it works after a transaction
await con.execute('start transaction;')
await con.execute('drop global foo;')
await con.execute('commit;')
metrics = tb.parse_metrics(sd.fetch_metrics())
self.assertEqual(metrics.get(_featkey('global'), 0), 0)
# And inside a script
await con.execute('create global foo -> str; select 1;')
await con.execute('create function asdf() -> int64 using (0)')
metrics = tb.parse_metrics(sd.fetch_metrics())
self.assertEqual(metrics.get(_featkey('global'), 0), 1)
self.assertEqual(metrics.get(_featkey('function'), 0), 1)
# Check in a second branch
await con.execute('create empty branch b2')
con2 = await sd.connect(database='b2')
await con2.execute('create function asdf() -> int64 using (0)')
await con2.execute('create extension graphql')
metrics = tb.parse_metrics(sd.fetch_metrics())
self.assertEqual(metrics.get(_extkey('graphql'), 0), 1)
self.assertEqual(metrics.get(_featkey('global'), 0), 1)
self.assertEqual(metrics.get(_featkey('function'), 0), 2)
await con2.aclose()
con2 = None
# Dropping the other branch clears them out
await con.execute('drop branch b2')
metrics = tb.parse_metrics(sd.fetch_metrics())
self.assertEqual(metrics.get(_extkey('graphql'), 0), 0)
self.assertEqual(metrics.get(_featkey('function'), 0), 1)
# More detailed testing
await con.execute('create type Foo;')
metrics = tb.parse_metrics(sd.fetch_metrics())
self.assertEqual(metrics.get(_featkey('index'), 0), 0)
self.assertEqual(metrics.get(_featkey('constraint'), 0), 0)
await con.execute('''
alter type Foo create constraint expression on (true)
''')
metrics = tb.parse_metrics(sd.fetch_metrics())
self.assertEqual(metrics.get(_featkey('index'), 0), 0)
self.assertEqual(metrics.get(_featkey('constraint'), 0), 1)
self.assertEqual(metrics.get(_featkey('constraint_expr'), 0), 1)
self.assertEqual(
metrics.get(_featkey('multiple_inheritance'), 0), 0
)
self.assertEqual(metrics.get(_featkey('scalar'), 0), 0)
self.assertEqual(metrics.get(_featkey('enum'), 0), 0)
self.assertEqual(metrics.get(_featkey('link_property'), 0), 0)
await con.execute('''
create type Bar;
create type Baz extending Foo, Bar;
create scalar type EnumType02 extending enum<foo, bar>;
create type Lol { create multi link foo -> Bar {
create property x -> str;
} };
''')
metrics = tb.parse_metrics(sd.fetch_metrics())
self.assertEqual(
metrics.get(_featkey('multiple_inheritance'), 0), 1
)
self.assertEqual(metrics.get(_featkey('scalar'), 0), 1)
self.assertEqual(metrics.get(_featkey('enum'), 0), 1)
self.assertEqual(metrics.get(_featkey('link_property'), 0), 1)
finally:
await con.aclose()
if con2:
await con2.aclose() | )
metrics = tb.parse_metrics(sd.fetch_metrics())
self.assertEqual(metrics.get(_featkey('index'), 0), 0)
self.assertEqual(metrics.get(_featkey('constraint'), 0), 1)
self.assertEqual(metrics.get(_featkey('constraint_expr'), 0), 1)
self.assertEqual(
metrics.get(_featkey('multiple_inheritance'), 0), 0
)
self.assertEqual(metrics.get(_featkey('scalar'), 0), 0)
self.assertEqual(metrics.get(_featkey('enum'), 0), 0)
self.assertEqual(metrics.get(_featkey('link_property'), 0), 0)
await con.execute( | test_server_ops_schema_metrics_01 | python | geldata/gel | tests/test_server_ops.py | https://github.com/geldata/gel/blob/master/tests/test_server_ops.py | Apache-2.0 |
async def test_edgeql_advtypes_overlapping_union(self):
await self.con.execute('''
INSERT V {name:= 'v0', s := 's0', t := 't0', u := 'u0'};
INSERT Z {
name := 'z0',
stw0 := (
SELECT V FILTER .name = 'v0'
),
};
''')
await self.assert_query_result(
r'''
SELECT Z {stw0: {name}} FILTER .name = 'z0';
''',
[{
'stw0': [{'name': 'v0'}],
}]
) | )
await self.assert_query_result(
r | test_edgeql_advtypes_overlapping_union | python | geldata/gel | tests/test_edgeql_advtypes.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_advtypes.py | Apache-2.0 |
async def test_edgeql_advtypes_overlapping_link_union(self):
await self.con.execute("""
INSERT A { name := 'a1' };
INSERT V {
name:= 'v1',
s := 's1',
t := 't1',
u := 'u1',
l_a := (SELECT A FILTER .name = 'a1'),
};
""")
await self.assert_query_result(
r"""
SELECT (DISTINCT (SELECT S UNION T)) {
cla := count(.l_a)
}
""",
[{
'cla': 1,
}]
) | )
await self.assert_query_result(
r | test_edgeql_advtypes_overlapping_link_union | python | geldata/gel | tests/test_edgeql_advtypes.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_advtypes.py | Apache-2.0 |
async def test_edgeql_advtypes_complex_intersection_15(self):
await self.con.execute("""
INSERT A { name := 'a1' };
INSERT A { name := 'a2' };
INSERT A { name := 'a3' };
INSERT S { name := 'sss', s := 's', l_a := (select A) };
INSERT T { name := 'ttt', t := 't', l_a := (select A) };
INSERT V {
name := 'vvv',
s := 'u',
t := 'u',
u := 'u',
l_a := (select A)
};
""")
await self.assert_query_result(
r"""
SELECT A.<l_a[is S | T] { name } ORDER BY .name;
""",
[{'name': 'sss'}, {'name': 'ttt'}, {'name': 'vvv'}],
)
await self.assert_query_result(
r"""
SELECT A.<l_a[is S & T] { name } ORDER BY .name;
""",
[{'name': 'vvv'}],
) | )
await self.assert_query_result(
r | test_edgeql_advtypes_complex_intersection_15 | python | geldata/gel | tests/test_edgeql_advtypes.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_advtypes.py | Apache-2.0 |
async def test_edgeql_advtypes_complex_intersection_16(self):
# Testing finding path var for type intersections (#7656)
await self._setup_basic_data()
await self.assert_query_result(
r"""
SELECT {CBa, Ba[is Bb]} {
tn := .__type__.name,
[IS Ba].ba,
}
ORDER BY .ba EMPTY LAST;
""",
[
{'tn': 'default::CBa', 'ba': 'cba0'},
{'tn': 'default::CBa', 'ba': 'cba1'},
{'tn': 'default::CBaBb', 'ba': 'cba2'},
{'tn': 'default::CBaBb', 'ba': 'cba3'},
{'tn': 'default::CBaBbBc', 'ba': 'cba8'},
{'tn': 'default::CBaBbBc', 'ba': 'cba9'},
],
)
await self.assert_query_result(
r"""
SELECT {CBa, Bb[is Ba]} {
tn := .__type__.name,
[IS Ba].ba,
}
ORDER BY .ba EMPTY LAST;
""",
[
{'tn': 'default::CBa', 'ba': 'cba0'},
{'tn': 'default::CBa', 'ba': 'cba1'},
{'tn': 'default::CBaBb', 'ba': 'cba2'},
{'tn': 'default::CBaBb', 'ba': 'cba3'},
{'tn': 'default::CBaBbBc', 'ba': 'cba8'},
{'tn': 'default::CBaBbBc', 'ba': 'cba9'},
],
)
await self.assert_query_result(
r"""
SELECT {Bb[is Ba], Bb[is Ba & Bc | CBaBb]} {
tn := .__type__.name,
[IS Ba].ba,
}
ORDER BY .ba EMPTY LAST;
""",
[
{'tn': 'default::CBaBb', 'ba': 'cba2'},
{'tn': 'default::CBaBb', 'ba': 'cba2'},
{'tn': 'default::CBaBb', 'ba': 'cba3'},
{'tn': 'default::CBaBb', 'ba': 'cba3'},
{'tn': 'default::CBaBbBc', 'ba': 'cba8'},
{'tn': 'default::CBaBbBc', 'ba': 'cba8'},
{'tn': 'default::CBaBbBc', 'ba': 'cba9'},
{'tn': 'default::CBaBbBc', 'ba': 'cba9'},
],
) | ,
[
{'tn': 'default::CBa', 'ba': 'cba0'},
{'tn': 'default::CBa', 'ba': 'cba1'},
{'tn': 'default::CBaBb', 'ba': 'cba2'},
{'tn': 'default::CBaBb', 'ba': 'cba3'},
{'tn': 'default::CBaBbBc', 'ba': 'cba8'},
{'tn': 'default::CBaBbBc', 'ba': 'cba9'},
],
)
await self.assert_query_result(
r | test_edgeql_advtypes_complex_intersection_16 | python | geldata/gel | tests/test_edgeql_advtypes.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_advtypes.py | Apache-2.0 |
async def test_edgeql_advtypes_union_narrowing_supertype(self):
await self.con.execute("""
INSERT S { name := 'sss', s := 'sss' };
INSERT T { name := 'ttt', t := 'ttt' };
INSERT W { name := 'www' };
INSERT Z {
name := 'zzz',
stw0 := {S, T, W},
};
""")
await self.assert_query_result(
r"""
WITH My_Z := (SELECT Z FILTER .name = 'zzz')
SELECT _ := My_Z.stw0[IS R].name
ORDER BY _
""",
[
'sss',
'ttt',
]
) | )
await self.assert_query_result(
r | test_edgeql_advtypes_union_narrowing_supertype | python | geldata/gel | tests/test_edgeql_advtypes.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_advtypes.py | Apache-2.0 |
async def test_edgeql_advtypes_union_narrowing_subtype(self):
await self.con.execute("""
INSERT S { name := 'sss', s := 'sss' };
INSERT T { name := 'ttt', t := 'ttt' };
INSERT W { name := 'www' };
INSERT X { name := 'xxx', u := 'xxx_uuu' };
INSERT Z {
name := 'zzz',
stw0 := {S, T, W},
};
""")
await self.assert_query_result(
r"""
WITH My_Z := (SELECT Z FILTER .name = 'zzz')
SELECT _ := My_Z.stw0[IS X].name
ORDER BY _
""",
[
'xxx',
]
) | )
await self.assert_query_result(
r | test_edgeql_advtypes_union_narrowing_subtype | python | geldata/gel | tests/test_edgeql_advtypes.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_advtypes.py | Apache-2.0 |
async def test_edgeql_advtypes_union_opaque_narrowing_subtype(self):
await self.con.execute("""
INSERT W { name := 'www' };
INSERT X {
name := 'xxx',
u := 'xxx_uuu',
w := (SELECT DETACHED W LIMIT 1),
};
INSERT W {
name := 'www-2',
w := (SELECT (DETACHED W) FILTER .name = 'www'),
};
""")
await self.assert_query_result(
r"""
SELECT W {
w_of := .<w[IS X] {
name
}
}
FILTER .name = 'www'
""",
[{
'w_of': [{
'name': 'xxx',
}],
}]
)
await self.assert_query_result(
r"""
SELECT W {
w_of := .<w[IS U] {
u
}
}
FILTER .name = 'www'
""",
[{
'w_of': [{
'u': 'xxx_uuu',
}],
}]
) | )
await self.assert_query_result(
r | test_edgeql_advtypes_union_opaque_narrowing_subtype | python | geldata/gel | tests/test_edgeql_advtypes.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_advtypes.py | Apache-2.0 |
async def test_edgeql_advtypes_intersection_with_comp(self):
await self.con.execute("""
INSERT A { name := 'aaa' };
""")
await self.assert_query_result(
"""
WITH Rc := R
SELECT Rc[IS A].name
""",
['aaa'],
) | )
await self.assert_query_result( | test_edgeql_advtypes_intersection_with_comp | python | geldata/gel | tests/test_edgeql_advtypes.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_advtypes.py | Apache-2.0 |
async def test_edgeql_advtypes_intersection_alias(self):
await self.con.execute("""
INSERT S { name := 'aaa', s := '' };
INSERT Z { name := 'lol', stw0 := S };
""")
await self.assert_query_result(
"""
WITH X := Z.stw0
SELECT X { name }
""",
[{'name': 'aaa'}],
) | )
await self.assert_query_result( | test_edgeql_advtypes_intersection_alias | python | geldata/gel | tests/test_edgeql_advtypes.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_advtypes.py | Apache-2.0 |
async def test_edgeql_advtypes_intersection_semijoin_01(self):
await self.con.execute("""
insert V {
name := "x", s := "!", t := "!", u := '...',
l_a := (insert A { name := "test" })
};
""")
await self.assert_query_result(
"""
select S[is T].l_a { name }
""",
[{"name": "test"}]
)
await self.assert_query_result(
"""
select S[is T] { l_a: {name} }
""",
[{"l_a": [{"name": "test"}]}]
) | )
await self.assert_query_result( | test_edgeql_advtypes_intersection_semijoin_01 | python | geldata/gel | tests/test_edgeql_advtypes.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_advtypes.py | Apache-2.0 |
async def test_edgeql_advtypes_update_complex_type_01(self):
await self._setup_basic_data()
await self.assert_query_result(
r"""
with
temp := (
update Ba[is Bb] set {
ba := .ba ++ '!',
bb := .bb + 1,
}
)
select temp {
tn := .__type__.name,
[IS Ba].ba,
[IS Bb].bb,
[IS Bc].bc,
}
order by .tn then .ba then .bb then .bc;
""",
[
{'tn': 'default::CBaBb', 'ba': 'cba2!', 'bb': 3, 'bc': None},
{'tn': 'default::CBaBb', 'ba': 'cba3!', 'bb': 4, 'bc': None},
{'tn': 'default::CBaBbBc', 'ba': 'cba8!', 'bb': 9, 'bc': 8.5},
{'tn': 'default::CBaBbBc', 'ba': 'cba9!', 'bb': 10, 'bc': 9.5},
],
)
# Ensure the rest of the data is unchanged
await self.assert_query_result(
r"""
select (DISTINCT {Ba, Bb, Bc}){
tn := .__type__.name,
[IS Ba].ba,
[IS Bb].bb,
[IS Bc].bc,
}
order by .tn then .ba then .bb then .bc;
""",
[
{'tn': 'default::CBa', 'ba': 'cba0', 'bb': None, 'bc': None},
{'tn': 'default::CBa', 'ba': 'cba1', 'bb': None, 'bc': None},
{'tn': 'default::CBaBb', 'ba': 'cba2!', 'bb': 3, 'bc': None},
{'tn': 'default::CBaBb', 'ba': 'cba3!', 'bb': 4, 'bc': None},
{'tn': 'default::CBaBbBc', 'ba': 'cba8!', 'bb': 9, 'bc': 8.5},
{'tn': 'default::CBaBbBc', 'ba': 'cba9!', 'bb': 10, 'bc': 9.5},
{'tn': 'default::CBaBc', 'ba': 'cba4', 'bb': None, 'bc': 4.5},
{'tn': 'default::CBaBc', 'ba': 'cba5', 'bb': None, 'bc': 5.5},
{'tn': 'default::CBb', 'ba': None, 'bb': 0, 'bc': None},
{'tn': 'default::CBb', 'ba': None, 'bb': 1, 'bc': None},
{'tn': 'default::CBbBc', 'ba': None, 'bb': 6, 'bc': 6.5},
{'tn': 'default::CBbBc', 'ba': None, 'bb': 7, 'bc': 7.5},
{'tn': 'default::CBc', 'ba': None, 'bb': None, 'bc': 0.5},
{'tn': 'default::CBc', 'ba': None, 'bb': None, 'bc': 1.5},
],
) | ,
[
{'tn': 'default::CBaBb', 'ba': 'cba2!', 'bb': 3, 'bc': None},
{'tn': 'default::CBaBb', 'ba': 'cba3!', 'bb': 4, 'bc': None},
{'tn': 'default::CBaBbBc', 'ba': 'cba8!', 'bb': 9, 'bc': 8.5},
{'tn': 'default::CBaBbBc', 'ba': 'cba9!', 'bb': 10, 'bc': 9.5},
],
)
# Ensure the rest of the data is unchanged
await self.assert_query_result(
r | test_edgeql_advtypes_update_complex_type_01 | python | geldata/gel | tests/test_edgeql_advtypes.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_advtypes.py | Apache-2.0 |
async def test_edgeql_advtypes_update_complex_type_02(self):
await self._setup_basic_data()
await self.assert_query_result(
r"""
with
temp := (
update Ba[is Bb][is Bc] set {
ba := .ba ++ '!',
bb := .bb + 1,
bc := .bc + 0.1,
}
)
select temp {
tn := .__type__.name,
[IS Ba].ba,
[IS Bb].bb,
[IS Bc].bc,
}
order by .tn then .ba then .bb then .bc;
""",
[
{'tn': 'default::CBaBbBc', 'ba': 'cba8!', 'bb': 9, 'bc': 8.6},
{'tn': 'default::CBaBbBc', 'ba': 'cba9!', 'bb': 10, 'bc': 9.6},
],
)
# Ensure the rest of the data is unchanged
await self.assert_query_result(
r"""
select (DISTINCT {Ba, Bb, Bc}){
tn := .__type__.name,
[IS Ba].ba,
[IS Bb].bb,
[IS Bc].bc,
}
order by .tn then .ba then .bb then .bc;
""",
[
{'tn': 'default::CBa', 'ba': 'cba0', 'bb': None, 'bc': None},
{'tn': 'default::CBa', 'ba': 'cba1', 'bb': None, 'bc': None},
{'tn': 'default::CBaBb', 'ba': 'cba2', 'bb': 2, 'bc': None},
{'tn': 'default::CBaBb', 'ba': 'cba3', 'bb': 3, 'bc': None},
{'tn': 'default::CBaBbBc', 'ba': 'cba8!', 'bb': 9, 'bc': 8.6},
{'tn': 'default::CBaBbBc', 'ba': 'cba9!', 'bb': 10, 'bc': 9.6},
{'tn': 'default::CBaBc', 'ba': 'cba4', 'bb': None, 'bc': 4.5},
{'tn': 'default::CBaBc', 'ba': 'cba5', 'bb': None, 'bc': 5.5},
{'tn': 'default::CBb', 'ba': None, 'bb': 0, 'bc': None},
{'tn': 'default::CBb', 'ba': None, 'bb': 1, 'bc': None},
{'tn': 'default::CBbBc', 'ba': None, 'bb': 6, 'bc': 6.5},
{'tn': 'default::CBbBc', 'ba': None, 'bb': 7, 'bc': 7.5},
{'tn': 'default::CBc', 'ba': None, 'bb': None, 'bc': 0.5},
{'tn': 'default::CBc', 'ba': None, 'bb': None, 'bc': 1.5},
],
) | ,
[
{'tn': 'default::CBaBbBc', 'ba': 'cba8!', 'bb': 9, 'bc': 8.6},
{'tn': 'default::CBaBbBc', 'ba': 'cba9!', 'bb': 10, 'bc': 9.6},
],
)
# Ensure the rest of the data is unchanged
await self.assert_query_result(
r | test_edgeql_advtypes_update_complex_type_02 | python | geldata/gel | tests/test_edgeql_advtypes.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_advtypes.py | Apache-2.0 |
async def test_edgeql_advtypes_update_complex_type_03(self):
await self._setup_basic_data()
await self.assert_query_result(
r"""
with
temp := (
update Ba[is Bb | Bc] set {
ba := .ba ++ '!',
}
)
select temp {
tn := .__type__.name,
[IS Ba].ba,
[IS Bb].bb,
[IS Bc].bc,
}
order by .tn then .ba then .bb then .bc;
""",
[
{'tn': 'default::CBaBb', 'ba': 'cba2!', 'bb': 2, 'bc': None},
{'tn': 'default::CBaBb', 'ba': 'cba3!', 'bb': 3, 'bc': None},
{'tn': 'default::CBaBbBc', 'ba': 'cba8!', 'bb': 8, 'bc': 8.5},
{'tn': 'default::CBaBbBc', 'ba': 'cba9!', 'bb': 9, 'bc': 9.5},
{'tn': 'default::CBaBc', 'ba': 'cba4!', 'bb': None, 'bc': 4.5},
{'tn': 'default::CBaBc', 'ba': 'cba5!', 'bb': None, 'bc': 5.5},
],
)
# Ensure the rest of the data is unchanged
await self.assert_query_result(
r"""
select (DISTINCT {Ba, Bb, Bc}){
tn := .__type__.name,
[IS Ba].ba,
[IS Bb].bb,
[IS Bc].bc,
}
order by .tn then .ba then .bb then .bc;
""",
[
{'tn': 'default::CBa', 'ba': 'cba0', 'bb': None, 'bc': None},
{'tn': 'default::CBa', 'ba': 'cba1', 'bb': None, 'bc': None},
{'tn': 'default::CBaBb', 'ba': 'cba2!', 'bb': 2, 'bc': None},
{'tn': 'default::CBaBb', 'ba': 'cba3!', 'bb': 3, 'bc': None},
{'tn': 'default::CBaBbBc', 'ba': 'cba8!', 'bb': 8, 'bc': 8.5},
{'tn': 'default::CBaBbBc', 'ba': 'cba9!', 'bb': 9, 'bc': 9.5},
{'tn': 'default::CBaBc', 'ba': 'cba4!', 'bb': None, 'bc': 4.5},
{'tn': 'default::CBaBc', 'ba': 'cba5!', 'bb': None, 'bc': 5.5},
{'tn': 'default::CBb', 'ba': None, 'bb': 0, 'bc': None},
{'tn': 'default::CBb', 'ba': None, 'bb': 1, 'bc': None},
{'tn': 'default::CBbBc', 'ba': None, 'bb': 6, 'bc': 6.5},
{'tn': 'default::CBbBc', 'ba': None, 'bb': 7, 'bc': 7.5},
{'tn': 'default::CBc', 'ba': None, 'bb': None, 'bc': 0.5},
{'tn': 'default::CBc', 'ba': None, 'bb': None, 'bc': 1.5},
],
) | ,
[
{'tn': 'default::CBaBb', 'ba': 'cba2!', 'bb': 2, 'bc': None},
{'tn': 'default::CBaBb', 'ba': 'cba3!', 'bb': 3, 'bc': None},
{'tn': 'default::CBaBbBc', 'ba': 'cba8!', 'bb': 8, 'bc': 8.5},
{'tn': 'default::CBaBbBc', 'ba': 'cba9!', 'bb': 9, 'bc': 9.5},
{'tn': 'default::CBaBc', 'ba': 'cba4!', 'bb': None, 'bc': 4.5},
{'tn': 'default::CBaBc', 'ba': 'cba5!', 'bb': None, 'bc': 5.5},
],
)
# Ensure the rest of the data is unchanged
await self.assert_query_result(
r | test_edgeql_advtypes_update_complex_type_03 | python | geldata/gel | tests/test_edgeql_advtypes.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_advtypes.py | Apache-2.0 |
async def test_edgeql_advtypes_update_complex_type_04(self):
await self._setup_basic_data()
await self.assert_query_result(
r"""
with
temp := (
update Ba[is Bb & Bc] set {
ba := .ba ++ '!',
bb := .bb + 1,
bc := .bc + 0.1,
}
)
select temp {
tn := .__type__.name,
[IS Ba].ba,
[IS Bb].bb,
[IS Bc].bc,
}
order by .tn then .ba then .bb then .bc;
""",
[
{'tn': 'default::CBaBbBc', 'ba': 'cba8!', 'bb': 9, 'bc': 8.6},
{'tn': 'default::CBaBbBc', 'ba': 'cba9!', 'bb': 10, 'bc': 9.6},
],
)
# Ensure the rest of the data is unchanged
await self.assert_query_result(
r"""
select (DISTINCT {Ba, Bb, Bc}){
tn := .__type__.name,
[IS Ba].ba,
[IS Bb].bb,
[IS Bc].bc,
}
order by .tn then .ba then .bb then .bc;
""",
[
{'tn': 'default::CBa', 'ba': 'cba0', 'bb': None, 'bc': None},
{'tn': 'default::CBa', 'ba': 'cba1', 'bb': None, 'bc': None},
{'tn': 'default::CBaBb', 'ba': 'cba2', 'bb': 2, 'bc': None},
{'tn': 'default::CBaBb', 'ba': 'cba3', 'bb': 3, 'bc': None},
{'tn': 'default::CBaBbBc', 'ba': 'cba8!', 'bb': 9, 'bc': 8.6},
{'tn': 'default::CBaBbBc', 'ba': 'cba9!', 'bb': 10, 'bc': 9.6},
{'tn': 'default::CBaBc', 'ba': 'cba4', 'bb': None, 'bc': 4.5},
{'tn': 'default::CBaBc', 'ba': 'cba5', 'bb': None, 'bc': 5.5},
{'tn': 'default::CBb', 'ba': None, 'bb': 0, 'bc': None},
{'tn': 'default::CBb', 'ba': None, 'bb': 1, 'bc': None},
{'tn': 'default::CBbBc', 'ba': None, 'bb': 6, 'bc': 6.5},
{'tn': 'default::CBbBc', 'ba': None, 'bb': 7, 'bc': 7.5},
{'tn': 'default::CBc', 'ba': None, 'bb': None, 'bc': 0.5},
{'tn': 'default::CBc', 'ba': None, 'bb': None, 'bc': 1.5},
],
) | ,
[
{'tn': 'default::CBaBbBc', 'ba': 'cba8!', 'bb': 9, 'bc': 8.6},
{'tn': 'default::CBaBbBc', 'ba': 'cba9!', 'bb': 10, 'bc': 9.6},
],
)
# Ensure the rest of the data is unchanged
await self.assert_query_result(
r | test_edgeql_advtypes_update_complex_type_04 | python | geldata/gel | tests/test_edgeql_advtypes.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_advtypes.py | Apache-2.0 |
async def test_edgeql_advtypes_update_complex_type_05(self):
await self._setup_basic_data()
await self.assert_query_result(
r"""
with
temp := (
update Ba[IS CBa | Bb & Bc] set {
ba := .ba ++ '!',
}
)
select temp {
tn := .__type__.name,
[IS Ba].ba,
[IS Bb].bb,
[IS Bc].bc,
}
order by .tn then .ba then .bb then .bc;
""",
[
{'tn': 'default::CBa', 'ba': 'cba0!', 'bb': None, 'bc': None},
{'tn': 'default::CBa', 'ba': 'cba1!', 'bb': None, 'bc': None},
{'tn': 'default::CBaBbBc', 'ba': 'cba8!', 'bb': 8, 'bc': 8.5},
{'tn': 'default::CBaBbBc', 'ba': 'cba9!', 'bb': 9, 'bc': 9.5},
],
)
# Ensure the rest of the data is unchanged
await self.assert_query_result(
r"""
select (DISTINCT {Ba, Bb, Bc}){
tn := .__type__.name,
[IS Ba].ba,
[IS Bb].bb,
[IS Bc].bc,
}
order by .tn then .ba then .bb then .bc;
""",
[
{'tn': 'default::CBa', 'ba': 'cba0!', 'bb': None, 'bc': None},
{'tn': 'default::CBa', 'ba': 'cba1!', 'bb': None, 'bc': None},
{'tn': 'default::CBaBb', 'ba': 'cba2', 'bb': 2, 'bc': None},
{'tn': 'default::CBaBb', 'ba': 'cba3', 'bb': 3, 'bc': None},
{'tn': 'default::CBaBbBc', 'ba': 'cba8!', 'bb': 8, 'bc': 8.5},
{'tn': 'default::CBaBbBc', 'ba': 'cba9!', 'bb': 9, 'bc': 9.5},
{'tn': 'default::CBaBc', 'ba': 'cba4', 'bb': None, 'bc': 4.5},
{'tn': 'default::CBaBc', 'ba': 'cba5', 'bb': None, 'bc': 5.5},
{'tn': 'default::CBb', 'ba': None, 'bb': 0, 'bc': None},
{'tn': 'default::CBb', 'ba': None, 'bb': 1, 'bc': None},
{'tn': 'default::CBbBc', 'ba': None, 'bb': 6, 'bc': 6.5},
{'tn': 'default::CBbBc', 'ba': None, 'bb': 7, 'bc': 7.5},
{'tn': 'default::CBc', 'ba': None, 'bb': None, 'bc': 0.5},
{'tn': 'default::CBc', 'ba': None, 'bb': None, 'bc': 1.5},
],
) | ,
[
{'tn': 'default::CBa', 'ba': 'cba0!', 'bb': None, 'bc': None},
{'tn': 'default::CBa', 'ba': 'cba1!', 'bb': None, 'bc': None},
{'tn': 'default::CBaBbBc', 'ba': 'cba8!', 'bb': 8, 'bc': 8.5},
{'tn': 'default::CBaBbBc', 'ba': 'cba9!', 'bb': 9, 'bc': 9.5},
],
)
# Ensure the rest of the data is unchanged
await self.assert_query_result(
r | test_edgeql_advtypes_update_complex_type_05 | python | geldata/gel | tests/test_edgeql_advtypes.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_advtypes.py | Apache-2.0 |
async def test_edgeql_advtypes_update_complex_type_06(self):
await self._setup_basic_data()
await self.assert_query_result(
r"""
with
temp := (
update {CBa, Ba[IS Bb & Bc]} set {
ba := .ba ++ '!',
}
)
select temp {
tn := .__type__.name,
[IS Ba].ba,
[IS Bb].bb,
[IS Bc].bc,
}
order by .tn then .ba then .bb then .bc;
""",
[
{'tn': 'default::CBa', 'ba': 'cba0!', 'bb': None, 'bc': None},
{'tn': 'default::CBa', 'ba': 'cba1!', 'bb': None, 'bc': None},
{'tn': 'default::CBaBbBc', 'ba': 'cba8!', 'bb': 8, 'bc': 8.5},
{'tn': 'default::CBaBbBc', 'ba': 'cba9!', 'bb': 9, 'bc': 9.5},
],
)
# Ensure the rest of the data is unchanged
await self.assert_query_result(
r"""
select (DISTINCT {Ba, Bb, Bc}){
tn := .__type__.name,
[IS Ba].ba,
[IS Bb].bb,
[IS Bc].bc,
}
order by .tn then .ba then .bb then .bc;
""",
[
{'tn': 'default::CBa', 'ba': 'cba0!', 'bb': None, 'bc': None},
{'tn': 'default::CBa', 'ba': 'cba1!', 'bb': None, 'bc': None},
{'tn': 'default::CBaBb', 'ba': 'cba2', 'bb': 2, 'bc': None},
{'tn': 'default::CBaBb', 'ba': 'cba3', 'bb': 3, 'bc': None},
{'tn': 'default::CBaBbBc', 'ba': 'cba8!', 'bb': 8, 'bc': 8.5},
{'tn': 'default::CBaBbBc', 'ba': 'cba9!', 'bb': 9, 'bc': 9.5},
{'tn': 'default::CBaBc', 'ba': 'cba4', 'bb': None, 'bc': 4.5},
{'tn': 'default::CBaBc', 'ba': 'cba5', 'bb': None, 'bc': 5.5},
{'tn': 'default::CBb', 'ba': None, 'bb': 0, 'bc': None},
{'tn': 'default::CBb', 'ba': None, 'bb': 1, 'bc': None},
{'tn': 'default::CBbBc', 'ba': None, 'bb': 6, 'bc': 6.5},
{'tn': 'default::CBbBc', 'ba': None, 'bb': 7, 'bc': 7.5},
{'tn': 'default::CBc', 'ba': None, 'bb': None, 'bc': 0.5},
{'tn': 'default::CBc', 'ba': None, 'bb': None, 'bc': 1.5},
],
) | ,
[
{'tn': 'default::CBa', 'ba': 'cba0!', 'bb': None, 'bc': None},
{'tn': 'default::CBa', 'ba': 'cba1!', 'bb': None, 'bc': None},
{'tn': 'default::CBaBbBc', 'ba': 'cba8!', 'bb': 8, 'bc': 8.5},
{'tn': 'default::CBaBbBc', 'ba': 'cba9!', 'bb': 9, 'bc': 9.5},
],
)
# Ensure the rest of the data is unchanged
await self.assert_query_result(
r | test_edgeql_advtypes_update_complex_type_06 | python | geldata/gel | tests/test_edgeql_advtypes.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_advtypes.py | Apache-2.0 |
async def test_edgeql_advtypes_update_complex_type_07(self):
await self._setup_basic_data()
await self.assert_query_result(
r"""
with
temp := (
update Object[IS (Ba & Bb) | (Ba & Bc)] set {
ba := .ba ++ '!',
}
)
select temp {
tn := .__type__.name,
[IS Ba].ba,
[IS Bb].bb,
[IS Bc].bc,
}
order by .tn then .ba then .bb then .bc;
""",
[
{'tn': 'default::CBaBb', 'ba': 'cba2!', 'bb': 2, 'bc': None},
{'tn': 'default::CBaBb', 'ba': 'cba3!', 'bb': 3, 'bc': None},
{'tn': 'default::CBaBbBc', 'ba': 'cba8!', 'bb': 8, 'bc': 8.5},
{'tn': 'default::CBaBbBc', 'ba': 'cba9!', 'bb': 9, 'bc': 9.5},
{'tn': 'default::CBaBc', 'ba': 'cba4!', 'bb': None, 'bc': 4.5},
{'tn': 'default::CBaBc', 'ba': 'cba5!', 'bb': None, 'bc': 5.5},
],
)
# Ensure the rest of the data is unchanged
await self.assert_query_result(
r"""
select (DISTINCT {Ba, Bb, Bc}){
tn := .__type__.name,
[IS Ba].ba,
[IS Bb].bb,
[IS Bc].bc,
}
order by .tn then .ba then .bb then .bc;
""",
[
{'tn': 'default::CBa', 'ba': 'cba0', 'bb': None, 'bc': None},
{'tn': 'default::CBa', 'ba': 'cba1', 'bb': None, 'bc': None},
{'tn': 'default::CBaBb', 'ba': 'cba2!', 'bb': 2, 'bc': None},
{'tn': 'default::CBaBb', 'ba': 'cba3!', 'bb': 3, 'bc': None},
{'tn': 'default::CBaBbBc', 'ba': 'cba8!', 'bb': 8, 'bc': 8.5},
{'tn': 'default::CBaBbBc', 'ba': 'cba9!', 'bb': 9, 'bc': 9.5},
{'tn': 'default::CBaBc', 'ba': 'cba4!', 'bb': None, 'bc': 4.5},
{'tn': 'default::CBaBc', 'ba': 'cba5!', 'bb': None, 'bc': 5.5},
{'tn': 'default::CBb', 'ba': None, 'bb': 0, 'bc': None},
{'tn': 'default::CBb', 'ba': None, 'bb': 1, 'bc': None},
{'tn': 'default::CBbBc', 'ba': None, 'bb': 6, 'bc': 6.5},
{'tn': 'default::CBbBc', 'ba': None, 'bb': 7, 'bc': 7.5},
{'tn': 'default::CBc', 'ba': None, 'bb': None, 'bc': 0.5},
{'tn': 'default::CBc', 'ba': None, 'bb': None, 'bc': 1.5},
],
) | ,
[
{'tn': 'default::CBaBb', 'ba': 'cba2!', 'bb': 2, 'bc': None},
{'tn': 'default::CBaBb', 'ba': 'cba3!', 'bb': 3, 'bc': None},
{'tn': 'default::CBaBbBc', 'ba': 'cba8!', 'bb': 8, 'bc': 8.5},
{'tn': 'default::CBaBbBc', 'ba': 'cba9!', 'bb': 9, 'bc': 9.5},
{'tn': 'default::CBaBc', 'ba': 'cba4!', 'bb': None, 'bc': 4.5},
{'tn': 'default::CBaBc', 'ba': 'cba5!', 'bb': None, 'bc': 5.5},
],
)
# Ensure the rest of the data is unchanged
await self.assert_query_result(
r | test_edgeql_advtypes_update_complex_type_07 | python | geldata/gel | tests/test_edgeql_advtypes.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_advtypes.py | Apache-2.0 |
async def test_edgeql_advtypes_update_complex_type_08(self):
await self._setup_basic_data()
await self.assert_query_result(
r"""
with
temp := (
update {Object[IS Ba & Bb], Object[IS Ba & Bc]} set {
ba := .ba ++ '!',
}
)
select temp {
tn := .__type__.name,
[IS Ba].ba,
[IS Bb].bb,
[IS Bc].bc,
}
order by .tn then .ba then .bb then .bc;
""",
[
{'tn': 'default::CBaBb', 'ba': 'cba2!', 'bb': 2, 'bc': None},
{'tn': 'default::CBaBb', 'ba': 'cba3!', 'bb': 3, 'bc': None},
{'tn': 'default::CBaBbBc', 'ba': 'cba8!', 'bb': 8, 'bc': 8.5},
{'tn': 'default::CBaBbBc', 'ba': 'cba9!', 'bb': 9, 'bc': 9.5},
{'tn': 'default::CBaBc', 'ba': 'cba4!', 'bb': None, 'bc': 4.5},
{'tn': 'default::CBaBc', 'ba': 'cba5!', 'bb': None, 'bc': 5.5},
],
)
# Ensure the rest of the data is unchanged
await self.assert_query_result(
r"""
select (DISTINCT {Ba, Bb, Bc}){
tn := .__type__.name,
[IS Ba].ba,
[IS Bb].bb,
[IS Bc].bc,
}
order by .tn then .ba then .bb then .bc;
""",
[
{'tn': 'default::CBa', 'ba': 'cba0', 'bb': None, 'bc': None},
{'tn': 'default::CBa', 'ba': 'cba1', 'bb': None, 'bc': None},
{'tn': 'default::CBaBb', 'ba': 'cba2!', 'bb': 2, 'bc': None},
{'tn': 'default::CBaBb', 'ba': 'cba3!', 'bb': 3, 'bc': None},
{'tn': 'default::CBaBbBc', 'ba': 'cba8!', 'bb': 8, 'bc': 8.5},
{'tn': 'default::CBaBbBc', 'ba': 'cba9!', 'bb': 9, 'bc': 9.5},
{'tn': 'default::CBaBc', 'ba': 'cba4!', 'bb': None, 'bc': 4.5},
{'tn': 'default::CBaBc', 'ba': 'cba5!', 'bb': None, 'bc': 5.5},
{'tn': 'default::CBb', 'ba': None, 'bb': 0, 'bc': None},
{'tn': 'default::CBb', 'ba': None, 'bb': 1, 'bc': None},
{'tn': 'default::CBbBc', 'ba': None, 'bb': 6, 'bc': 6.5},
{'tn': 'default::CBbBc', 'ba': None, 'bb': 7, 'bc': 7.5},
{'tn': 'default::CBc', 'ba': None, 'bb': None, 'bc': 0.5},
{'tn': 'default::CBc', 'ba': None, 'bb': None, 'bc': 1.5},
],
) | ,
[
{'tn': 'default::CBaBb', 'ba': 'cba2!', 'bb': 2, 'bc': None},
{'tn': 'default::CBaBb', 'ba': 'cba3!', 'bb': 3, 'bc': None},
{'tn': 'default::CBaBbBc', 'ba': 'cba8!', 'bb': 8, 'bc': 8.5},
{'tn': 'default::CBaBbBc', 'ba': 'cba9!', 'bb': 9, 'bc': 9.5},
{'tn': 'default::CBaBc', 'ba': 'cba4!', 'bb': None, 'bc': 4.5},
{'tn': 'default::CBaBc', 'ba': 'cba5!', 'bb': None, 'bc': 5.5},
],
)
# Ensure the rest of the data is unchanged
await self.assert_query_result(
r | test_edgeql_advtypes_update_complex_type_08 | python | geldata/gel | tests/test_edgeql_advtypes.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_advtypes.py | Apache-2.0 |
async def test_edgeql_advtypes_delete_complex_type_01(self):
await self._setup_basic_data()
await self.con.execute(
r"""
delete Ba[is Bb];
"""
)
# Ensure the rest of the data is unchanged
await self.assert_query_result(
r"""
select (DISTINCT {Ba, Bb, Bc}){
tn := .__type__.name,
[IS Ba].ba,
[IS Bb].bb,
[IS Bc].bc,
}
order by .tn then .ba then .bb then .bc;
""",
[
{'tn': 'default::CBa', 'ba': 'cba0', 'bb': None, 'bc': None},
{'tn': 'default::CBa', 'ba': 'cba1', 'bb': None, 'bc': None},
{'tn': 'default::CBaBc', 'ba': 'cba4', 'bb': None, 'bc': 4.5},
{'tn': 'default::CBaBc', 'ba': 'cba5', 'bb': None, 'bc': 5.5},
{'tn': 'default::CBb', 'ba': None, 'bb': 0, 'bc': None},
{'tn': 'default::CBb', 'ba': None, 'bb': 1, 'bc': None},
{'tn': 'default::CBbBc', 'ba': None, 'bb': 6, 'bc': 6.5},
{'tn': 'default::CBbBc', 'ba': None, 'bb': 7, 'bc': 7.5},
{'tn': 'default::CBc', 'ba': None, 'bb': None, 'bc': 0.5},
{'tn': 'default::CBc', 'ba': None, 'bb': None, 'bc': 1.5},
],
) | )
# Ensure the rest of the data is unchanged
await self.assert_query_result(
r | test_edgeql_advtypes_delete_complex_type_01 | python | geldata/gel | tests/test_edgeql_advtypes.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_advtypes.py | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.