code
stringlengths 26
870k
| docstring
stringlengths 1
65.6k
| func_name
stringlengths 1
194
| language
stringclasses 1
value | repo
stringlengths 8
68
| path
stringlengths 5
182
| url
stringlengths 46
251
| license
stringclasses 4
values |
---|---|---|---|---|---|---|---|
def test_schema_bad_type_19c(self):
"""
type Bar;
function foo() -> Bar | Baz using (1);
""" | type Bar;
function foo() -> Bar | Baz using (1); | test_schema_bad_type_19c | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_bad_type_19d(self):
"""
type Bar;
function foo(x: Bar | Baz) -> int64 using (1);
""" | type Bar;
function foo(x: Bar | Baz) -> int64 using (1); | test_schema_bad_type_19d | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_computable_cardinality_inference_03(self):
"""
type Spam {
required property title -> str;
multi link spams -> Spam;
single link ham := .spams;
}
""" | type Spam {
required property title -> str;
multi link spams -> Spam;
single link ham := .spams;
} | test_schema_computable_cardinality_inference_03 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_computable_cardinality_inference_04(self):
"""
type Spam {
required property title -> str;
multi link spams -> Spam;
single property hams := .spams.title;
}
""" | type Spam {
required property title -> str;
multi link spams -> Spam;
single property hams := .spams.title;
} | test_schema_computable_cardinality_inference_04 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_computable_cardinality_inference_05(self):
"""
type Spam {
required property title -> str;
multi link spams -> Spam;
required property hams := .spams.title;
}
""" | type Spam {
required property title -> str;
multi link spams -> Spam;
required property hams := .spams.title;
} | test_schema_computable_cardinality_inference_05 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_optionality_consistency_check_01(self):
"""
type A {
required property title -> str;
}
type B extending A {
overloaded optional property title -> str;
}
""" | type A {
required property title -> str;
}
type B extending A {
overloaded optional property title -> str;
} | test_schema_optionality_consistency_check_01 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_optionality_consistency_check_02(self):
"""
type A {
optional property title -> str;
}
type B {
required property title -> str;
}
type C extending A, B {
overloaded optional property title -> str;
}
""" | type A {
optional property title -> str;
}
type B {
required property title -> str;
}
type C extending A, B {
overloaded optional property title -> str;
} | test_schema_optionality_consistency_check_02 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_target_consistency_check_01(self):
"""
type A {
property title -> str {
using (1)
}
}
""" | type A {
property title -> str {
using (1)
}
} | test_schema_target_consistency_check_01 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_target_consistency_check_02(self):
"""
type A {
property title -> tuple<str, str> {
using ((1, 2))
}
}
""" | type A {
property title -> tuple<str, str> {
using ((1, 2))
}
} | test_schema_target_consistency_check_02 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_target_consistency_check_03(self):
"""
type A;
type B;
type C {
link foo -> A {
using (SELECT B)
}
}
""" | type A;
type B;
type C {
link foo -> A {
using (SELECT B)
}
} | test_schema_target_consistency_check_03 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_wrong_type_01(self):
"""
scalar type X extending enum<TEST>;
type Y extending X {}
""" | scalar type X extending enum<TEST>;
type Y extending X {} | test_schema_wrong_type_01 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_wrong_type_02(self):
"""
type X;
type Y { constraint X; }
""" | type X;
type Y { constraint X; } | test_schema_wrong_type_02 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_duplicate_def_01(self):
"""
type T;
type T;
""" | type T;
type T; | test_schema_duplicate_def_01 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_duplicate_def_02(self):
"""
type T {
property foo -> str;
property foo -> int64;
};
""" | type T {
property foo -> str;
property foo -> int64;
}; | test_schema_duplicate_def_02 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_duplicate_def_03(self):
"""
type T {
access policy foo allow all using (true);
access policy foo allow all using (true);
};
""" | type T {
access policy foo allow all using (true);
access policy foo allow all using (true);
}; | test_schema_duplicate_def_03 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_module_reserved_01(self):
"""
module foo {
module super {}
}
""" | module foo {
module super {}
} | test_schema_module_reserved_01 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_field_dupe_01(self):
"""
type SimpleNumbers {
property bar: str;
property foo: str {
default := '';
default := '';
}
}
""" | type SimpleNumbers {
property bar: str;
property foo: str {
default := '';
default := '';
}
} | test_schema_field_dupe_01 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_field_dupe_02(self):
"""
type SimpleNumbers {
property bar: str;
property foo: str {
default := .bar;
default := .bar;
}
}
""" | type SimpleNumbers {
property bar: str;
property foo: str {
default := .bar;
default := .bar;
}
} | test_schema_field_dupe_02 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_field_dupe_03(self):
"""
type SimpleNumbers {
bar: str;
foo := .bar ++ "!";
foo := .bar ++ "!";
}
""" | type SimpleNumbers {
bar: str;
foo := .bar ++ "!";
foo := .bar ++ "!";
} | test_schema_field_dupe_03 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_object_as_lprop_01(self):
"""
type Tgt;
type Tgt2;
type Src {
multi tgts: Tgt {
lprop: Tgt2;
}
};
""" | type Tgt;
type Tgt2;
type Src {
multi tgts: Tgt {
lprop: Tgt2;
}
}; | test_schema_object_as_lprop_01 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_object_as_lprop_02(self):
"""
type Tgt;
type Tgt2;
type Src {
multi tgts: Tgt {
}
};
type Src2 extending Src {
overloaded multi tgts: Tgt {
lprop: Tgt2;
}
};
""" | type Tgt;
type Tgt2;
type Src {
multi tgts: Tgt {
}
};
type Src2 extending Src {
overloaded multi tgts: Tgt {
lprop: Tgt2;
}
}; | test_schema_object_as_lprop_02 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_func_optional_variadic_01(self):
"""
function foo(variadic bar: optional int64) -> array<int64>
using (assert_exists(bar));
""" | function foo(variadic bar: optional int64) -> array<int64>
using (assert_exists(bar)); | test_schema_func_optional_variadic_01 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_global_01(self):
"""
global two_things: TwoThings;
scalar type TwoThings extending enum<One, Two>;
""" | global two_things: TwoThings;
scalar type TwoThings extending enum<One, Two>; | test_schema_global_01 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_hard_sorting_01(self):
# This is hard to sort properly because we don't understand the types.
# From #4683.
"""
global current_user_id -> uuid;
global current_user := (
select User filter .id = global current_user_id
);
global current_user_role := (
(global current_user).role.slug
);
type Role {
property slug -> str;
}
type User {
required link role -> Role;
}
""" | global current_user_id -> uuid;
global current_user := (
select User filter .id = global current_user_id
);
global current_user_role := (
(global current_user).role.slug
);
type Role {
property slug -> str;
}
type User {
required link role -> Role;
} | test_schema_hard_sorting_01 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_hard_sorting_02(self):
# This is hard to sort properly because we don't understand the types.
# From #5163
"""
type Branch;
type CO2DataPoint{
required link datapoint -> DataPoint;
link branch := .datapoint.data_entry.branch;
}
type DataPoint{
required link data_entry := assert_exists(
.<data_points[is DataEntry]);
}
type DataEntry{
required link branch -> Branch;
multi link data_points -> DataPoint;
}
""" | type Branch;
type CO2DataPoint{
required link datapoint -> DataPoint;
link branch := .datapoint.data_entry.branch;
}
type DataPoint{
required link data_entry := assert_exists(
.<data_points[is DataEntry]);
}
type DataEntry{
required link branch -> Branch;
multi link data_points -> DataPoint;
} | test_schema_hard_sorting_02 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_hard_sorting_03(self):
# This is hard to sort properly because we don't understand the types.
"""
type A {
property foo := assert_exists(B).bar;
};
type B {
property bar := 1;
};
""" | type A {
property foo := assert_exists(B).bar;
};
type B {
property bar := 1;
}; | test_schema_hard_sorting_03 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_hard_sorting_04(self):
# This is hard to sort properly because we don't understand the types.
"""
type A {
property foo := (
with Z := assert_exists(B) select Z.bar);
};
type B {
property bar := 1;
};
""" | type A {
property foo := (
with Z := assert_exists(B) select Z.bar);
};
type B {
property bar := 1;
}; | test_schema_hard_sorting_04 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_hard_sorting_05(self):
"""
type T {
multi as: A;
multi bs: B;
sections := (
select (.as union .bs)
filter .index > 0
);
}
abstract type I {
required index: int16;
}
type A extending I;
type B extending I;
""" | type T {
multi as: A;
multi bs: B;
sections := (
select (.as union .bs)
filter .index > 0
);
}
abstract type I {
required index: int16;
}
type A extending I;
type B extending I; | test_schema_hard_sorting_05 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_refs_01(self):
schema = self.load_schema("""
type Object1;
type Object2 {
link foo -> Object1
};
type Object3 extending Object1;
type Object4 extending Object1;
type Object5 {
link bar -> Object2
};
type Object6 extending Object4;
""")
Obj1 = schema.get('test::Object1')
Obj2 = schema.get('test::Object2')
Obj3 = schema.get('test::Object3')
Obj4 = schema.get('test::Object4')
Obj5 = schema.get('test::Object5')
Obj6 = schema.get('test::Object6')
obj1_id = Obj1.getptr(schema, s_name.UnqualName('id'))
obj1_type = Obj1.getptr(schema, s_name.UnqualName('__type__'))
obj1_type_source = obj1_type.getptr(
schema, s_name.UnqualName('source'))
obj2_type = Obj2.getptr(schema, s_name.UnqualName('__type__'))
foo = Obj2.getptr(schema, s_name.UnqualName('foo'))
foo_target = foo.getptr(schema, s_name.UnqualName('target'))
bar = Obj5.getptr(schema, s_name.UnqualName('bar'))
self.assertEqual(
schema.get_referrers(Obj1),
frozenset({
foo, # Object 1 is a Object2.foo target
foo_target, # and also a target of its @target property
Obj3, # It is also in Object3's bases and ancestors
Obj4, # Likewise for Object4
Obj6, # Object6 through its ancestors
obj1_id, # Inherited id property
obj1_type, # Inherited __type__ link
obj1_type_source, # and its @source property
})
)
self.assertEqual(
schema.get_referrers(Obj1, scls_type=s_objtypes.ObjectType),
{
Obj3, # It is also in Object3's bases and ancestors
Obj4, # Likewise for Object4
Obj6, # Object6 through its ancestors
}
)
self.assertEqual(
schema.get_referrers(Obj2, scls_type=s_links.Link),
{
foo, # Obj2 is foo's source
bar, # Obj2 is bar's target
obj2_type, # Iherited Obj2.__type__ link
}
)
self.assertEqual(
schema.get_referrers(Obj2, scls_type=s_links.Link,
field_name='target'),
{
bar, # Obj2 is bar's target
}
)
schema = self.run_ddl(schema, '''
ALTER TYPE test::Object4 DROP EXTENDING test::Object1;
''')
self.assertEqual(
schema.get_referrers(Obj1),
frozenset({
foo, # Object 1 is a Object2.foo target
foo_target, # and also a target of its @target property
Obj3, # It is also in Object3's bases and ancestors
obj1_id, # Inherited id property
obj1_type, # Inherited __type__ link
obj1_type_source, # and its @source property
})
)
schema = self.run_ddl(schema, '''
ALTER TYPE test::Object3 DROP EXTENDING test::Object1;
''')
self.assertEqual(
schema.get_referrers(Obj1),
frozenset({
foo, # Object 1 is a Object2.foo target
foo_target, # and also a target of its @target property
obj1_id, # Inherited id property
obj1_type, # Inherited __type__ link
obj1_type_source, # and its @source property
})
)
schema = self.run_ddl(schema, '''
CREATE FUNCTION
test::my_contains(arr: array<anytype>, val: anytype) -> bool {
SET volatility := 'Immutable';
USING (
SELECT contains(arr, val)
);
};
CREATE ABSTRACT CONSTRAINT
test::my_one_of(one_of: array<anytype>) {
USING (
SELECT (
test::my_contains(one_of, __subject__),
).0
);
};
CREATE SCALAR TYPE test::my_scalar_t extending str {
CREATE CONSTRAINT test::my_one_of(['foo', 'bar']);
};
''')
my_scalar_t = schema.get('test::my_scalar_t')
constr = my_scalar_t.get_constraints(schema).objects(schema)[0]
my_contains = schema.get_functions('test::my_contains')[0]
self.assertEqual(
schema.get_referrers(my_contains),
frozenset({
constr,
})
)
self.assertEqual(
schema.get_referrers(Obj1),
frozenset({
foo, # Object 1 is a Object2.foo target
foo_target, # and also a target of its @target property
obj1_id, # Inherited id property
obj1_type, # Inherited __type__ link
obj1_type_source, # and its @source property
})
) | )
Obj1 = schema.get('test::Object1')
Obj2 = schema.get('test::Object2')
Obj3 = schema.get('test::Object3')
Obj4 = schema.get('test::Object4')
Obj5 = schema.get('test::Object5')
Obj6 = schema.get('test::Object6')
obj1_id = Obj1.getptr(schema, s_name.UnqualName('id'))
obj1_type = Obj1.getptr(schema, s_name.UnqualName('__type__'))
obj1_type_source = obj1_type.getptr(
schema, s_name.UnqualName('source'))
obj2_type = Obj2.getptr(schema, s_name.UnqualName('__type__'))
foo = Obj2.getptr(schema, s_name.UnqualName('foo'))
foo_target = foo.getptr(schema, s_name.UnqualName('target'))
bar = Obj5.getptr(schema, s_name.UnqualName('bar'))
self.assertEqual(
schema.get_referrers(Obj1),
frozenset({
foo, # Object 1 is a Object2.foo target
foo_target, # and also a target of its @target property
Obj3, # It is also in Object3's bases and ancestors
Obj4, # Likewise for Object4
Obj6, # Object6 through its ancestors
obj1_id, # Inherited id property
obj1_type, # Inherited __type__ link
obj1_type_source, # and its @source property
})
)
self.assertEqual(
schema.get_referrers(Obj1, scls_type=s_objtypes.ObjectType),
{
Obj3, # It is also in Object3's bases and ancestors
Obj4, # Likewise for Object4
Obj6, # Object6 through its ancestors
}
)
self.assertEqual(
schema.get_referrers(Obj2, scls_type=s_links.Link),
{
foo, # Obj2 is foo's source
bar, # Obj2 is bar's target
obj2_type, # Iherited Obj2.__type__ link
}
)
self.assertEqual(
schema.get_referrers(Obj2, scls_type=s_links.Link,
field_name='target'),
{
bar, # Obj2 is bar's target
}
)
schema = self.run_ddl(schema, | test_schema_refs_01 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_refs_04(self):
with self.assertRaisesRegex(
errors.InvalidReferenceError,
"__subject__ cannot be used in this expression",
):
self.load_schema(
"""
type User3 {
required property nick: str;
required property name: str {
default := (select __subject__.nick);
};
}
"""
) | type User3 {
required property nick: str;
required property name: str {
default := (select __subject__.nick);
};
} | test_schema_refs_04 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_constraint_inheritance_05(self):
"""
abstract constraint aaa extending std::max_len_value;
""" | abstract constraint aaa extending std::max_len_value; | test_schema_constraint_inheritance_05 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_constraint_inheritance_06(self):
"""
abstract constraint aaa(max: std::int64)
extending std::max_len_value;
abstract constraint bbb(min: std::int64)
extending std::min_len_value;
abstract constraint zzz(max: std::int64)
extending aaa, bbb;
""" | abstract constraint aaa(max: std::int64)
extending std::max_len_value;
abstract constraint bbb(min: std::int64)
extending std::min_len_value;
abstract constraint zzz(max: std::int64)
extending aaa, bbb; | test_schema_constraint_inheritance_06 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_constraint_inheritance_07(self):
"""
abstract constraint aaa(max: std::int64, foo: str)
extending std::max_len_value;
abstract constraint zzz(max: std::int64)
extending aaa;
""" | abstract constraint aaa(max: std::int64, foo: str)
extending std::max_len_value;
abstract constraint zzz(max: std::int64)
extending aaa; | test_schema_constraint_inheritance_07 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_constraint_inheritance_08(self):
"""
abstract constraint aaa(max: std::int64)
extending std::max_len_value;
abstract constraint zzz(max: std::int64)
extending aaa;
""" | abstract constraint aaa(max: std::int64)
extending std::max_len_value;
abstract constraint zzz(max: std::int64)
extending aaa; | test_schema_constraint_inheritance_08 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_constraint_inheritance_09(self):
"""
abstract constraint aaa(max: std::int64, foo: str)
extending std::max_len_value;
abstract constraint zzz(max: std::str)
extending aaa;
""" | abstract constraint aaa(max: std::int64, foo: str)
extending std::max_len_value;
abstract constraint zzz(max: std::str)
extending aaa; | test_schema_constraint_inheritance_09 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_constraint_inheritance_10(self):
"""
abstract constraint aaa(max: std::int64)
extending std::max_len_value;
abstract constraint zzz(min: std::str)
extending aaa;
""" | abstract constraint aaa(max: std::int64)
extending std::max_len_value;
abstract constraint zzz(min: std::str)
extending aaa; | test_schema_constraint_inheritance_10 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_constraint_inheritance_11(self):
"""
abstract constraint aaa(max: std::int64)
extending std::max_len_value;
abstract constraint zzz(max: std::str)
extending aaa;
""" | abstract constraint aaa(max: std::int64)
extending std::max_len_value;
abstract constraint zzz(max: std::str)
extending aaa; | test_schema_constraint_inheritance_11 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_constraint_inheritance_12(self):
"""
abstract constraint aaa(max: std::int64)
extending std::max_len_value;
abstract constraint zzz(max: anyscalar)
extending aaa;
""" | abstract constraint aaa(max: std::int64)
extending std::max_len_value;
abstract constraint zzz(max: anyscalar)
extending aaa; | test_schema_constraint_inheritance_12 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_constraint_inheritance_13(self):
"""
type A {
property name -> str {
constraint exclusive;
}
}
type B extending A {
overloaded property name -> str {
delegated constraint exclusive;
}
}
""" | type A {
property name -> str {
constraint exclusive;
}
}
type B extending A {
overloaded property name -> str {
delegated constraint exclusive;
}
} | test_schema_constraint_inheritance_13 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_rewrite_missing_required_01(self):
"""
type Project {
required name: str;
required owner: User;
}
type User {
link default_project: Project {
rewrite insert using (
insert Project {
owner := __subject__,
}
)
};
}
""" | type Project {
required name: str;
required owner: User;
}
type User {
link default_project: Project {
rewrite insert using (
insert Project {
owner := __subject__,
}
)
};
} | test_schema_rewrite_missing_required_01 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_rewrite_order_01(self):
"""
type EventSession extending Timed {
lastSeen: datetime {
rewrite update using (
__old__.foo
)
}
lastSeen2: datetime {
rewrite insert using (
__subject__.foo
)
}
}
abstract type Timed {
required foo: datetime {
default := datetime_current();
}
}
""" | type EventSession extending Timed {
lastSeen: datetime {
rewrite update using (
__old__.foo
)
}
lastSeen2: datetime {
rewrite insert using (
__subject__.foo
)
}
}
abstract type Timed {
required foo: datetime {
default := datetime_current();
}
} | test_schema_rewrite_order_01 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_rewrite_order_02(self):
# One of the properties is going to reference the other property
# before it is created in its rewrite via __specified__.
# Ensure that this gets ordered correctly.
"""
type User {
property foo -> bool {
rewrite insert using (__specified__.bar);
};
property bar -> bool {
rewrite insert using (__specified__.foo);
};
};
""" | type User {
property foo -> bool {
rewrite insert using (__specified__.bar);
};
property bar -> bool {
rewrite insert using (__specified__.foo);
};
}; | test_schema_rewrite_order_02 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_scalar_order_01(self):
# Make sure scalar types account for base types when tracing SDL
# dependencies.
"""
scalar type two extending one;
scalar type one extending str;
""" | scalar type two extending one;
scalar type one extending str; | test_schema_scalar_order_01 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_trigger_order_01(self):
"""
type Feed extending Entity {
trigger sync_trigger_on_update after update for each when (
__old__.field ?= __new__.field
)
do (1)
}
abstract type Entity {
field: str;
}
""" | type Feed extending Entity {
trigger sync_trigger_on_update after update for each when (
__old__.field ?= __new__.field
)
do (1)
}
abstract type Entity {
field: str;
} | test_schema_trigger_order_01 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_property_cardinality_alter_01(self):
schema = self.load_schema('''
type Foo {
single property foo1 -> str;
single property bar1 := .foo1 ++ '!';
single property foo2 -> str;
property bar2 := .foo2 ++ '!';
}
''')
with self.assertRaisesRegex(
errors.SchemaDefinitionError,
"cannot convert property 'foo1' of object type 'test::Foo' to "
"'multi' cardinality because this affects expression of "
"property 'bar1' of object type 'test::Foo'"
):
self.run_ddl(schema, '''
ALTER TYPE Foo ALTER PROPERTY foo1 SET MULTI
''', default_module='test')
# Altering foo2 is OK, because the computable bar2 was declared
# without explicit cardinality.
self.run_ddl(schema, '''
ALTER TYPE Foo ALTER PROPERTY foo2 SET MULTI
''', default_module='test') | )
with self.assertRaisesRegex(
errors.SchemaDefinitionError,
"cannot convert property 'foo1' of object type 'test::Foo' to "
"'multi' cardinality because this affects expression of "
"property 'bar1' of object type 'test::Foo'"
):
self.run_ddl(schema, | test_schema_property_cardinality_alter_01 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_property_cardinality_alter_02(self):
schema = self.load_schema('''
type Foo {
single property foo1 -> str;
}
type Bar extending Foo;
''')
with self.assertRaisesRegex(
errors.SchemaDefinitionError,
"cannot redefine the cardinality of property 'foo1' of "
"object type 'test::Bar'.*"
):
self.run_ddl(schema, '''
ALTER TYPE Bar ALTER PROPERTY foo1 SET MULTI
''', default_module='test') | )
with self.assertRaisesRegex(
errors.SchemaDefinitionError,
"cannot redefine the cardinality of property 'foo1' of "
"object type 'test::Bar'.*"
):
self.run_ddl(schema, | test_schema_property_cardinality_alter_02 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_property_cardinality_alter_03(self):
schema = self.load_schema('''
type Foo {
single property foo1 -> str;
}
type Bar extending Foo;
''')
schema = self.run_ddl(schema, '''
ALTER TYPE Foo ALTER PROPERTY foo1 SET MULTI
''', default_module='test')
Bar = schema.get('test::Bar', type=s_objtypes.ObjectType)
foo1 = Bar.getptr(schema, s_name.UnqualName('foo1'))
self.assertEqual(str(foo1.get_cardinality(schema)), 'Many') | )
schema = self.run_ddl(schema, | test_schema_property_cardinality_alter_03 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_ref_diamond_inheritance(self):
schema = tb._load_std_schema()
schema = self.run_ddl(schema, '''
CREATE MODULE default;
CREATE TYPE default::A;
CREATE TYPE default::B EXTENDING A;
CREATE TYPE default::C EXTENDING B, A;
''')
orig_get_children = type(schema).get_children
def stable_get_children(self, scls):
children = orig_get_children(self, scls)
return list(sorted(children, key=lambda obj: obj.get_name(schema)))
type(schema).get_children = stable_get_children
try:
schema = self.run_ddl(schema, '''
ALTER TYPE default::A CREATE PROPERTY foo -> str;
''')
finally:
type(schema).get_children = orig_get_children | )
orig_get_children = type(schema).get_children
def stable_get_children(self, scls):
children = orig_get_children(self, scls)
return list(sorted(children, key=lambda obj: obj.get_name(schema)))
type(schema).get_children = stable_get_children
try:
schema = self.run_ddl(schema, | test_schema_ref_diamond_inheritance | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_ancestor_propagation_on_sdl_migration(self):
schema = self.load_schema("""
type A;
type B extending A;
type C extending B;
""")
BaseObject = schema.get('std::BaseObject')
Object = schema.get('std::Object')
A = schema.get('test::A')
B = schema.get('test::B')
C = schema.get('test::C')
std_link = schema.get('std::link')
BaseObject__type__ = BaseObject.getptr(
schema, s_name.UnqualName('__type__'))
Object__type__ = Object.getptr(
schema, s_name.UnqualName('__type__'))
A__type__ = A.getptr(schema, s_name.UnqualName('__type__'))
B__type__ = B.getptr(schema, s_name.UnqualName('__type__'))
C__type__ = C.getptr(schema, s_name.UnqualName('__type__'))
self.assertEqual(
C__type__.get_ancestors(schema).objects(schema),
(
B__type__,
A__type__,
Object__type__,
BaseObject__type__,
std_link,
)
)
schema = self.run_ddl(schema, """
START MIGRATION TO {
module test {
type A;
type B;
type C extending B;
}
};
POPULATE MIGRATION;
COMMIT MIGRATION;
""")
self.assertEqual(
C__type__.get_ancestors(schema).objects(schema),
(
B__type__,
Object__type__,
BaseObject__type__,
std_link,
)
) | )
BaseObject = schema.get('std::BaseObject')
Object = schema.get('std::Object')
A = schema.get('test::A')
B = schema.get('test::B')
C = schema.get('test::C')
std_link = schema.get('std::link')
BaseObject__type__ = BaseObject.getptr(
schema, s_name.UnqualName('__type__'))
Object__type__ = Object.getptr(
schema, s_name.UnqualName('__type__'))
A__type__ = A.getptr(schema, s_name.UnqualName('__type__'))
B__type__ = B.getptr(schema, s_name.UnqualName('__type__'))
C__type__ = C.getptr(schema, s_name.UnqualName('__type__'))
self.assertEqual(
C__type__.get_ancestors(schema).objects(schema),
(
B__type__,
A__type__,
Object__type__,
BaseObject__type__,
std_link,
)
)
schema = self.run_ddl(schema, | test_schema_ancestor_propagation_on_sdl_migration | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_ast_contects_01(self):
schema = self.load_schema("")
schema = self.run_ddl(schema, """
create type test::Foo {
create property asdf := 1 + 2 + 3
};
""")
obj = schema.get('test::Foo')
asdf = obj.getptr(schema, s_name.UnqualName('asdf'))
expr_ast = asdf.get_expr(schema).parse()
self.assertEqual(
expr_ast.span.name,
f'<{asdf.id} expr>'
)
schema = self.run_ddl(schema, """
alter type test::Foo {
create property x -> str { set default := "test" };
}
""")
x = obj.getptr(schema, s_name.UnqualName('x'))
default_ast = x.get_default(schema).parse()
self.assertEqual(
default_ast.span.name,
f'<{x.id} default>'
) | )
obj = schema.get('test::Foo')
asdf = obj.getptr(schema, s_name.UnqualName('asdf'))
expr_ast = asdf.get_expr(schema).parse()
self.assertEqual(
expr_ast.span.name,
f'<{asdf.id} expr>'
)
schema = self.run_ddl(schema, | test_schema_ast_contects_01 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_backlink_01(self):
"""
type Bar {
link foo -> Foo;
link f := .<bar[IS Foo];
}
type Foo {
link bar := .<foo[IS Bar];
}
""" | type Bar {
link foo -> Foo;
link f := .<bar[IS Foo];
}
type Foo {
link bar := .<foo[IS Bar];
} | test_schema_backlink_01 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_backlink_02(self):
"""
type Bar {
link foo -> Foo;
link f := .<bar;
}
type Foo {
link bar := .<foo;
}
""" | type Bar {
link foo -> Foo;
link f := .<bar;
}
type Foo {
link bar := .<foo;
} | test_schema_backlink_02 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_backlink_03(self):
"""
alias B := Bar {
f := .<bar[IS Foo]
};
type Bar {
link foo -> Foo;
}
type Foo {
link bar := .<foo[IS Bar];
}
""" | alias B := Bar {
f := .<bar[IS Foo]
};
type Bar {
link foo -> Foo;
}
type Foo {
link bar := .<foo[IS Bar];
} | test_schema_backlink_03 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_backlink_04(self):
"""
function foo() -> uuid using (
Bar.<bar[IS Foo].id
);
type Bar {
link foo -> Foo;
}
type Foo {
link bar := .<foo[IS Bar];
}
""" | function foo() -> uuid using (
Bar.<bar[IS Foo].id
);
type Bar {
link foo -> Foo;
}
type Foo {
link bar := .<foo[IS Bar];
} | test_schema_backlink_04 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_recursive_01(self):
schema = self.load_schema(r'''
type Foo {
link next -> Foo;
property val := 1;
}
''', modname='default')
with self.assertRaisesRegex(
errors.InvalidDefinitionError,
"property 'val' of object type 'default::Foo' "
"is defined recursively"
):
self.run_ddl(schema, '''
ALTER TYPE default::Foo
ALTER PROPERTY val USING (1 + (.next.val ?? 0));
''') | , modname='default')
with self.assertRaisesRegex(
errors.InvalidDefinitionError,
"property 'val' of object type 'default::Foo' "
"is defined recursively"
):
self.run_ddl(schema, | test_schema_recursive_01 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_recursive_02(self):
schema = self.load_schema(r'''
type Foo {
link next -> Bar;
property val := 1;
}
type Bar {
link next -> Foo;
property val := 1;
}
''', modname='default')
self.run_ddl(schema, '''
ALTER TYPE default::Foo
ALTER PROPERTY val USING (1 + (.next.val ?? 0));
''')
with self.assertRaisesRegex(
errors.InvalidDefinitionError,
"definition dependency cycle between "
"property 'val' of object type 'default::Bar' and "
"property 'val' of object type 'default::Foo'"
):
self.run_ddl(schema, '''
ALTER TYPE default::Bar
ALTER PROPERTY val USING (1 + (.next.val ?? 0));
# ALTER PROPERTY val USING ('bad');
''') | , modname='default')
self.run_ddl(schema, | test_schema_recursive_02 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_recursive_03(self):
schema = self.load_schema(r'''
function foo(v: int64) -> int64 using (
1 + v
);
''', modname='default')
with self.assertRaisesRegex(
errors.InvalidDefinitionError,
r"function 'default::foo\(v:.+int64\)' "
r"is defined recursively"
):
self.run_ddl(schema, '''
ALTER FUNCTION foo(v: int64) USING (
0 IF v < 0 ELSE 1 + foo(v -1)
);
''')
# Make sure unrelated functions with similar prefix
# aren't matched erroneously (#3115)
schema = self.load_schema(r'''
function len_strings(words: str) -> int64 using (
len(words)
);
''', modname='default') | , modname='default')
with self.assertRaisesRegex(
errors.InvalidDefinitionError,
r"function 'default::foo\(v:.+int64\)' "
r"is defined recursively"
):
self.run_ddl(schema, | test_schema_recursive_03 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_recursive_04(self):
schema = self.load_schema(r'''
function foo(v: int64) -> int64 using (
1 + v
);
function bar(v: int64) -> int64 using (
0 IF v < 0 ELSE 1 + foo(v -1)
);
''', modname='default')
with self.assertRaisesRegex(
errors.InvalidDefinitionError,
r"definition dependency cycle between "
r"function 'default::bar\(v:.+int64\)' and "
r"function 'default::foo\(v:.+int64\)'"
):
self.run_ddl(schema, '''
ALTER FUNCTION foo(v: int64) USING (
0 IF v < 0 ELSE 1 + bar(v -1)
);
''') | , modname='default')
with self.assertRaisesRegex(
errors.InvalidDefinitionError,
r"definition dependency cycle between "
r"function 'default::bar\(v:.+int64\)' and "
r"function 'default::foo\(v:.+int64\)'"
):
self.run_ddl(schema, | test_schema_recursive_04 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_recursive_05(self):
schema = self.load_schema(r'''
type Foo {
property val := foo(1);
}
function foo(v: int64) -> int64 using (
1 + v
);
''', modname='default')
with self.assertRaisesRegex(
errors.InvalidDefinitionError,
r"definition dependency cycle between "
r"function 'default::foo\(v:.+int64\)' and "
r"property 'val' of object type 'default::Foo'"
):
self.run_ddl(schema, r'''
ALTER FUNCTION foo(v: int64) USING (
# This is very broken now
assert_exists(1 + (SELECT Foo LIMIT 1).val)
);
''') | , modname='default')
with self.assertRaisesRegex(
errors.InvalidDefinitionError,
r"definition dependency cycle between "
r"function 'default::foo\(v:.+int64\)' and "
r"property 'val' of object type 'default::Foo'"
):
self.run_ddl(schema, r | test_schema_recursive_05 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_recursive_06(self):
schema = self.load_schema(r'''
type Foo {
property val := 1;
}
function foo(v: int64) -> optional int64 using (
1 + (SELECT Foo LIMIT 1).val
);
''', modname='default')
with self.assertRaisesRegex(
errors.SchemaDefinitionError,
r"cannot alter property 'val' of object type 'default::Foo' "
r"because this affects body expression of "
r"function 'default::foo\(v:.+int64\)'"
):
self.run_ddl(schema, r'''
ALTER TYPE Foo {
# This is very broken now
ALTER PROPERTY val USING (foo(1));
};
''') | , modname='default')
with self.assertRaisesRegex(
errors.SchemaDefinitionError,
r"cannot alter property 'val' of object type 'default::Foo' "
r"because this affects body expression of "
r"function 'default::foo\(v:.+int64\)'"
):
self.run_ddl(schema, r | test_schema_recursive_06 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_recursive_07(self):
schema = self.load_schema(r'''
type Foo {
property val -> int64;
}
alias FooAlias0 := Foo {
comp := .val + (SELECT FooAlias1 LIMIT 1).comp
};
alias FooAlias1 := Foo {
comp := .val + 1
};
''', modname='default')
with self.assertRaisesRegex(
errors.InvalidDefinitionError,
"definition dependency cycle between "
"alias 'default::FooAlias1' and alias 'default::FooAlias0'"
):
self.run_ddl(schema, r'''
ALTER ALIAS FooAlias1 USING (
Foo {
comp := .val + (SELECT FooAlias0 LIMIT 1).comp
}
);
''') | , modname='default')
with self.assertRaisesRegex(
errors.InvalidDefinitionError,
"definition dependency cycle between "
"alias 'default::FooAlias1' and alias 'default::FooAlias0'"
):
self.run_ddl(schema, r | test_schema_recursive_07 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_recursive_08(self):
schema = self.load_schema(r'''
type Foo;
type Bar extending Foo;
''', modname='default')
with self.assertRaisesRegex(
errors.InvalidDefinitionError,
"'default::Foo' is defined recursively"
):
self.run_ddl(schema, r'''
ALTER TYPE Foo EXTENDING Bar;
''') | , modname='default')
with self.assertRaisesRegex(
errors.InvalidDefinitionError,
"'default::Foo' is defined recursively"
):
self.run_ddl(schema, r | test_schema_recursive_08 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_computed_01(self):
# Issue #3499
"""
type Version {
multi link fields -> Field {
property position -> int32 {
default := 0;
}
}
multi link sections :=
(select .ordered_fields filter .type = 'section');
multi link ordered_fields :=
(select .fields order by @position);
}
type Field {
required property type -> str;
multi link versions := .<fields[is Version];
}
""" | type Version {
multi link fields -> Field {
property position -> int32 {
default := 0;
}
}
multi link sections :=
(select .ordered_fields filter .type = 'section');
multi link ordered_fields :=
(select .fields order by @position);
}
type Field {
required property type -> str;
multi link versions := .<fields[is Version];
} | test_schema_computed_01 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_computed_02(self):
# Issue #3499
"""
type Version {
multi link fields -> Field {
property position -> int32 {
default := 0;
}
}
multi link ordered_fields :=
(select .fields order by @position);
multi link sections :=
(select .ordered_fields filter .type = 'section');
}
type Field {
required property type -> str;
multi link versions := .<fields[is Version];
}
""" | type Version {
multi link fields -> Field {
property position -> int32 {
default := 0;
}
}
multi link ordered_fields :=
(select .fields order by @position);
multi link sections :=
(select .ordered_fields filter .type = 'section');
}
type Field {
required property type -> str;
multi link versions := .<fields[is Version];
} | test_schema_computed_02 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_computed_03(self):
# Issue #3499
"""
type Version {
multi link ordered_fields :=
(select .fields order by @position);
multi link sections :=
(select .ordered_fields filter .type = 'section');
multi link fields -> Field {
property position -> int32 {
default := 0;
}
}
}
type Field {
required property type -> str;
multi link versions := .<fields[is Version];
}
""" | type Version {
multi link ordered_fields :=
(select .fields order by @position);
multi link sections :=
(select .ordered_fields filter .type = 'section');
multi link fields -> Field {
property position -> int32 {
default := 0;
}
}
}
type Field {
required property type -> str;
multi link versions := .<fields[is Version];
} | test_schema_computed_03 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_computed_04(self):
"""
type User {
required property name -> str;
multi link likedPosts := .<author[is PostLike].post;
}
type Post {
required property content -> str;
}
abstract type ALike {
required link author -> User;
}
type PostLike extending ALike {
required link post -> Post;
}
""" | type User {
required property name -> str;
multi link likedPosts := .<author[is PostLike].post;
}
type Post {
required property content -> str;
}
abstract type ALike {
required link author -> User;
}
type PostLike extending ALike {
required link post -> Post;
} | test_schema_computed_04 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_computed_05(self):
"""
type User {
required property name -> str;
property val_e := {'alice', 'billie'} except .name;
property val_i := {'alice', 'billie'} intersect .name;
}
""" | type User {
required property name -> str;
property val_e := {'alice', 'billie'} except .name;
property val_i := {'alice', 'billie'} intersect .name;
} | test_schema_computed_05 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_alias_01(self):
"""
type User {
required property name -> str;
}
alias val_e := {'alice', 'billie'} except User.name;
alias val_i := {'alice', 'billie'} intersect User.name;
""" | type User {
required property name -> str;
}
alias val_e := {'alice', 'billie'} except User.name;
alias val_i := {'alice', 'billie'} intersect User.name; | test_schema_alias_01 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_range_01(self):
"""
scalar type Age extending int64;
type Y {
property age_requirement -> range<Age>
}
""" | scalar type Age extending int64;
type Y {
property age_requirement -> range<Age>
} | test_schema_range_01 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_constraint_non_singleton_01(self):
"""
type ConstraintNonSingletonTest {
property has_bad_constraint -> str {
constraint expression on (
distinct __subject__ = __subject__
)
}
}
""" | type ConstraintNonSingletonTest {
property has_bad_constraint -> str {
constraint expression on (
distinct __subject__ = __subject__
)
}
} | test_schema_constraint_non_singleton_01 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_constraint_non_singleton_02(self):
"""
type ConstraintNonSingletonTest {
property has_bad_constraint -> str {
constraint exclusive on (
distinct __subject__
)
}
}
""" | type ConstraintNonSingletonTest {
property has_bad_constraint -> str {
constraint exclusive on (
distinct __subject__
)
}
} | test_schema_constraint_non_singleton_02 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_constraint_non_singleton_03(self):
"""
type ConstraintNonSingletonTest {
property has_bad_constraint -> str;
constraint exclusive on (distinct .has_bad_constraint);
}
""" | type ConstraintNonSingletonTest {
property has_bad_constraint -> str;
constraint exclusive on (distinct .has_bad_constraint);
} | test_schema_constraint_non_singleton_03 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_constraint_non_singleton_04(self):
"""
type ConstraintNonSingletonTest {
property has_bad_constraint -> str;
constraint exclusive on (.has_bad_constraint) except (
distinct __subject__ = __subject__
);
}
""" | type ConstraintNonSingletonTest {
property has_bad_constraint -> str;
constraint exclusive on (.has_bad_constraint) except (
distinct __subject__ = __subject__
);
} | test_schema_constraint_non_singleton_04 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_constraint_non_singleton_05(self):
"""
abstract constraint bad_constraint {
using (distinct __subject__ = __subject__);
}
""" | abstract constraint bad_constraint {
using (distinct __subject__ = __subject__);
} | test_schema_constraint_non_singleton_05 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_constraint_non_singleton_06(self):
"""
abstract constraint bad_constraint {
using (count(__subject__) <= 2);
}
""" | abstract constraint bad_constraint {
using (count(__subject__) <= 2);
} | test_schema_constraint_non_singleton_06 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_constraint_non_singleton_07(self):
"""
type Foo;
type ConstraintNonSingletonTest {
link has_bad_constraint -> Foo {
constraint expression on (
count(__subject__) <= 2
)
}
}
""" | type Foo;
type ConstraintNonSingletonTest {
link has_bad_constraint -> Foo {
constraint expression on (
count(__subject__) <= 2
)
}
} | test_schema_constraint_non_singleton_07 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_constraint_non_singleton_08(self):
"""
type Foo;
type ConstraintNonSingletonTest {
multi link has_bad_constraint -> Foo {
constraint expression on (
count(__subject__) <= 2
)
}
}
""" | type Foo;
type ConstraintNonSingletonTest {
multi link has_bad_constraint -> Foo {
constraint expression on (
count(__subject__) <= 2
)
}
} | test_schema_constraint_non_singleton_08 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_constraint_non_singleton_09(self):
"""
type Foo;
type ConstraintNonSingletonTest {
link has_bad_constraint -> Foo {
constraint expression on (
distinct __subject__ = __subject__
)
}
}
""" | type Foo;
type ConstraintNonSingletonTest {
link has_bad_constraint -> Foo {
constraint expression on (
distinct __subject__ = __subject__
)
}
} | test_schema_constraint_non_singleton_09 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_constraint_non_singleton_10(self):
"""
type Foo;
type ConstraintNonSingletonTest {
multi link has_bad_constraint -> Foo {
constraint expression on (
distinct __subject__ = __subject__
)
}
}
""" | type Foo;
type ConstraintNonSingletonTest {
multi link has_bad_constraint -> Foo {
constraint expression on (
distinct __subject__ = __subject__
)
}
} | test_schema_constraint_non_singleton_10 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_constraint_singleton_01a(self):
# `IN` allowed in singleton
"""
type X {
property a -> int64 {
constraint expression on (
__subject__ in {1}
);
}
};
""" | type X {
property a -> int64 {
constraint expression on (
__subject__ in {1}
);
}
}; | test_schema_constraint_singleton_01a | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_constraint_singleton_01b(self):
"""
type X {
multi property a -> int64 {
constraint expression on (
__subject__ in {1}
);
}
};
""" | type X {
multi property a -> int64 {
constraint expression on (
__subject__ in {1}
);
}
}; | test_schema_constraint_singleton_01b | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_constraint_singleton_02a(self):
# `NOT IN` allowed in singleton
"""
type X {
property a -> int64 {
constraint expression on (
__subject__ not in {1}
);
}
};
""" | type X {
property a -> int64 {
constraint expression on (
__subject__ not in {1}
);
}
}; | test_schema_constraint_singleton_02a | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_constraint_singleton_02b(self):
"""
type X {
multi property a -> int64 {
constraint expression on (
__subject__ not in {1}
);
}
};
""" | type X {
multi property a -> int64 {
constraint expression on (
__subject__ not in {1}
);
}
}; | test_schema_constraint_singleton_02b | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_constraint_singleton_03a(self):
# `EXISTS` allowed in singleton
"""
type X {
property a -> int64 {
constraint expression on (
exists(__subject__)
);
}
};
""" | type X {
property a -> int64 {
constraint expression on (
exists(__subject__)
);
}
}; | test_schema_constraint_singleton_03a | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_constraint_singleton_03b(self):
"""
type Foo;
type ConstraintNonSingletonTest {
multi link has_bad_constraint -> Foo {
constraint expression on (
exists(__subject__)
)
}
}
""" | type Foo;
type ConstraintNonSingletonTest {
multi link has_bad_constraint -> Foo {
constraint expression on (
exists(__subject__)
)
}
} | test_schema_constraint_singleton_03b | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_constraint_singleton_04a(self):
# `??` allowed in singleton
"""
type X {
property a -> int64 {
constraint expression on (
__subject__ ?? 1 = 0
);
}
};
""" | type X {
property a -> int64 {
constraint expression on (
__subject__ ?? 1 = 0
);
}
}; | test_schema_constraint_singleton_04a | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_constraint_singleton_04b(self):
"""
type X {
multi property a -> int64 {
constraint expression on (
__subject__ ?? 1 = 0
);
}
};
""" | type X {
multi property a -> int64 {
constraint expression on (
__subject__ ?? 1 = 0
);
}
}; | test_schema_constraint_singleton_04b | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_constraint_singleton_05a(self):
# `IF` allowed in singleton
"""
type X {
property a -> tuple<bool, int64> {
constraint expression on (
__subject__.1 < 0
if __subject__.0 else
__subject__.1 >= 0
);
}
};
""" | type X {
property a -> tuple<bool, int64> {
constraint expression on (
__subject__.1 < 0
if __subject__.0 else
__subject__.1 >= 0
);
}
}; | test_schema_constraint_singleton_05a | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_constraint_singleton_05b(self):
"""
type X {
multi property a -> tuple<bool, int64> {
constraint expression on (
__subject__.1 < 0
if __subject__.0 else
__subject__.1 >= 0
);
}
};
""" | type X {
multi property a -> tuple<bool, int64> {
constraint expression on (
__subject__.1 < 0
if __subject__.0 else
__subject__.1 >= 0
);
}
}; | test_schema_constraint_singleton_05b | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_index_non_singleton_01(self):
"""
type IndexNonSingletonTest {
property has_bad_index -> str;
index on (distinct .has_bad_index)
}
""" | type IndexNonSingletonTest {
property has_bad_index -> str;
index on (distinct .has_bad_index)
} | test_schema_index_non_singleton_01 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_index_non_singleton_02(self):
"""
type IndexNonSingletonTest {
property has_bad_index -> str;
index on (count(.has_bad_index))
}
""" | type IndexNonSingletonTest {
property has_bad_index -> str;
index on (count(.has_bad_index))
} | test_schema_index_non_singleton_02 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_incompatible_union_01(self):
"""
type X {
property a -> int64;
}
type Y {
property a -> str;
}
type Z {
link xy -> X | Y;
}
""" | type X {
property a -> int64;
}
type Y {
property a -> str;
}
type Z {
link xy -> X | Y;
} | test_schema_incompatible_union_01 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_incompatible_union_02(self):
"""
type A;
type X {
property a -> int64;
}
type Y {
link a -> A;
}
type Z {
link xy -> X | Y;
}
""" | type A;
type X {
property a -> int64;
}
type Y {
link a -> A;
}
type Z {
link xy -> X | Y;
} | test_schema_incompatible_union_02 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_incompatible_union_03(self):
"""
type A;
type X {
link a -> A {
b -> int64
};
}
type Y {
link a -> A {
b -> str
}
}
type Z {
link xy -> X | Y;
}
""" | type A;
type X {
link a -> A {
b -> int64
};
}
type Y {
link a -> A {
b -> str
}
}
type Z {
link xy -> X | Y;
} | test_schema_incompatible_union_03 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_query_parameter_01(self):
"""
type Foo { foo := <int64>$0 }
""" | type Foo { foo := <int64>$0 } | test_schema_query_parameter_01 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_query_parameter_02(self):
"""
global foo := <int64>$0
""" | global foo := <int64>$0 | test_schema_query_parameter_02 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_unknown_typename_01(self):
"""
type A;
type B {
link a -> A;
property x := <C>.a;
}
""" | type A;
type B {
link a -> A;
property x := <C>.a;
} | test_schema_unknown_typename_01 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_unknown_typename_02(self):
"""
type A;
type B {
link a -> A;
property x := .a is C;
}
""" | type A;
type B {
link a -> A;
property x := .a is C;
} | test_schema_unknown_typename_02 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_unknown_typename_03(self):
"""
type A;
type B {
link a -> A;
property x := .a is null;
}
""" | type A;
type B {
link a -> A;
property x := .a is null;
} | test_schema_unknown_typename_03 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
def test_schema_unknown_typename_04(self):
"""
type A;
type B {
link a -> A;
property x := .a is NONE;
}
""" | type A;
type B {
link a -> A;
property x := .a is NONE;
} | test_schema_unknown_typename_04 | python | geldata/gel | tests/test_schema.py | https://github.com/geldata/gel/blob/master/tests/test_schema.py | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.