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_eschema_syntax_annotation_14(self):
"""
module test {
abstract annotation as extending extending foo;
};
""" | module test {
abstract annotation as extending extending foo;
}; | test_eschema_syntax_annotation_14 | python | geldata/gel | tests/test_schema_syntax.py | https://github.com/geldata/gel/blob/master/tests/test_schema_syntax.py | Apache-2.0 |
def test_eschema_syntax_annotation_15(self):
"""
annotation test::foo;
""" | annotation test::foo; | test_eschema_syntax_annotation_15 | python | geldata/gel | tests/test_schema_syntax.py | https://github.com/geldata/gel/blob/master/tests/test_schema_syntax.py | Apache-2.0 |
def test_eschema_syntax_future_1(self):
"""
using future foo;
""" | using future foo; | test_eschema_syntax_future_1 | python | geldata/gel | tests/test_schema_syntax.py | https://github.com/geldata/gel/blob/master/tests/test_schema_syntax.py | Apache-2.0 |
def test_eschema_syntax_global_1(self):
"""
module test {
global foo -> str;
};
""" | module test {
global foo -> str;
}; | test_eschema_syntax_global_1 | python | geldata/gel | tests/test_schema_syntax.py | https://github.com/geldata/gel/blob/master/tests/test_schema_syntax.py | Apache-2.0 |
def test_eschema_syntax_global_2(self):
"""
global test::foo -> str;
""" | global test::foo -> str; | test_eschema_syntax_global_2 | python | geldata/gel | tests/test_schema_syntax.py | https://github.com/geldata/gel/blob/master/tests/test_schema_syntax.py | Apache-2.0 |
def test_eschema_syntax_global_3(self):
"""
module test {
optional global foo := 1;
};
""" | module test {
optional global foo := 1;
}; | test_eschema_syntax_global_3 | python | geldata/gel | tests/test_schema_syntax.py | https://github.com/geldata/gel/blob/master/tests/test_schema_syntax.py | Apache-2.0 |
def test_eschema_syntax_global_4(self):
"""
module test {
required global foo -> str {
default := "lol";
annotation title := "foo";
};
};
""" | module test {
required global foo -> str {
default := "lol";
annotation title := "foo";
};
}; | test_eschema_syntax_global_4 | python | geldata/gel | tests/test_schema_syntax.py | https://github.com/geldata/gel/blob/master/tests/test_schema_syntax.py | Apache-2.0 |
def test_eschema_syntax_global_5(self):
"""
module test {
required global foo {
using (50);
annotation title := "foo";
};
};
""" | module test {
required global foo {
using (50);
annotation title := "foo";
};
}; | test_eschema_syntax_global_5 | python | geldata/gel | tests/test_schema_syntax.py | https://github.com/geldata/gel/blob/master/tests/test_schema_syntax.py | Apache-2.0 |
def test_eschema_syntax_policy_1(self):
"""
module test {
type Foo {
access policy test
allow all
using (true);
};
};
""" | module test {
type Foo {
access policy test
allow all
using (true);
};
}; | test_eschema_syntax_policy_1 | python | geldata/gel | tests/test_schema_syntax.py | https://github.com/geldata/gel/blob/master/tests/test_schema_syntax.py | Apache-2.0 |
def test_eschema_syntax_policy_2(self):
"""
module test {
type Foo {
access policy test
allow select, update, insert
using (1 + 2 = 3);
};
};
""" | module test {
type Foo {
access policy test
allow select, update, insert
using (1 + 2 = 3);
};
}; | test_eschema_syntax_policy_2 | python | geldata/gel | tests/test_schema_syntax.py | https://github.com/geldata/gel/blob/master/tests/test_schema_syntax.py | Apache-2.0 |
def test_eschema_syntax_policy_3(self):
"""
module test {
type Foo {
access policy test
when (true)
deny all
using (true) {
annotation title := 'foo';
};
property x: str;
};
};
""" | module test {
type Foo {
access policy test
when (true)
deny all
using (true) {
annotation title := 'foo';
};
property x: str;
};
}; | test_eschema_syntax_policy_3 | python | geldata/gel | tests/test_schema_syntax.py | https://github.com/geldata/gel/blob/master/tests/test_schema_syntax.py | Apache-2.0 |
def test_eschema_syntax_policy_4(self):
"""
module test {
type Foo {
access policy test
when (true)
deny all
using (true);
property x: str;
};
};
""" | module test {
type Foo {
access policy test
when (true)
deny all
using (true);
property x: str;
};
}; | test_eschema_syntax_policy_4 | python | geldata/gel | tests/test_schema_syntax.py | https://github.com/geldata/gel/blob/master/tests/test_schema_syntax.py | Apache-2.0 |
def test_eschema_syntax_trigger_1(self):
"""
module test {
type Foo {
trigger foo after insert
for each
do (1);
};
};
""" | module test {
type Foo {
trigger foo after insert
for each
do (1);
};
}; | test_eschema_syntax_trigger_1 | python | geldata/gel | tests/test_schema_syntax.py | https://github.com/geldata/gel/blob/master/tests/test_schema_syntax.py | Apache-2.0 |
def test_eschema_syntax_trigger_2(self):
"""
module test {
type Foo {
trigger foo after commit of
update, delete, insert
for all
do ((__new__, __old__));
};
};
""" | module test {
type Foo {
trigger foo after commit of
update, delete, insert
for all
do ((__new__, __old__));
};
}; | test_eschema_syntax_trigger_2 | python | geldata/gel | tests/test_schema_syntax.py | https://github.com/geldata/gel/blob/master/tests/test_schema_syntax.py | Apache-2.0 |
def test_eschema_syntax_trigger_3(self):
"""
module test {
type Foo {
trigger foo after commit of
update, delete, insert
for all
do (1) {
annotation title := 'foo';
};
};
};
""" | module test {
type Foo {
trigger foo after commit of
update, delete, insert
for all
do (1) {
annotation title := 'foo';
};
};
}; | test_eschema_syntax_trigger_3 | python | geldata/gel | tests/test_schema_syntax.py | https://github.com/geldata/gel/blob/master/tests/test_schema_syntax.py | Apache-2.0 |
def test_eschema_syntax_rewrite_1(self):
"""
module test {
type Foo {
property foo: i64 {
rewrite insert using (1);
};
};
};
""" | module test {
type Foo {
property foo: i64 {
rewrite insert using (1);
};
};
}; | test_eschema_syntax_rewrite_1 | python | geldata/gel | tests/test_schema_syntax.py | https://github.com/geldata/gel/blob/master/tests/test_schema_syntax.py | Apache-2.0 |
def test_eschema_syntax_rewrite_2(self):
"""
module test {
type Foo {
property name_updated_at: i64 {
rewrite update, insert using (
datetime_current()
if __specified__.name
else .name_updated_at
);
};
};
};
""" | module test {
type Foo {
property name_updated_at: i64 {
rewrite update, insert using (
datetime_current()
if __specified__.name
else .name_updated_at
);
};
};
}; | test_eschema_syntax_rewrite_2 | python | geldata/gel | tests/test_schema_syntax.py | https://github.com/geldata/gel/blob/master/tests/test_schema_syntax.py | Apache-2.0 |
def test_eschema_newsyntax_colon_01(self):
"""
abstract type test::OwnedObject {
required link owner: User
};
% OK %
abstract type test::OwnedObject {
required link owner: User;
};
""" | abstract type test::OwnedObject {
required link owner: User
};
% OK %
abstract type test::OwnedObject {
required link owner: User;
}; | test_eschema_newsyntax_colon_01 | python | geldata/gel | tests/test_schema_syntax.py | https://github.com/geldata/gel/blob/master/tests/test_schema_syntax.py | Apache-2.0 |
def test_eschema_newsyntax_global_1(self):
"""
module test {
global foo: str;
};
% OK %
module test {
global foo -> str;
};
""" | module test {
global foo: str;
};
% OK %
module test {
global foo -> str;
}; | test_eschema_newsyntax_global_1 | python | geldata/gel | tests/test_schema_syntax.py | https://github.com/geldata/gel/blob/master/tests/test_schema_syntax.py | Apache-2.0 |
def test_eschema_syntax_missing_semicolon(self):
"""
module default {
type Foo;
type Bar {
link l -> Foo {
a -> bool # missing semicolon
b -> bool;
c -> bool;
};
};
}
;
using future nonrecursive_access_policies;
% OK %
module test {
global foo -> str;
};
""" | module default {
type Foo;
type Bar {
link l -> Foo {
a -> bool # missing semicolon
b -> bool;
c -> bool;
};
};
}
;
using future nonrecursive_access_policies;
% OK %
module test {
global foo -> str;
}; | test_eschema_syntax_missing_semicolon | python | geldata/gel | tests/test_schema_syntax.py | https://github.com/geldata/gel/blob/master/tests/test_schema_syntax.py | Apache-2.0 |
def test_eschema_syntax_extra_create(self):
"""
type T {
create property lol -> str;
}
""" | type T {
create property lol -> str;
} | test_eschema_syntax_extra_create | python | geldata/gel | tests/test_schema_syntax.py | https://github.com/geldata/gel/blob/master/tests/test_schema_syntax.py | Apache-2.0 |
async def _ensure_schema_integrity(self):
# Validate branch-level config
await self.assert_query_result(
r'''
select cfg::Config.extensions[is ext::pgvector::Config]
.ef_search
''',
[
5
]
)
await self.assert_query_result(
r'''
select ext::pgvector::Config.ef_search
filter ext::pgvector::Config.cfg is cfg::DatabaseConfig
''',
[
5
]
) | ,
[
5
]
)
await self.assert_query_result(
r | _ensure_schema_integrity | python | geldata/gel | tests/test_dump_v5.py | https://github.com/geldata/gel/blob/master/tests/test_dump_v5.py | Apache-2.0 |
async def _ensure_data_integrity(self):
await self.assert_query_result(
r'''
select count(L2)
''',
[
999
]
)
await self.assert_query_result(
r'''
with x := range_unpack(range(1, 1000))
select all(
L2.vec in <v3>[x % 10, std::math::ln(x), x / 7 % 13]
)
''',
[
True
]
) | ,
[
999
]
)
await self.assert_query_result(
r | _ensure_data_integrity | python | geldata/gel | tests/test_dump_v5.py | https://github.com/geldata/gel/blob/master/tests/test_dump_v5.py | Apache-2.0 |
async def test_edgeql_globals_errors_01(self):
async with self.assertRaisesRegexTx(
edgedb.QueryError,
r"possibly an empty set returned",
):
await self.con.execute('''
set global def_cur_user := {};
''')
async with self.assertRaisesRegexTx(
edgedb.QueryError,
r"possibly more than one element returned",
):
await self.con.execute('''
set global def_cur_user := {"foo", "bar"};
''') | )
async with self.assertRaisesRegexTx(
edgedb.QueryError,
r"possibly more than one element returned",
):
await self.con.execute( | test_edgeql_globals_errors_01 | python | geldata/gel | tests/test_edgeql_globals.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_globals.py | Apache-2.0 |
async def test_edgeql_globals_01(self):
await self.con.execute('''
set global cur_user := "Bob";
''')
await self.assert_query_result(
r'''
select global cur_user
''',
['Bob'],
) | )
await self.assert_query_result(
r | test_edgeql_globals_01 | python | geldata/gel | tests/test_edgeql_globals.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_globals.py | Apache-2.0 |
async def test_edgeql_globals_02(self):
await self.con.execute('''
set global cur_user := "Bob";
set global def_cur_user := "Dave";
''')
await self.assert_query_result(
r'''
select (global cur_user, global def_cur_user,
global def_cur_user_excited)
''',
[['Bob', 'Dave', 'Dave!']],
) | )
await self.assert_query_result(
r | test_edgeql_globals_02 | python | geldata/gel | tests/test_edgeql_globals.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_globals.py | Apache-2.0 |
async def test_edgeql_globals_03(self):
# test the behaviors of an optional with a default
await self.assert_query_result(
r'''select global cur_card''',
['Dragon']
)
await self.con.execute('''
set global cur_card := 'foo'
''')
await self.assert_query_result(
r'''select global cur_card''',
['foo']
)
# setting it to {} actually sets it to {}
await self.con.execute('''
set global cur_card := {}
''')
await self.assert_query_result(
r'''select global cur_card''',
[]
)
# and RESET puts it back to the default
await self.con.execute('''
reset global cur_card
''')
await self.assert_query_result(
r'''select global cur_card''',
['Dragon']
) | )
await self.assert_query_result(
r'''select global cur_card''',
['foo']
)
# setting it to {} actually sets it to {}
await self.con.execute( | test_edgeql_globals_03 | python | geldata/gel | tests/test_edgeql_globals.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_globals.py | Apache-2.0 |
async def test_edgeql_globals_06(self):
await self.con.execute('''
set global cur_user := "Alice";
''')
await self.con.execute('''
set global banned_cards := ["Dragon"];
''')
await self.assert_query_result(
r'''select get_current_legal_cards().name''',
{"Imp", "Bog monster", "Giant turtle"},
) | )
await self.con.execute( | test_edgeql_globals_06 | python | geldata/gel | tests/test_edgeql_globals.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_globals.py | Apache-2.0 |
async def test_edgeql_globals_07(self):
await self.con.execute('''
set global def_cur_user := "Bob";
''')
await self.con.execute('''
set global cur_user := "Alice";
''')
await self.con.execute('''
set global banned_cards := ["Dragon"];
''')
await self.con.execute('''
alter function get_current_user() using (
select User filter .name = global def_cur_user
);
''')
await self.assert_query_result(
r'''select get_current_legal_cards().name''',
{"Dwarf", "Bog monster", "Golem", "Giant turtle"}
) | )
await self.con.execute( | test_edgeql_globals_07 | python | geldata/gel | tests/test_edgeql_globals.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_globals.py | Apache-2.0 |
async def test_edgeql_globals_08(self):
await self.assert_query_result(
r'''select get_all_vars()''',
[["", "Alice", "Dragon"]],
)
await self.con.execute('''
set global cur_card := "Imp";
''')
await self.assert_query_result(
r'''select get_all_vars()''',
[["", "Alice", "Imp"]],
)
await self.con.execute('''
set global cur_user := "Bob";
''')
await self.assert_query_result(
r'''select get_all_vars()''',
[["Bob", "Alice", "Imp"]],
)
await self.con.execute('''
set global def_cur_user := "Carol";
''')
await self.assert_query_result(
r'''select get_all_vars()''',
[["Bob", "Carol", "Imp"]],
)
await self.con.execute('''
set global cur_card := {};
''')
await self.assert_query_result(
r'''select get_all_vars()''',
[["Bob", "Carol", ""]],
) | )
await self.assert_query_result(
r'''select get_all_vars()''',
[["", "Alice", "Imp"]],
)
await self.con.execute( | test_edgeql_globals_08 | python | geldata/gel | tests/test_edgeql_globals.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_globals.py | Apache-2.0 |
async def test_edgeql_globals_09(self):
# Test that overloaded functions work
await self.con.execute('''
create function is_active(x: Named) -> bool using (false);
create function is_active(x: User) -> bool using (
select x.name ?= global cur_user);
create function is_active(x: Card) -> bool using (
select x.name not in array_unpack(global banned_cards));
create function is_active2(x: Named) -> bool using (is_active(x));
''')
await self.con.execute('''
set global cur_user := "Bob";
''')
await self.con.execute('''
set global banned_cards := ["Dragon"];
''')
results = tb.bag([
{"active": True, "name": "Imp"},
{"active": False, "name": "Dragon"},
{"active": True, "name": "Bog monster"},
{"active": True, "name": "Giant turtle"},
{"active": True, "name": "Dwarf"},
{"active": True, "name": "Golem"},
{"active": True, "name": "Sprite"},
{"active": True, "name": "Giant eagle"},
{"active": False, "name": "Alice"},
{"active": True, "name": "Bob"},
{"active": False, "name": "Carol"},
{"active": False, "name": "Dave"},
{"active": True, "name": "Djinn"},
{"active": False, "name": "1st"},
{"active": False, "name": "2nd"},
{"active": False, "name": "3rd"},
])
await self.assert_query_result(
r'''
select Named { name, required active := is_active(Named) }
''',
results
)
await self.assert_query_result(
r'''
select Named { name, required active := is_active2(Named) }
''',
results
)
# swap the function to use def_cur_user and make sure it still works
await self.con.execute('''
alter function is_active(x: User) using (
select x.name = global def_cur_user);
''')
await self.con.execute('''
set global cur_user := "Carol";
''')
await self.con.execute('''
set global def_cur_user := "Bob";
''')
await self.assert_query_result(
r'''
select Named { name, required active := is_active(Named) }
''',
results
)
# An indirect call, to make sure it gets update that way
await self.assert_query_result(
r'''
select Named { name, required active := is_active2(Named) }
''',
results
) | )
await self.con.execute( | test_edgeql_globals_09 | python | geldata/gel | tests/test_edgeql_globals.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_globals.py | Apache-2.0 |
async def test_edgeql_globals_10(self):
await self.con.execute('''
set global cur_user := "test";
''')
await self.con.execute('''
set global cur_user := global cur_user ++ "!";
''')
await self.con.execute('''
set global cur_user := global cur_user ++ "!";
set global cur_user := global cur_user ++ "!";
''')
await self.assert_query_result(
r'''select global cur_user''',
['test!!!']
) | )
await self.con.execute( | test_edgeql_globals_10 | python | geldata/gel | tests/test_edgeql_globals.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_globals.py | Apache-2.0 |
async def test_edgeql_globals_11(self):
await self.con.execute('''
set global cur_user := "";
''')
await self.assert_query_result(
r'''select global cur_user''',
['']
)
await self.con.execute('''
set global cur_user := {};
''')
await self.assert_query_result(
r'''select global cur_user''',
[]
) | )
await self.assert_query_result(
r'''select global cur_user''',
['']
)
await self.con.execute( | test_edgeql_globals_11 | python | geldata/gel | tests/test_edgeql_globals.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_globals.py | Apache-2.0 |
async def test_edgeql_globals_13(self):
await self.con.execute('''
create global my_var -> str;
''')
await self.con.execute('''
set global my_var := <str>$my_param
''', my_param='hello')
await self.assert_query_result(
r'''select global my_var''',
['hello']
)
with self.assertRaisesRegex(
edgedb.QueryError,
'non-constant expression in CONFIGURE DATABASE SET',
):
await self.con.execute(
'''
configure current database
set query_execution_timeout := <duration>$0
''',
my_param='1 sec',
) | )
await self.con.execute( | test_edgeql_globals_13 | python | geldata/gel | tests/test_edgeql_globals.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_globals.py | Apache-2.0 |
async def test_edgeql_globals_15(self):
await self.con.execute('''
create global foo := 1;
''')
with self.assertRaisesRegex(
edgedb.ConfigurationError,
"global 'def_cur_user_excited' is computed from an expression "
"and cannot be modified",
):
await self.con.execute(
'''
reset global def_cur_user_excited
''',
) | )
with self.assertRaisesRegex(
edgedb.ConfigurationError,
"global 'def_cur_user_excited' is computed from an expression "
"and cannot be modified",
):
await self.con.execute( | test_edgeql_globals_15 | python | geldata/gel | tests/test_edgeql_globals.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_globals.py | Apache-2.0 |
async def test_edgeql_globals_state_cardinality(self):
await self.con.execute('''
set global cur_user := {};
''')
state = self.con._protocol.last_state
await self.con.execute('''
alter global cur_user {
set default := 'Bob';
set required;
}
''')
# Use the previous state that has no data for the required global
self.con._protocol.last_state = state
with self.assertRaises(edgedb.CardinalityViolationError):
await self.con.execute("select global cur_user")
self.con._protocol.last_state = None | )
state = self.con._protocol.last_state
await self.con.execute( | test_edgeql_globals_state_cardinality | python | geldata/gel | tests/test_edgeql_globals.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_globals.py | Apache-2.0 |
async def test_edgeql_globals_schema_types_01(self):
# Non-computed globals don't add a schema type
await self.con.execute('''
create global best_card -> str;
''')
await self.assert_query_result(
r'''
with module schema select Type { name }
filter .name ilike "%best_card%";
''',
[]
)
await self.con.execute('''
set global best_card := 'Dragon';
''')
await self.assert_query_result(
r'''
with module schema select Type { name }
filter .name ilike "%best_card%";
''',
[]
)
await self.con.execute('''
drop global best_card;
''')
await self.assert_query_result(
r'''
with module schema select Type { name }
filter .name ilike "%best_card%";
''',
[]
)
await self.con.execute('''
create module my_mod;
create global my_mod::best_card -> str;
''')
await self.assert_query_result(
r'''
with module schema select Type { name }
filter .name ilike "%best_card%";
''',
[]
)
await self.con.execute('''
set global my_mod::best_card := 'Dragon';
''')
await self.assert_query_result(
r'''
with module schema select Type { name }
filter .name ilike "%best_card%";
''',
[]
)
await self.con.execute('''
drop global my_mod::best_card;
''')
await self.assert_query_result(
r'''
with module schema select Type { name }
filter .name ilike "%best_card%";
''',
[]
) | )
await self.assert_query_result(
r | test_edgeql_globals_schema_types_01 | python | geldata/gel | tests/test_edgeql_globals.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_globals.py | Apache-2.0 |
async def test_edgeql_globals_schema_types_02(self):
# Computed scalar global adds a type
await self.con.execute('''
create global best_card := 'Dragon';
''')
await self.assert_query_result(
r'''
with module schema select Type { name }
filter .name ilike "%best_card%";
''',
[{'name': 'default::best_card'}]
)
await self.con.execute('''
drop global best_card;
''')
await self.assert_query_result(
r'''
with module schema select Type { name }
filter .name ilike "%best_card%";
''',
[]
)
await self.con.execute('''
create module my_mod;
create global my_mod::best_card := 'Dragon';
''')
await self.assert_query_result(
r'''
with module schema select Type { name }
filter .name ilike "%best_card%";
''',
[{'name': 'my_mod::best_card'}]
)
await self.con.execute('''
drop global my_mod::best_card;
''')
await self.assert_query_result(
r'''
with module schema select Type { name }
filter .name ilike "%best_card%";
''',
[]
) | )
await self.assert_query_result(
r | test_edgeql_globals_schema_types_02 | python | geldata/gel | tests/test_edgeql_globals.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_globals.py | Apache-2.0 |
async def test_edgeql_globals_schema_types_03(self):
# Computed object global adds a type
await self.con.execute('''
create global best_card := (
select Card filter .name = 'Dragon' limit 1
);
''')
await self.assert_query_result(
r'''
with module schema select Type { name }
filter .name ilike "%best_card%";
''',
[{'name': 'default::best_card'}]
)
await self.con.execute('''
drop global best_card;
''')
await self.assert_query_result(
r'''
with module schema select Type { name }
filter .name ilike "%best_card%";
''',
[]
)
await self.con.execute('''
create module my_mod;
create global my_mod::best_card := (
select Card filter .name = 'Dragon' limit 1
);
''')
await self.assert_query_result(
r'''
with module schema select Type { name }
filter .name ilike "%best_card%";
''',
[{'name': 'my_mod::best_card'}]
)
await self.con.execute('''
drop global my_mod::best_card;
''')
await self.assert_query_result(
r'''
with module schema select Type { name }
filter .name ilike "%best_card%";
''',
[]
) | )
await self.assert_query_result(
r | test_edgeql_globals_schema_types_03 | python | geldata/gel | tests/test_edgeql_globals.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_globals.py | Apache-2.0 |
async def test_edgeql_globals_schema_types_04(self):
# Computed object global with shape adds two types:
# - one for the global
# - one for the shape
await self.con.execute('''
create global best_card := (
select Card {name}
filter .name = 'Dragon' limit 1
);
''')
await self.assert_query_result(
r'''
with module schema select Type { name }
filter .name ilike "%best_card%"
order by .name;
''',
[
{'name': 'default::__best_card'},
{'name': 'default::best_card'},
]
)
await self.con.execute('''
drop global best_card;
''')
await self.assert_query_result(
r'''
with module schema select Type { name }
filter .name ilike "%best_card%";
''',
[]
)
await self.con.execute('''
create module my_mod;
create global my_mod::best_card := (
select Card {name}
filter .name = 'Dragon' limit 1
);
''')
await self.assert_query_result(
r'''
with module schema select Type { name }
filter .name ilike "%best_card%"
order by .name;
''',
[
{'name': 'my_mod::__best_card'},
{'name': 'my_mod::best_card'},
]
)
await self.con.execute('''
drop global my_mod::best_card;
''')
await self.assert_query_result(
r'''
with module schema select Type { name }
filter .name ilike "%best_card%";
''',
[]
) | )
await self.assert_query_result(
r | test_edgeql_globals_schema_types_04 | python | geldata/gel | tests/test_edgeql_globals.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_globals.py | Apache-2.0 |
def test_sphinx_eql_type_01(self):
src = '''
.. eql:type:: int64
descr
'''
out = self.build(src, format='xml')
x = requests_xml.XML(xml=out)
self.assertEqual(
x.xpath('''
//desc_signature
[@eql-fullname="std::int64"] /
desc_name / text()
'''),
['int64']) | out = self.build(src, format='xml')
x = requests_xml.XML(xml=out)
self.assertEqual(
x.xpath( | test_sphinx_eql_type_01 | python | geldata/gel | tests/test_docs_sphinx_ext.py | https://github.com/geldata/gel/blob/master/tests/test_docs_sphinx_ext.py | Apache-2.0 |
def test_sphinx_eql_type_06(self):
src = r'''
.. eql:type:: std::int64
An integer.
.. eql:type:: std::array
Array.
Testing :eql:type:`XXX <array<int64>>` ref.
Testing :eql:type:`array\<int64\>` ref.
Testing :eql:type:`array\<int64\> <array<int64>>` ref.
Testing :eql:type:`array\<array\<int64\>\>` ref.
'''
out = self.build(src, format='xml')
x = requests_xml.XML(xml=out)
self.assertEqual(
x.xpath('''
//paragraph /
reference[@eql-type="type"] /
literal / text()
'''),
['XXX', 'array<int64>', 'array<int64>', 'array<array<int64>>']) | out = self.build(src, format='xml')
x = requests_xml.XML(xml=out)
self.assertEqual(
x.xpath( | test_sphinx_eql_type_06 | python | geldata/gel | tests/test_docs_sphinx_ext.py | https://github.com/geldata/gel/blob/master/tests/test_docs_sphinx_ext.py | Apache-2.0 |
def test_sphinx_eql_type_07(self):
src = '''
.. eql:type:: int64
An integer.
Testing :eql:type:`OPTIONAL int64` ref.
Testing :eql:type:`OPTIONAL int64` ref.
Testing :eql:type:`SET OF int64` ref.
Testing :eql:type:`SET OF int64` ref.
'''
out = self.build(src, format='xml')
x = requests_xml.XML(xml=out)
self.assertEqual(
x.xpath('''
//paragraph /
reference[@eql-type="type"] /
literal / text()
'''),
['OPTIONAL int64', 'OPTIONAL int64',
'SET OF int64', 'SET OF int64']) | out = self.build(src, format='xml')
x = requests_xml.XML(xml=out)
self.assertEqual(
x.xpath( | test_sphinx_eql_type_07 | python | geldata/gel | tests/test_docs_sphinx_ext.py | https://github.com/geldata/gel/blob/master/tests/test_docs_sphinx_ext.py | Apache-2.0 |
def test_sphinx_eql_type_08(self):
src = '''
.. eql:type:: SET OF
An integer.
Testing :eql:type:`SET OF`.
Testing :eql:type:`XXX <SET OF>`.
'''
out = self.build(src, format='xml')
x = requests_xml.XML(xml=out)
self.assertEqual(
x.xpath('''
//paragraph /
reference[@eql-type="type"] /
literal / text()
'''),
['SET OF', 'XXX']) | out = self.build(src, format='xml')
x = requests_xml.XML(xml=out)
self.assertEqual(
x.xpath( | test_sphinx_eql_type_08 | python | geldata/gel | tests/test_docs_sphinx_ext.py | https://github.com/geldata/gel/blob/master/tests/test_docs_sphinx_ext.py | Apache-2.0 |
def test_sphinx_eql_func_01(self):
src = '''
Testing DESC !! :eql:func-desc:`test` !! >> ref.
.. eql:type:: std::int64
An integer.
.. eql:type:: any
any.
.. eql:function:: std::test(v: any) -> any
:index: xxx YyY
A super function.
Testing :eql:func:`XXX <test>` ref.
Testing :eql:func:`test` ref.
'''
out = self.build(src, format='xml')
x = requests_xml.XML(xml=out)
func = x.xpath('//desc[@desctype="function"]')
self.assertEqual(len(func), 1)
func = func[0]
self.assertEqual(func.attrs['summary'], 'A super function.')
self.assertIn('!! A super function. !!', out)
self.assertEqual(
x.xpath('//desc_returns / text()'),
['any'])
self.assertEqual(
x.xpath('''
//paragraph /
reference[@eql-type="function" and
@refid="function::std::test"] /
literal / text()
'''),
['XXX', 'test()'])
self.assertEqual(
x.xpath('''
//field[@eql-name="index"] / field_body / paragraph / text()
'''),
['xxx YyY']) | out = self.build(src, format='xml')
x = requests_xml.XML(xml=out)
func = x.xpath('//desc[@desctype="function"]')
self.assertEqual(len(func), 1)
func = func[0]
self.assertEqual(func.attrs['summary'], 'A super function.')
self.assertIn('!! A super function. !!', out)
self.assertEqual(
x.xpath('//desc_returns / text()'),
['any'])
self.assertEqual(
x.xpath( | test_sphinx_eql_func_01 | python | geldata/gel | tests/test_docs_sphinx_ext.py | https://github.com/geldata/gel/blob/master/tests/test_docs_sphinx_ext.py | Apache-2.0 |
def test_sphinx_eql_func_03(self):
src = '''
.. eql:function:: std::test(v: any) -> any
:type v: int64
blah
'''
expected = r'''(?xs)
found\sunknown\sfield\s'type' .*
Possible\sreason:\sfield\s'type'\sis\snot\ssupported
'''
with self.assert_fails(expected):
self.build(src) | expected = r'''(?xs)
found\sunknown\sfield\s'type' .*
Possible\sreason:\sfield\s'type'\sis\snot\ssupported | test_sphinx_eql_func_03 | python | geldata/gel | tests/test_docs_sphinx_ext.py | https://github.com/geldata/gel/blob/master/tests/test_docs_sphinx_ext.py | Apache-2.0 |
def test_sphinx_eql_constr_01(self):
src = '''
.. eql:type:: std::int64
An integer.
.. eql:type:: any
any.
.. eql:constraint:: std::max_len_value(v: any)
blah
Testing :eql:constraint:`XXX <max_len_value>` ref.
Testing :eql:constraint:`max_len_value` ref.
'''
out = self.build(src, format='xml')
x = requests_xml.XML(xml=out)
constr = x.xpath('//desc[@desctype="constraint"]')
self.assertEqual(len(constr), 1)
constr = constr[0]
self.assertEqual(constr.attrs['summary'], 'blah')
self.assertEqual(
x.xpath('''
//paragraph /
reference[@eql-type="constraint" and
@refid="constraint::std::max_len_value"] /
literal / text()
'''),
['XXX', 'max_len_value']) | out = self.build(src, format='xml')
x = requests_xml.XML(xml=out)
constr = x.xpath('//desc[@desctype="constraint"]')
self.assertEqual(len(constr), 1)
constr = constr[0]
self.assertEqual(constr.attrs['summary'], 'blah')
self.assertEqual(
x.xpath( | test_sphinx_eql_constr_01 | python | geldata/gel | tests/test_docs_sphinx_ext.py | https://github.com/geldata/gel/blob/master/tests/test_docs_sphinx_ext.py | Apache-2.0 |
def test_sphinx_eql_op_01(self):
src = '''
Testing ?? :eql:op-desc:`PLUS` ??.
.. eql:type:: int64
int64
.. eql:type:: str
123
.. eql:operator:: PLUS: A + B
:optype A: int64 or str
:optype B: int64 or str
:resulttype: int64 or str
Arithmetic addition.
some text
:eql:op:`XXX <PLUS>`
'''
out = self.build(src, format='xml')
x = requests_xml.XML(xml=out)
self.assertIn('Testing ?? Arithmetic addition. ??.', out)
self.assertEqual(
len(x.xpath('''
//desc_signature[@eql-name="PLUS" and @eql-signature="A + B"] /
*[
(self::desc_annotation and text()="operator") or
(self::desc_name and text()="A + B")
]
''')),
2)
self.assertEqual(len(x.xpath('//field[@eql-name="operand"]')), 2)
self.assertEqual(len(x.xpath('//field[@eql-name="resulttype"]')), 1)
self.assertEqual(
x.xpath('''
//paragraph /
reference[@eql-type="operator" and @refid="operator::PLUS"] /
literal / text()
'''),
['XXX']) | out = self.build(src, format='xml')
x = requests_xml.XML(xml=out)
self.assertIn('Testing ?? Arithmetic addition. ??.', out)
self.assertEqual(
len(x.xpath( | test_sphinx_eql_op_01 | python | geldata/gel | tests/test_docs_sphinx_ext.py | https://github.com/geldata/gel/blob/master/tests/test_docs_sphinx_ext.py | Apache-2.0 |
def test_sphinx_eql_op_02(self):
src = '''
.. eql:type:: any
123
.. eql:operator:: IS: A IS B
:optype A: any
:optype B: type
:resulttype: any
Is
:eql:op:`XXX <IS>`
'''
out = self.build(src, format='xml')
x = requests_xml.XML(xml=out)
self.assertEqual(
x.xpath('''
//field[@eql-opname="B"] /
field_body / * / literal_strong / text()
'''),
['B']) | out = self.build(src, format='xml')
x = requests_xml.XML(xml=out)
self.assertEqual(
x.xpath( | test_sphinx_eql_op_02 | python | geldata/gel | tests/test_docs_sphinx_ext.py | https://github.com/geldata/gel/blob/master/tests/test_docs_sphinx_ext.py | Apache-2.0 |
def test_sphinx_eql_kw_01(self):
src = '''
.. eql:keyword:: SET OF
blah
some text
:eql:kw:`XXX <SET OF>`
'''
out = self.build(src, format='xml')
x = requests_xml.XML(xml=out)
self.assertEqual(
len(x.xpath('''
//desc[@desctype="keyword"] /
desc_signature[@eql-name="SET OF"] /
*[
(self::desc_annotation and text()="keyword") or
(self::desc_name and text()="SET OF")
]
''')),
2)
self.assertEqual(
x.xpath('''
//paragraph /
reference[@eql-type="keyword" and @refid="keyword::SET-OF"] /
literal / text()
'''),
['XXX']) | out = self.build(src, format='xml')
x = requests_xml.XML(xml=out)
self.assertEqual(
len(x.xpath( | test_sphinx_eql_kw_01 | python | geldata/gel | tests/test_docs_sphinx_ext.py | https://github.com/geldata/gel/blob/master/tests/test_docs_sphinx_ext.py | Apache-2.0 |
def test_sphinx_eql_stmt_05(self):
src = '''
CREATE FUNCTION
===============
:eql-statement:
``CREATE FUNCTION``--creates a function.
fooing and baring.
Subhead
-------
asdasdas
CREATE TYPE
===========
:eql-statement:
blah.
Test
====
A ref to :eql:stmt:`create function`
A ref to :eql:stmt:`ttt <create type>`
'''
out = self.build(src, format='xml')
x = requests_xml.XML(xml=out)
self.assertEqual(
x.xpath('''
//paragraph /
reference[@eql-type="statement" and
@refid="statement::create-function"] /
literal / text()
'''),
['create function'])
self.assertEqual(
x.xpath('''
//paragraph /
reference[@eql-type="statement" and
@refid="statement::create-type"] /
literal / text()
'''),
['ttt'])
self.assertEqual(
x.xpath('''
//section[@eql-statement="true"]/@ids
'''),
['create-function statement::create-function',
'create-type statement::create-type'])
self.assertEqual(
x.xpath('''
//section[@eql-statement="true"]/@summary
'''),
['CREATE FUNCTION--creates a function.', 'blah.']) | out = self.build(src, format='xml')
x = requests_xml.XML(xml=out)
self.assertEqual(
x.xpath( | test_sphinx_eql_stmt_05 | python | geldata/gel | tests/test_docs_sphinx_ext.py | https://github.com/geldata/gel/blob/master/tests/test_docs_sphinx_ext.py | Apache-2.0 |
def test_sphinx_eql_stmt_10(self):
src = '''
=========
Functions
=========
:edb-alt-title: Functions and Operators
This section describes the DDL commands ...
CREATE FUNCTION
===============
:eql-statement:
Define a new function.
DROP FUNCTION
=============
:eql-statement:
:eql-haswith:
Remove a function.
'''
out = self.build(src, format='xml')
x = requests_xml.XML(xml=out)
self.assertEqual(
x.xpath('''
//section/title[text()="Functions"]/@edb-alt-title
'''),
['Functions and Operators'])
self.assertEqual(
x.xpath('''
//section[@eql-statement="true"]/title/text()
'''),
['CREATE FUNCTION', 'DROP FUNCTION'])
self.assertEqual(
x.xpath('''
//section[@eql-statement="true" and @eql-haswith="true"]
/title/text()
'''),
['DROP FUNCTION']) | out = self.build(src, format='xml')
x = requests_xml.XML(xml=out)
self.assertEqual(
x.xpath( | test_sphinx_eql_stmt_10 | python | geldata/gel | tests/test_docs_sphinx_ext.py | https://github.com/geldata/gel/blob/master/tests/test_docs_sphinx_ext.py | Apache-2.0 |
def test_sphinx_eql_struct_01(self):
src = '''
.. eql:struct:: edb.protocol.AuthenticationSASLFinal
.. eql:struct:: edb.protocol.enums.Cardinality
'''
out = self.build(src, format='xml')
x = requests_xml.XML(xml=out)
self.assertEqual(
x.xpath('''
literal_block/@language
'''),
['c', 'c'])
val = x.xpath('''
literal_block/text()
''')
self.assertIn('struct AuthenticationSASLFinal {', val[0])
self.assertIn('enum Cardinality {', val[1]) | out = self.build(src, format='xml')
x = requests_xml.XML(xml=out)
self.assertEqual(
x.xpath( | test_sphinx_eql_struct_01 | python | geldata/gel | tests/test_docs_sphinx_ext.py | https://github.com/geldata/gel/blob/master/tests/test_docs_sphinx_ext.py | Apache-2.0 |
def test_sphinx_eql_inline_role_01(self):
src = '''
a test of :eql:synopsis:`WITH <aaaa>`.
'''
out = self.build(src, format='xml')
x = requests_xml.XML(xml=out)
self.assertEqual(
x.xpath('''
//literal[@eql-lang="edgeql-synopsis"] / text()
'''),
['WITH <aaaa>']) | out = self.build(src, format='xml')
x = requests_xml.XML(xml=out)
self.assertEqual(
x.xpath( | test_sphinx_eql_inline_role_01 | python | geldata/gel | tests/test_docs_sphinx_ext.py | https://github.com/geldata/gel/blob/master/tests/test_docs_sphinx_ext.py | Apache-2.0 |
def test_sphinx_eql_blockquote_02(self):
# Test that although regular block-qoutes are blocked
# (as their syntax is very confusing and fragile), we can
# still use explicit block-quotes via the `.. pull-quote::`
# directive.
src = '''
blah
.. pull-quote::
spam
blah2
'''
out = self.build(src, format='xml')
x = requests_xml.XML(xml=out)
self.assertEqual(
x.xpath('''
block_quote/*/text()
'''),
['spam']
) | out = self.build(src, format='xml')
x = requests_xml.XML(xml=out)
self.assertEqual(
x.xpath( | test_sphinx_eql_blockquote_02 | python | geldata/gel | tests/test_docs_sphinx_ext.py | https://github.com/geldata/gel/blob/master/tests/test_docs_sphinx_ext.py | Apache-2.0 |
def test_sphinx_edb_collapsed_01(self):
src = '''
blah
Foo
===
bar
.. edb:collapsed::
spam
ham
blah2
'''
out = self.build(src, format='xml')
x = requests_xml.XML(xml=out)
self.assertEqual(
x.xpath('''
//container[@collapsed_block="True"]/paragraph/text()
'''),
['spam', 'ham']) | out = self.build(src, format='xml')
x = requests_xml.XML(xml=out)
self.assertEqual(
x.xpath( | test_sphinx_edb_collapsed_01 | python | geldata/gel | tests/test_docs_sphinx_ext.py | https://github.com/geldata/gel/blob/master/tests/test_docs_sphinx_ext.py | Apache-2.0 |
def test_sphinx_edb_brand_name_01(self):
src = '''
blah |Gel|
blah2 |Gel's|
'''
out = self.build(src, format='xml')
x = requests_xml.XML(xml=out)
self.assertEqual(
x.xpath('''
//paragraph/inline[@edb-substitution="true"]/text()
'''),
["Gel", "Gel's"]) | out = self.build(src, format='xml')
x = requests_xml.XML(xml=out)
self.assertEqual(
x.xpath( | test_sphinx_edb_brand_name_01 | python | geldata/gel | tests/test_docs_sphinx_ext.py | https://github.com/geldata/gel/blob/master/tests/test_docs_sphinx_ext.py | Apache-2.0 |
def test_sphinx_edb_brand_name_02(self):
src = '''
blah |gelcmd|
blah 2 :gelcmd:`migrate --help`
blah 3 :gelcmd:`migrate
--help
--foo`
blah4 |geluri|
blah5 :geluri:`foo:bar@nax/a:123#12`
blah6 :dotgel:`default`
blah7 :gelenv:`HOST`
blah8 :gelenv:`HOST=AB`
DONE
'''
out = self.build(src, format='xml')
x = requests_xml.XML(xml=out)
self.assertEqual(
x.xpath('''
//paragraph/literal
[@edb-substitution="true"]
[@edb-gelcmd="true"]
[@edb-gelcmd-top="true"]
/ text()
'''),
['gel']
)
self.assertEqual(
x.xpath('''
//paragraph/literal
[@edb-substitution="true"]
[@edb-gelcmd="true"]
[@edb-gelcmd-top="false"]
/ text()
'''),
['gel migrate --help', 'gel migrate --help --foo']
)
self.assertEqual(
x.xpath('''
//paragraph/literal
[@edb-substitution="true"]
[@edb-geluri="true"]
/ text()
'''),
['gel://', 'gel://foo:bar@nax/a:123#12']
)
self.assertEqual(
x.xpath('''
//paragraph/literal
[@edb-substitution="true"]
[@edb-dotgel="true"]
/ text()
'''),
['default.gel']
)
self.assertEqual(
x.xpath('''
//paragraph/literal
[@edb-substitution="true"]
[@edb-gelenv="true"]
/ text()
'''),
['GEL_HOST', 'GEL_HOST=AB']
) | out = self.build(src, format='xml')
x = requests_xml.XML(xml=out)
self.assertEqual(
x.xpath( | test_sphinx_edb_brand_name_02 | python | geldata/gel | tests/test_docs_sphinx_ext.py | https://github.com/geldata/gel/blob/master/tests/test_docs_sphinx_ext.py | Apache-2.0 |
async def test_edgeql_ext_pg_unaccent_02(self):
await self.assert_query_result(
"""
select fts::search(
Post, 'resuming', language := 'eng'
).object { title, body }
""",
[{'title': None, 'body': 'Resumè'}],
)
await self.assert_query_result(
"""
select fts::search(
Post, 'Resumè', language := 'eng'
).object { title, body }
""",
[{'title': 'Resumè', 'body': None}],
) | select fts::search(
Post, 'resuming', language := 'eng'
).object { title, body }
""",
[{'title': None, 'body': 'Resumè'}],
)
await self.assert_query_result( | test_edgeql_ext_pg_unaccent_02 | python | geldata/gel | tests/test_edgeql_ext_pg_unaccent.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ext_pg_unaccent.py | Apache-2.0 |
def test_edgeql_select_interpreter_computable_15(self):
self.execute(
"""\
SELECT Issue{
name,
number,
foo := {1, 2}
}
FILTER Issue.number = '1';
"""
) | \
SELECT Issue{
name,
number,
foo := {1, 2}
}
FILTER Issue.number = '1'; | test_edgeql_select_interpreter_computable_15 | python | geldata/gel | tests/test_edgeql_select_interpreter.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_select_interpreter.py | Apache-2.0 |
def test_edgeql_select_interpreter_computable_17(self):
self.execute(
"""\
WITH
V := (SELECT Issue {
foo := {1, 2}
} FILTER .number = '1')
SELECT
V {
foo := .foo
};
"""
) | \
WITH
V := (SELECT Issue {
foo := {1, 2}
} FILTER .number = '1')
SELECT
V {
foo := .foo
}; | test_edgeql_select_interpreter_computable_17 | python | geldata/gel | tests/test_edgeql_select_interpreter.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_select_interpreter.py | Apache-2.0 |
def test_edgeql_select_interpreter_computable_18(self):
self.execute(
'''
INSERT Publication {
title := 'aaa'
}
'''
)
self.assert_query_result(
r"""
SELECT Publication {
title,
title1,
title2,
title3,
title4,
title5,
title6,
}
FILTER .title = 'aaa'
""",
[
{
'title': 'aaa',
'title1': 'aaa',
'title2': 'aaa',
'title3': 'aaa',
'title4': 'aaa',
'title5': ['aaa'],
'title6': ['aaa'],
}
],
) | INSERT Publication {
title := 'aaa'
} | test_edgeql_select_interpreter_computable_18 | python | geldata/gel | tests/test_edgeql_select_interpreter.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_select_interpreter.py | Apache-2.0 |
def test_edgeql_select_interpreter_computable_32(self):
self.assert_query_result(
r"""
SELECT _ := (User {x := .name}.x, (SELECT User.name)) ORDER BY _;
""",
[
['Elvis', 'Elvis'],
['Yury', 'Yury'],
],
)
self.assert_query_result(
r"""
SELECT _ := ((SELECT User.name), User {x := .name}.x) ORDER BY _;
""",
[
['Elvis', 'Elvis'],
['Yury', 'Yury'],
],
)
self.assert_query_result(
r"""
SELECT _ := ((SELECT User.name), (User {x := .name},).0.x)
ORDER BY _;
""",
[
['Elvis', 'Elvis'],
['Yury', 'Yury'],
],
) | ,
[
['Elvis', 'Elvis'],
['Yury', 'Yury'],
],
)
self.assert_query_result(
r | test_edgeql_select_interpreter_computable_32 | python | geldata/gel | tests/test_edgeql_select_interpreter.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_select_interpreter.py | Apache-2.0 |
def test_edgeql_select_interpreter_computable_33(self):
self.assert_query_result(
r"""
SELECT User {name, todo_ids := .todo.id} FILTER .name = 'Elvis';
""",
[
{'name': 'Elvis', 'todo_ids': [str, str]},
],
)
self.assert_query_result(
r"""
WITH Z := (SELECT User {
asdf := (SELECT .todo ORDER BY .number LIMIT 1)})
SELECT Z {name, asdf_id := .asdf.id} FILTER .name = 'Elvis';
""",
[
{'name': 'Elvis', 'asdf_id': str},
],
) | ,
[
{'name': 'Elvis', 'todo_ids': [str, str]},
],
)
self.assert_query_result(
r | test_edgeql_select_interpreter_computable_33 | python | geldata/gel | tests/test_edgeql_select_interpreter.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_select_interpreter.py | Apache-2.0 |
def test_edgeql_select_interpreter_computable_34(self):
self.execute(
"""\
SELECT Issue{
number,
foo := .owner.todo UNION .owner.todo,
}
FILTER Issue.number = '1';
"""
) | \
SELECT Issue{
number,
foo := .owner.todo UNION .owner.todo,
}
FILTER Issue.number = '1'; | test_edgeql_select_interpreter_computable_34 | python | geldata/gel | tests/test_edgeql_select_interpreter.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_select_interpreter.py | Apache-2.0 |
def test_edgeql_select_interpreter_match_01(self):
self.assert_query_result(
r"""
SELECT
Issue {number}
FILTER
Issue.name LIKE '%edgedb'
ORDER BY Issue.number;
""",
[],
)
self.assert_query_result(
r"""
SELECT
Issue {number}
FILTER
Issue.name LIKE '%EdgeDB'
ORDER BY Issue.number;
""",
[{'number': '1'}],
)
self.assert_query_result(
r"""
SELECT
Issue {number}
FILTER
Issue.name LIKE '%Edge%'
ORDER BY Issue.number;
""",
[{'number': '1'}, {'number': '2'}],
) | ,
[],
)
self.assert_query_result(
r | test_edgeql_select_interpreter_match_01 | python | geldata/gel | tests/test_edgeql_select_interpreter.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_select_interpreter.py | Apache-2.0 |
def test_edgeql_select_interpreter_match_02(self):
self.assert_query_result(
r"""
SELECT
Issue {number}
FILTER
Issue.name NOT LIKE '%edgedb'
ORDER BY Issue.number;
""",
[
{'number': '1'},
{'number': '2'},
{'number': '3'},
{'number': '4'},
],
)
self.assert_query_result(
r"""
SELECT
Issue {number}
FILTER
Issue.name NOT LIKE '%EdgeDB'
ORDER BY Issue.number;
""",
[{'number': '2'}, {'number': '3'}, {'number': '4'}],
)
self.assert_query_result(
r"""
SELECT
Issue {number}
FILTER
Issue.name NOT LIKE '%Edge%'
ORDER BY Issue.number;
""",
[{'number': '3'}, {'number': '4'}],
) | ,
[
{'number': '1'},
{'number': '2'},
{'number': '3'},
{'number': '4'},
],
)
self.assert_query_result(
r | test_edgeql_select_interpreter_match_02 | python | geldata/gel | tests/test_edgeql_select_interpreter.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_select_interpreter.py | Apache-2.0 |
def test_edgeql_select_interpreter_match_03(self):
self.assert_query_result(
r"""
SELECT
Issue {number}
FILTER
Issue.name ILIKE '%edgedb'
ORDER BY Issue.number;
""",
[{'number': '1'}],
)
self.assert_query_result(
r"""
SELECT
Issue {number}
FILTER
Issue.name ILIKE '%EdgeDB'
ORDER BY Issue.number;
""",
[{'number': '1'}],
)
self.assert_query_result(
r"""
SELECT
Issue {number}
FILTER
Issue.name ILIKE '%re%'
ORDER BY Issue.number;
""",
[
{'number': '1'},
{'number': '2'},
{'number': '3'},
{'number': '4'},
],
) | ,
[{'number': '1'}],
)
self.assert_query_result(
r | test_edgeql_select_interpreter_match_03 | python | geldata/gel | tests/test_edgeql_select_interpreter.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_select_interpreter.py | Apache-2.0 |
def test_edgeql_select_interpreter_match_04(self):
self.assert_query_result(
r"""
SELECT
Issue {number}
FILTER
Issue.name NOT ILIKE '%edgedb'
ORDER BY Issue.number;
""",
[{'number': '2'}, {'number': '3'}, {'number': '4'}],
)
self.assert_query_result(
r"""
SELECT
Issue {number}
FILTER
Issue.name NOT ILIKE '%EdgeDB'
ORDER BY Issue.number;
""",
[{'number': '2'}, {'number': '3'}, {'number': '4'}],
)
self.assert_query_result(
r"""
SELECT
Issue {number}
FILTER
Issue.name NOT ILIKE '%re%'
ORDER BY Issue.number;
""",
[],
) | ,
[{'number': '2'}, {'number': '3'}, {'number': '4'}],
)
self.assert_query_result(
r | test_edgeql_select_interpreter_match_04 | python | geldata/gel | tests/test_edgeql_select_interpreter.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_select_interpreter.py | Apache-2.0 |
def test_edgeql_select_interpreter_match_07(self):
self.assert_query_result(
r"""
SELECT
Text {body}
FILTER
re_test('ed', Text.body)
ORDER BY Text.body;
""",
[
{'body': 'EdgeDB needs to happen soon.'},
{'body': 'Fix regression introduced by lexer tweak.'},
{
'body': 'We need to be able to render data in tabular format.' # NoQA
},
],
)
self.assert_query_result(
r"""
SELECT
Text {body}
FILTER
re_test('eD', Text.body)
ORDER BY Text.body;
""",
[
{'body': 'EdgeDB needs to happen soon.'},
{'body': 'Initial public release of EdgeDB.'},
],
)
self.assert_query_result(
r"""
SELECT
Text {body}
FILTER
re_test(r'ed([S\s]|$)', Text.body)
ORDER BY Text.body;
""",
[
{'body': 'Fix regression introduced by lexer tweak.'},
{
'body':
'We need to be able to render data in tabular format.'
},
],
) | ,
[
{'body': 'EdgeDB needs to happen soon.'},
{'body': 'Fix regression introduced by lexer tweak.'},
{
'body': 'We need to be able to render data in tabular format.' # NoQA
},
],
)
self.assert_query_result(
r | test_edgeql_select_interpreter_match_07 | python | geldata/gel | tests/test_edgeql_select_interpreter.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_select_interpreter.py | Apache-2.0 |
def test_edgeql_select_interpreter_match_08(self):
self.assert_query_result(
r"""
SELECT
Text {body}
FILTER
re_test('(?i)ed', Text.body)
ORDER BY Text.body;
""",
[
{'body': 'EdgeDB needs to happen soon.'},
{'body': 'Fix regression introduced by lexer tweak.'},
{'body': 'Initial public release of EdgeDB.'},
{
'body':
'We need to be able to render data in tabular format.'
},
],
)
self.assert_query_result(
r"""
SELECT
Text {body}
FILTER
re_test('(?i)eD', Text.body)
ORDER BY Text.body;
""",
[
{'body': 'EdgeDB needs to happen soon.'},
{'body': 'Fix regression introduced by lexer tweak.'},
{'body': 'Initial public release of EdgeDB.'},
{
'body':
'We need to be able to render data in tabular format.'
},
],
)
self.assert_query_result(
r"""
SELECT
Text {body}
FILTER
re_test(r'(?i)ed([S\s]|$)', Text.body)
ORDER BY Text.body;
""",
[
{'body': 'EdgeDB needs to happen soon.'},
{'body': 'Fix regression introduced by lexer tweak.'},
{
'body':
'We need to be able to render data in tabular format.'
},
],
) | ,
[
{'body': 'EdgeDB needs to happen soon.'},
{'body': 'Fix regression introduced by lexer tweak.'},
{'body': 'Initial public release of EdgeDB.'},
{
'body':
'We need to be able to render data in tabular format.'
},
],
)
self.assert_query_result(
r | test_edgeql_select_interpreter_match_08 | python | geldata/gel | tests/test_edgeql_select_interpreter.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_select_interpreter.py | Apache-2.0 |
def test_edgeql_select_interpreter_limit_01(self):
self.assert_query_result(
r'''
SELECT
Issue {number}
ORDER BY Issue.number
OFFSET 2;
''',
[{'number': '3'}, {'number': '4'}],
)
self.assert_query_result(
r'''
SELECT
Issue {number}
ORDER BY Issue.number
LIMIT 3;
''',
[{'number': '1'}, {'number': '2'}, {'number': '3'}],
)
self.assert_query_result(
r'''
SELECT
Issue {number}
ORDER BY Issue.number
OFFSET 2 LIMIT 3;
''',
[{'number': '3'}, {'number': '4'}],
) | ,
[{'number': '3'}, {'number': '4'}],
)
self.assert_query_result(
r | test_edgeql_select_interpreter_limit_01 | python | geldata/gel | tests/test_edgeql_select_interpreter.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_select_interpreter.py | Apache-2.0 |
def test_edgeql_select_interpreter_limit_02(self):
self.assert_query_result(
r'''
SELECT
Issue {number}
ORDER BY Issue.number
OFFSET 1 + 1;
''',
[{'number': '3'}, {'number': '4'}],
)
self.assert_query_result(
r'''
SELECT
Issue {number}
ORDER BY Issue.number
LIMIT 6 // 2;
''',
[{'number': '1'}, {'number': '2'}, {'number': '3'}],
)
self.assert_query_result(
r'''
SELECT
Issue {number}
ORDER BY Issue.number
OFFSET 4 - 2 LIMIT 5 * 2 - 7;
''',
[{'number': '3'}, {'number': '4'}],
) | ,
[{'number': '3'}, {'number': '4'}],
)
self.assert_query_result(
r | test_edgeql_select_interpreter_limit_02 | python | geldata/gel | tests/test_edgeql_select_interpreter.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_select_interpreter.py | Apache-2.0 |
def test_edgeql_select_interpreter_limit_03(self):
self.assert_query_result(
r'''
SELECT
Issue {number}
ORDER BY Issue.number
OFFSET (SELECT count(Status));
''',
[{'number': '3'}, {'number': '4'}],
)
self.assert_query_result(
r'''
SELECT
Issue {number}
ORDER BY Issue.number
LIMIT (SELECT count(Status) + 1);
''',
[{'number': '1'}, {'number': '2'}, {'number': '3'}],
)
self.assert_query_result(
r'''
SELECT
Issue {number}
ORDER BY Issue.number
OFFSET (SELECT count(Status))
LIMIT (SELECT count(Priority) + 1);
''',
[{'number': '3'}, {'number': '4'}],
) | ,
[{'number': '3'}, {'number': '4'}],
)
self.assert_query_result(
r | test_edgeql_select_interpreter_limit_03 | python | geldata/gel | tests/test_edgeql_select_interpreter.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_select_interpreter.py | Apache-2.0 |
def test_edgeql_select_interpreter_limit_10(self):
with self.assertRaisesRegex(ValueError, r'LIMIT must not be negative'):
self.execute(
"""
SELECT 1 LIMIT -1
"""
) | SELECT 1 LIMIT -1 | test_edgeql_select_interpreter_limit_10 | python | geldata/gel | tests/test_edgeql_select_interpreter.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_select_interpreter.py | Apache-2.0 |
def test_edgeql_select_interpreter_offset_01(self):
with self.assertRaisesRegex(
ValueError, r'OFFSET must not be negative'
):
self.execute(
"""
SELECT 1 OFFSET -1
"""
) | SELECT 1 OFFSET -1 | test_edgeql_select_interpreter_offset_01 | python | geldata/gel | tests/test_edgeql_select_interpreter.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_select_interpreter.py | Apache-2.0 |
def test_edgeql_select_interpreter_tvariant_bad_01(self):
self.execute(
"""
SELECT User {
name := 1
}
"""
) | SELECT User {
name := 1
} | test_edgeql_select_interpreter_tvariant_bad_01 | python | geldata/gel | tests/test_edgeql_select_interpreter.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_select_interpreter.py | Apache-2.0 |
def test_edgeql_select_interpreter_tvariant_bad_02(self):
self.execute(
"""
SELECT User {
name := Issue
}
"""
) | SELECT User {
name := Issue
} | test_edgeql_select_interpreter_tvariant_bad_02 | python | geldata/gel | tests/test_edgeql_select_interpreter.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_select_interpreter.py | Apache-2.0 |
def test_edgeql_select_interpreter_tvariant_bad_03(self):
self.execute(
"""
SELECT Issue {
related_to := 1
}
"""
) | SELECT Issue {
related_to := 1
} | test_edgeql_select_interpreter_tvariant_bad_03 | python | geldata/gel | tests/test_edgeql_select_interpreter.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_select_interpreter.py | Apache-2.0 |
def test_edgeql_select_interpreter_tvariant_bad_04(self):
self.execute(
"""
SELECT Issue {
related_to := Text
}
"""
) | SELECT Issue {
related_to := Text
} | test_edgeql_select_interpreter_tvariant_bad_04 | python | geldata/gel | tests/test_edgeql_select_interpreter.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_select_interpreter.py | Apache-2.0 |
def test_edgeql_select_interpreter_tvariant_bad_05(self):
self.execute(
"""
SELECT Issue {
priority := Priority
}
"""
) | SELECT Issue {
priority := Priority
} | test_edgeql_select_interpreter_tvariant_bad_05 | python | geldata/gel | tests/test_edgeql_select_interpreter.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_select_interpreter.py | Apache-2.0 |
def test_edgeql_select_interpreter_tvariant_bad_06(self):
self.execute(
"""
SELECT Issue {
multi owner := User
}
"""
) | SELECT Issue {
multi owner := User
} | test_edgeql_select_interpreter_tvariant_bad_06 | python | geldata/gel | tests/test_edgeql_select_interpreter.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_select_interpreter.py | Apache-2.0 |
def test_edgeql_select_interpreter_tvariant_bad_07(self):
self.execute(
"""
SELECT Issue {
single related_to := (SELECT Issue LIMIT 1)
}
"""
) | SELECT Issue {
single related_to := (SELECT Issue LIMIT 1)
} | test_edgeql_select_interpreter_tvariant_bad_07 | python | geldata/gel | tests/test_edgeql_select_interpreter.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_select_interpreter.py | Apache-2.0 |
def test_edgeql_select_interpreter_tvariant_bad_08(self):
self.execute(
"""
SELECT Issue {
owner := (SELECT User LIMIT 1)
}
"""
) | SELECT Issue {
owner := (SELECT User LIMIT 1)
} | test_edgeql_select_interpreter_tvariant_bad_08 | python | geldata/gel | tests/test_edgeql_select_interpreter.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_select_interpreter.py | Apache-2.0 |
def test_edgeql_select_interpreter_setops_19(self):
self.assert_query_result(
r"""
# UNION between Issue and empty set Issue should be
# duck-typed to be effectively equivalent to Issue[IS
# Issue], which is just an Issue.
SELECT (Issue UNION <Issue>{}).name;
""",
{
'Release EdgeDB',
'Improve EdgeDB repl output rendering.',
'Repl tweak.',
'Regression.',
},
)
self.assert_query_result(
r"""
SELECT (Issue UNION <Issue>{}).number;
""",
{'1', '2', '3', '4'},
) | ,
{
'Release EdgeDB',
'Improve EdgeDB repl output rendering.',
'Repl tweak.',
'Regression.',
},
)
self.assert_query_result(
r | test_edgeql_select_interpreter_setops_19 | python | geldata/gel | tests/test_edgeql_select_interpreter.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_select_interpreter.py | Apache-2.0 |
def test_edgeql_select_interpreter_setops_24(self):
# Establish that EXCEPT and INTERSECT filter out the objects we'd
# expect.
self.assert_query_result(
r"""
with A := Owned except {LogEntry, Comment}
select all(A in Issue) and all(Issue in A)
""",
{True},
)
self.assert_query_result(
r"""
with A := Owned intersect Issue
select all(A in Owned[is Issue]) and all(Owned[is Issue] in A)
""",
{True},
) | ,
{True},
)
self.assert_query_result(
r | test_edgeql_select_interpreter_setops_24 | python | geldata/gel | tests/test_edgeql_select_interpreter.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_select_interpreter.py | Apache-2.0 |
def test_edgeql_select_interpreter_setops_25(self):
# Establish that EXCEPT and INTERSECT filter out the objects we'd
# expect.
self.assert_query_result(
r"""
with
A := (select Issue filter .name ilike '%edgedb%'),
B := (select Issue filter .owner.name = 'Elvis')
select (B except A) {name};
""",
[
{'name': 'Regression.'},
],
)
self.assert_query_result(
r"""
with
A := (select Issue filter .name ilike '%edgedb%'),
B := (select Issue filter .owner.name = 'Elvis')
select (B intersect A) {name};
""",
[
{'name': 'Release EdgeDB'},
],
) | ,
[
{'name': 'Regression.'},
],
)
self.assert_query_result(
r | test_edgeql_select_interpreter_setops_25 | python | geldata/gel | tests/test_edgeql_select_interpreter.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_select_interpreter.py | Apache-2.0 |
def test_edgeql_select_interpreter_setops_26(self):
# Establish that EXCEPT and INTERSECT filter out the objects we'd
# expect.
self.assert_query_result(
r"""
select (Issue except Named);
""",
[],
)
self.assert_query_result(
r"""
select (Issue intersect <Named>{});
""",
[],
) | ,
[],
)
self.assert_query_result(
r | test_edgeql_select_interpreter_setops_26 | python | geldata/gel | tests/test_edgeql_select_interpreter.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_select_interpreter.py | Apache-2.0 |
def test_edgeql_select_interpreter_setops_27(self):
self.assert_query_result(
r"""
with
A := (select Issue filter .name not ilike '%edgedb%').body
select _ :=
str_lower(array_unpack(str_split(A, ' ')))
except
{'minor', 'fix', 'lexer'}
order by _
""",
[
"by",
"introduced",
"lexer",
"regression",
"tweak.",
"tweaks.",
],
)
self.assert_query_result(
r"""
with A := (select Issue filter .name not ilike '%edgedb%')
select _ :=
str_lower(array_unpack(str_split(A.body, ' ')))
except
str_lower(array_unpack(str_split(A.name, ' ')))
order by _
""",
[
"by",
"fix",
"introduced",
"lexer",
"lexer",
"minor",
"regression",
"tweaks.",
],
) | ,
[
"by",
"introduced",
"lexer",
"regression",
"tweak.",
"tweaks.",
],
)
self.assert_query_result(
r | test_edgeql_select_interpreter_setops_27 | python | geldata/gel | tests/test_edgeql_select_interpreter.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_select_interpreter.py | Apache-2.0 |
def test_edgeql_select_interpreter_setops_28(self):
self.assert_query_result(
r"""
select _ :=
len(array_unpack(str_split(Issue.body, ' ')))
intersect {1, 2, 2, 3, 3, 3, 7, 7, 7, 7, 7, 7, 7}
order by _
""",
[2, 2, 3, 7, 7, 7, 7, 7, 7],
)
self.assert_query_result(
r"""
select _ :=
str_lower(array_unpack(str_split(Issue.name, ' ')))
except
str_lower(array_unpack(str_split(Issue.body, ' ')))
order by _
""",
[
"edgedb",
"edgedb",
"improve",
"output",
"regression.",
"rendering.",
"repl",
"repl",
],
) | ,
[2, 2, 3, 7, 7, 7, 7, 7, 7],
)
self.assert_query_result(
r | test_edgeql_select_interpreter_setops_28 | python | geldata/gel | tests/test_edgeql_select_interpreter.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_select_interpreter.py | Apache-2.0 |
def test_edgeql_select_interpreter_order_01(self):
self.assert_query_result(
r'''
SELECT Issue {name}
ORDER BY Issue.priority.name ASC EMPTY LAST THEN Issue.name;
''',
[
{'name': 'Improve EdgeDB repl output rendering.'},
{'name': 'Repl tweak.'},
{'name': 'Regression.'},
{'name': 'Release EdgeDB'},
],
)
self.assert_query_result(
r'''
SELECT Issue {name}
ORDER BY Issue.priority.name ASC EMPTY FIRST THEN Issue.name;
''',
[
{'name': 'Regression.'},
{'name': 'Release EdgeDB'},
{'name': 'Improve EdgeDB repl output rendering.'},
{'name': 'Repl tweak.'},
],
) | ,
[
{'name': 'Improve EdgeDB repl output rendering.'},
{'name': 'Repl tweak.'},
{'name': 'Regression.'},
{'name': 'Release EdgeDB'},
],
)
self.assert_query_result(
r | test_edgeql_select_interpreter_order_01 | python | geldata/gel | tests/test_edgeql_select_interpreter.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_select_interpreter.py | Apache-2.0 |
def test_edgeql_select_interpreter_func_01(self):
self.assert_query_result(
r'''
SELECT std::len(User.name) ORDER BY User.name;
''',
[5, 4],
)
self.assert_query_result(
r'''
SELECT std::sum(<std::int64>Issue.number);
''',
[10],
) | ,
[5, 4],
)
self.assert_query_result(
r | test_edgeql_select_interpreter_func_01 | python | geldata/gel | tests/test_edgeql_select_interpreter.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_select_interpreter.py | Apache-2.0 |
def test_edgeql_select_interpreter_exists_01(self):
self.assert_query_result(
r'''
SELECT
Issue {
number
}
FILTER
NOT EXISTS Issue.time_estimate
ORDER BY
Issue.number;
''',
[{'number': '2'}, {'number': '3'}, {'number': '4'}],
)
self.assert_query_result(
r'''
SELECT
Issue {
number
}
FILTER
EXISTS Issue.time_estimate
ORDER BY
Issue.number;
''',
[{'number': '1'}],
) | ,
[{'number': '2'}, {'number': '3'}, {'number': '4'}],
)
self.assert_query_result(
r | test_edgeql_select_interpreter_exists_01 | python | geldata/gel | tests/test_edgeql_select_interpreter.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_select_interpreter.py | Apache-2.0 |
def test_edgeql_select_interpreter_coalesce_03(self):
issues_h = self.execute(
r'''
SELECT Issue{number}
FILTER
Issue.priority.name = 'High'
ORDER BY Issue.number;
'''
)
issues_n = self.execute(
r'''
SELECT Issue{number}
FILTER
NOT EXISTS Issue.priority
ORDER BY Issue.number;
'''
)
self.assert_query_result(
r'''
SELECT Issue{number}
FILTER
Issue.priority.name ?? 'High' = 'High'
ORDER BY
Issue.priority.name EMPTY LAST THEN Issue.number;
''',
[{'number': o['number']} for o in [*issues_h, *issues_n]],
) | )
issues_n = self.execute(
r | test_edgeql_select_interpreter_coalesce_03 | python | geldata/gel | tests/test_edgeql_select_interpreter.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_select_interpreter.py | Apache-2.0 |
def test_edgeql_select_interpreter_or_01(self):
issues_h = self.execute(
r'''
SELECT Issue{number}
FILTER
Issue.priority.name = 'High'
ORDER BY Issue.number;
'''
)
issues_l = self.execute(
r'''
SELECT Issue{number}
FILTER
Issue.priority.name = 'Low'
ORDER BY Issue.number;
'''
)
self.assert_query_result(
r'''
SELECT Issue{number}
FILTER
Issue.priority.name = 'High'
OR
Issue.priority.name = 'Low'
ORDER BY Issue.priority.name THEN Issue.number;
''',
[{'number': o['number']} for o in [*issues_h, *issues_l]],
) | )
issues_l = self.execute(
r | test_edgeql_select_interpreter_or_01 | python | geldata/gel | tests/test_edgeql_select_interpreter.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_select_interpreter.py | Apache-2.0 |
def test_edgeql_select_interpreter_or_04(self):
self.assert_query_result(
r'''
SELECT Issue{number}
FILTER
Issue.priority.name = 'High'
OR
Issue.status.name = 'Closed'
ORDER BY Issue.number;
''',
[{'number': '2'}, {'number': '3'}],
)
self.assert_query_result(
r'''
SELECT Issue{number}
FILTER
Issue.priority.name = 'High'
OR
Issue.priority.name = 'Low'
OR
Issue.status.name = 'Closed'
ORDER BY Issue.number;
''',
# it so happens that all low priority issues are also closed
[{'number': '2'}, {'number': '3'}],
)
self.assert_query_result(
r'''
SELECT Issue{number}
FILTER
Issue.priority.name IN {'High', 'Low'}
OR
Issue.status.name = 'Closed'
ORDER BY Issue.number;
''',
[{'number': '2'}, {'number': '3'}],
) | ,
[{'number': '2'}, {'number': '3'}],
)
self.assert_query_result(
r | test_edgeql_select_interpreter_or_04 | python | geldata/gel | tests/test_edgeql_select_interpreter.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_select_interpreter.py | Apache-2.0 |
def test_edgeql_select_interpreter_or_05(self):
self.assert_query_result(
r'''
SELECT Issue{number}
FILTER
NOT EXISTS Issue.priority.id
OR
Issue.status.name = 'Closed'
ORDER BY Issue.number;
''',
[{'number': '1'}, {'number': '3'}, {'number': '4'}],
)
self.assert_query_result(
r'''
# should be identical
SELECT Issue{number}
FILTER
NOT EXISTS Issue.priority
OR
Issue.status.name = 'Closed'
ORDER BY Issue.number;
''',
[{'number': '1'}, {'number': '3'}, {'number': '4'}],
) | ,
[{'number': '1'}, {'number': '3'}, {'number': '4'}],
)
self.assert_query_result(
r | test_edgeql_select_interpreter_or_05 | python | geldata/gel | tests/test_edgeql_select_interpreter.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_select_interpreter.py | Apache-2.0 |
def test_edgeql_select_interpreter_not_01(self):
self.assert_query_result(
r'''
SELECT Issue{number}
FILTER NOT Issue.priority.name = 'High'
ORDER BY Issue.number;
''',
[{'number': '3'}],
)
self.assert_query_result(
r'''
SELECT Issue{number}
FILTER Issue.priority.name != 'High'
ORDER BY Issue.number;
''',
[{'number': '3'}],
) | ,
[{'number': '3'}],
)
self.assert_query_result(
r | test_edgeql_select_interpreter_not_01 | python | geldata/gel | tests/test_edgeql_select_interpreter.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_select_interpreter.py | Apache-2.0 |
def test_edgeql_select_interpreter_not_02(self):
# testing double negation
self.assert_query_result(
r'''
SELECT Issue{number}
FILTER NOT NOT NOT Issue.priority.name = 'High'
ORDER BY Issue.number;
''',
[{'number': '3'}],
)
self.assert_query_result(
r'''
SELECT Issue{number}
FILTER NOT NOT Issue.priority.name != 'High'
ORDER BY Issue.number;
''',
[{'number': '3'}],
) | ,
[{'number': '3'}],
)
self.assert_query_result(
r | test_edgeql_select_interpreter_not_02 | python | geldata/gel | tests/test_edgeql_select_interpreter.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_select_interpreter.py | Apache-2.0 |
def test_edgeql_select_interpreter_not_04(self):
# testing double negation
self.assert_query_result(
r'''
select BooleanTest {
name,
val,
x := not (.val < 5)
} order by .name;
''',
[
{'name': 'circle', 'val': 2, 'x': False},
{'name': 'hexagon', 'val': 4, 'x': False},
{'name': 'pentagon', 'val': None, 'x': None},
{'name': 'square', 'val': None, 'x': None},
{'name': 'triangle', 'val': 10, 'x': True},
],
)
self.assert_query_result(
r'''
select BooleanTest {
name,
val,
x := not not (.val < 5)
} order by .name;
''',
[
{'name': 'circle', 'val': 2, 'x': True},
{'name': 'hexagon', 'val': 4, 'x': True},
{'name': 'pentagon', 'val': None, 'x': None},
{'name': 'square', 'val': None, 'x': None},
{'name': 'triangle', 'val': 10, 'x': False},
],
) | ,
[
{'name': 'circle', 'val': 2, 'x': False},
{'name': 'hexagon', 'val': 4, 'x': False},
{'name': 'pentagon', 'val': None, 'x': None},
{'name': 'square', 'val': None, 'x': None},
{'name': 'triangle', 'val': 10, 'x': True},
],
)
self.assert_query_result(
r | test_edgeql_select_interpreter_not_04 | python | geldata/gel | tests/test_edgeql_select_interpreter.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_select_interpreter.py | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.