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
async def test_edgeql_insert_single_linkprop(self): await self.con.execute(''' insert Subordinate { name := "1" }; insert Subordinate { name := "2" }; ''') for _ in range(10): await self.con.execute(''' insert InsertTest { l2 := -1, sub := (select Subordinate { @note := "!" } order by random() limit 1) }; ''') await self.assert_query_result( ''' select InsertTest { sub: {name, @note} }; ''', [{"sub": {"name": str, "@note": "!"}}] * 10, ) await self.con.execute(''' update InsertTest set { sub := (select Subordinate { @note := "!" } order by random() limit 1) }; ''') await self.assert_query_result( ''' select InsertTest { sub: {name, @note} }; ''', [{"sub": {"name": str, "@note": "!"}}] * 10, )
) for _ in range(10): await self.con.execute(
test_edgeql_insert_single_linkprop
python
geldata/gel
tests/test_edgeql_insert.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_insert.py
Apache-2.0
async def test_edgeql_insert_conditional_01(self): await self.assert_query_result( ''' select if <bool>$0 then ( insert InsertTest { l2 := 2 } ) else ( insert DerivedTest { l2 := 200 } ) ''', [{}], variables=(True,) ) await self.assert_query_result( ''' select InsertTest { l2, tname := .__type__.name } ''', [ {"l2": 2, "tname": "default::InsertTest"}, ], ) await self.assert_query_result( ''' select if <bool>$0 then ( insert InsertTest { l2 := 2 } ) else ( insert DerivedTest { l2 := 200 } ) ''', [{}], variables=(False,) ) await self.assert_query_result( ''' select InsertTest { l2, tname := .__type__.name } order by .l2 ''', [ {"l2": 2, "tname": "default::InsertTest"}, {"l2": 200, "tname": "default::DerivedTest"}, ], ) await self.assert_query_result( ''' select if array_unpack(<array<bool>>$0) then ( insert InsertTest { l2 := 2 } ) else ( insert DerivedTest { l2 := 200 } ) ''', [{}, {}], variables=([True, False],) ) await self.assert_query_result( ''' with go := <bool>$0 select if go then ( insert InsertTest { l2 := 100 } ) else {} ''', [{}], variables=(True,) ) await self.assert_query_result( ''' select InsertTest { l2, tname := .__type__.name } order by .l2 ''', [ {"l2": 2, "tname": "default::InsertTest"}, {"l2": 2, "tname": "default::InsertTest"}, {"l2": 100, "tname": "default::InsertTest"}, {"l2": 200, "tname": "default::DerivedTest"}, {"l2": 200, "tname": "default::DerivedTest"}, ], )
select if <bool>$0 then ( insert InsertTest { l2 := 2 } ) else ( insert DerivedTest { l2 := 200 } ) ''', [{}], variables=(True,) ) await self.assert_query_result(
test_edgeql_insert_conditional_01
python
geldata/gel
tests/test_edgeql_insert.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_insert.py
Apache-2.0
async def test_edgeql_insert_conditional_03(self): await self.assert_query_result( ''' select (for n in array_unpack(<array<int64>>$0) union ( if n % 2 = 0 then (insert InsertTest { l2 := n }) else {} )) { l2 } order by .l2; ''', [{'l2': 2}, {'l2': 4}], variables=([1, 2, 3, 4, 5],), ) await self.assert_query_result( ''' select InsertTest { l2 } order by .l2; ''', [{'l2': 2}, {'l2': 4}], )
select (for n in array_unpack(<array<int64>>$0) union ( if n % 2 = 0 then (insert InsertTest { l2 := n }) else {} )) { l2 } order by .l2; ''', [{'l2': 2}, {'l2': 4}], variables=([1, 2, 3, 4, 5],), ) await self.assert_query_result(
test_edgeql_insert_conditional_03
python
geldata/gel
tests/test_edgeql_insert.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_insert.py
Apache-2.0
async def test_edgeql_insert_coalesce_01(self): await self.assert_query_result( ''' select (select InsertTest filter .l2 = 2) ?? (insert InsertTest { l2 := 2 }); ''', [{}], ) await self.assert_query_result( ''' select (select InsertTest filter .l2 = 2) ?? (insert InsertTest { l2 := 2 }); ''', [{}], ) await self.assert_query_result( ''' select count((delete InsertTest)) ''', [1], )
select (select InsertTest filter .l2 = 2) ?? (insert InsertTest { l2 := 2 }); ''', [{}], ) await self.assert_query_result(
test_edgeql_insert_coalesce_01
python
geldata/gel
tests/test_edgeql_insert.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_insert.py
Apache-2.0
async def test_edgeql_insert_coalesce_02(self): await self.assert_query_result( ''' select ((select InsertTest filter .l2 = 2), true) ?? ((insert InsertTest { l2 := 2 }), false); ''', [({}, False)], ) await self.assert_query_result( ''' select ((select InsertTest filter .l2 = 2), true) ?? ((insert InsertTest { l2 := 2 }), false); ''', [({}, True)], )
select ((select InsertTest filter .l2 = 2), true) ?? ((insert InsertTest { l2 := 2 }), false); ''', [({}, False)], ) await self.assert_query_result(
test_edgeql_insert_coalesce_02
python
geldata/gel
tests/test_edgeql_insert.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_insert.py
Apache-2.0
async def test_edgeql_insert_coalesce_03(self): await self.assert_query_result( ''' select ( (update InsertTest filter .l2 = 2 set { name := "!" }) ?? (insert InsertTest { l2 := 2, name := "?" }) ) { l2, name } ''', [{'l2': 2, 'name': "?"}], ) await self.assert_query_result( ''' select ( (update InsertTest filter .l2 = 2 set { name := "!" }) ?? (insert InsertTest { l2 := 2, name := "?" }) ) { l2, name } ''', [{'l2': 2, 'name': "!"}], ) await self.assert_query_result( ''' select InsertTest { l2, name } ''', [{'l2': 2, 'name': "!"}], ) await self.assert_query_result( ''' select count((delete InsertTest)) ''', [1], )
select ( (update InsertTest filter .l2 = 2 set { name := "!" }) ?? (insert InsertTest { l2 := 2, name := "?" }) ) { l2, name } ''', [{'l2': 2, 'name': "?"}], ) await self.assert_query_result(
test_edgeql_insert_coalesce_03
python
geldata/gel
tests/test_edgeql_insert.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_insert.py
Apache-2.0
async def test_edgeql_ddl_default_09(self): await self.con.execute(r""" CREATE TYPE Foo; """) with self.assertRaisesRegex( edgedb.UnsupportedFeatureError, "default value for property 'x' of link 'asdf' of object type " "'default::Bar' is too complicated; " "link property defaults must not depend on database contents" ): await self.con.execute(''' create type Bar { create link asdf -> Foo { create property x -> int64 { set default := count(Object) } } }; ''')
) with self.assertRaisesRegex( edgedb.UnsupportedFeatureError, "default value for property 'x' of link 'asdf' of object type " "'default::Bar' is too complicated; " "link property defaults must not depend on database contents" ): await self.con.execute(
test_edgeql_ddl_default_09
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_default_14(self): await self.con.execute(r""" create type X; insert X; """) with self.assertRaisesRegex( edgedb.MissingRequiredError, 'missing value for required property', ): await self.con.execute(r""" alter type X { create required property foo -> str { set default := (select "!" filter false); } }; """)
) with self.assertRaisesRegex( edgedb.MissingRequiredError, 'missing value for required property', ): await self.con.execute(r
test_edgeql_ddl_default_14
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_link_target_bad_01(self): await self.con.execute(''' CREATE TYPE A; CREATE TYPE B; CREATE TYPE Base0 { CREATE LINK foo -> A; }; CREATE TYPE Base1 { CREATE LINK foo -> B; }; ''') with self.assertRaisesRegex( edgedb.SchemaError, "inherited link 'foo' of object type 'default::Derived' has a " "type conflict" ): await self.con.execute(''' CREATE TYPE Derived EXTENDING Base0, Base1; ''')
) with self.assertRaisesRegex( edgedb.SchemaError, "inherited link 'foo' of object type 'default::Derived' has a " "type conflict" ): await self.con.execute(
test_edgeql_ddl_link_target_bad_01
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_link_target_bad_02(self): await self.con.execute(''' CREATE TYPE A; CREATE TYPE B; CREATE TYPE C; CREATE TYPE Base0 { CREATE LINK foo -> A | B; }; CREATE TYPE Base1 { CREATE LINK foo -> C; }; ''') with self.assertRaisesRegex( edgedb.SchemaError, "inherited link 'foo' of object type 'default::Derived' " "has a type conflict" ): await self.con.execute(''' CREATE TYPE Derived EXTENDING Base0, Base1; ''')
) with self.assertRaisesRegex( edgedb.SchemaError, "inherited link 'foo' of object type 'default::Derived' " "has a type conflict" ): await self.con.execute(
test_edgeql_ddl_link_target_bad_02
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_link_target_bad_03(self): await self.con.execute(''' CREATE TYPE A; CREATE TYPE Foo { CREATE LINK a -> A; CREATE PROPERTY b -> str; }; ''') async with self.assertRaisesRegexTx( edgedb.SchemaError, "cannot RESET TYPE of link 'a' of object type 'default::Foo' " "because it is not inherited"): await self.con.execute(''' ALTER TYPE Foo ALTER LINK a RESET TYPE; ''') async with self.assertRaisesRegexTx( edgedb.SchemaError, "cannot RESET TYPE of property 'b' of object type " "'default::Foo' because it is not inherited"): await self.con.execute(''' ALTER TYPE Foo ALTER PROPERTY b RESET TYPE; ''')
) async with self.assertRaisesRegexTx( edgedb.SchemaError, "cannot RESET TYPE of link 'a' of object type 'default::Foo' " "because it is not inherited"): await self.con.execute(
test_edgeql_ddl_link_target_bad_03
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_link_target_bad_04(self): await self.con.execute(''' CREATE TYPE Foo; CREATE TYPE Bar; ''') with self.assertRaisesRegex( edgedb.UnsupportedFeatureError, "unsupported type intersection in schema" ): await self.con.execute(''' CREATE TYPE Spam { CREATE MULTI LINK foobar := Foo[IS Bar] }; ''')
) with self.assertRaisesRegex( edgedb.UnsupportedFeatureError, "unsupported type intersection in schema" ): await self.con.execute(
test_edgeql_ddl_link_target_bad_04
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_prop_target_subtype_01(self): await self.con.execute(r""" CREATE SCALAR TYPE mystr EXTENDING std::str { CREATE CONSTRAINT std::max_len_value(5) }; CREATE TYPE Foo { CREATE PROPERTY a -> std::str; }; CREATE TYPE Bar EXTENDING Foo { ALTER PROPERTY a SET TYPE mystr; }; """) await self.con.execute('INSERT Foo { a := "123456" }') async with self.assertRaisesRegexTx( edgedb.ConstraintViolationError, 'must be no longer than 5 characters' ): await self.con.execute('INSERT Bar { a := "123456" }') await self.con.execute(""" ALTER TYPE Bar ALTER PROPERTY a RESET TYPE; """) await self.con.execute('INSERT Bar { a := "123456" }')
) await self.con.execute('INSERT Foo { a := "123456" }') async with self.assertRaisesRegexTx( edgedb.ConstraintViolationError, 'must be no longer than 5 characters' ): await self.con.execute('INSERT Bar { a := "123456" }') await self.con.execute(
test_edgeql_ddl_prop_target_subtype_01
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_ptr_set_type_using_01(self): await self.con.execute(r""" CREATE SCALAR TYPE mystr EXTENDING str; CREATE TYPE Bar { CREATE PROPERTY name -> str; }; CREATE TYPE SubBar EXTENDING Bar; CREATE TYPE Foo { CREATE PROPERTY p -> str { CREATE CONSTRAINT exclusive; }; CREATE CONSTRAINT exclusive ON (.p); CREATE REQUIRED PROPERTY r_p -> str; CREATE MULTI PROPERTY m_p -> str; CREATE REQUIRED MULTI PROPERTY rm_p -> str; CREATE LINK l -> Bar { CREATE PROPERTY lp -> str; }; CREATE REQUIRED LINK r_l -> Bar { CREATE PROPERTY lp -> str; }; CREATE MULTI LINK m_l -> Bar { CREATE PROPERTY lp -> str; }; CREATE REQUIRED MULTI LINK rm_l -> Bar { CREATE PROPERTY lp -> str; }; }; INSERT Bar {name := 'bar1'}; INSERT SubBar {name := 'bar2'}; WITH bar := (SELECT Bar FILTER .name = 'bar1' LIMIT 1), bars := (SELECT Bar), INSERT Foo { p := '1', r_p := '10', m_p := {'1', '2'}, rm_p := {'10', '20'}, l := bar { @lp := '1' }, r_l := bar { @lp := '10' }, m_l := ( FOR bar IN {enumerate(bars)} UNION (SELECT bar.1 { @lp := <str>(bar.0 + 1) }) ), rm_l := ( FOR bar IN {enumerate(bars)} UNION (SELECT bar.1 { @lp := <str>((bar.0 + 1) * 10) }) ) }; WITH bar := (SELECT Bar FILTER .name = 'bar2' LIMIT 1), bars := (SELECT Bar), INSERT Foo { p := '3', r_p := '30', m_p := {'3', '4'}, rm_p := {'30', '40'}, l := bar { @lp := '3' }, r_l := bar { @lp := '30' }, m_l := ( FOR bar IN {enumerate(bars)} UNION (SELECT bar.1 { @lp := <str>(bar.0 + 3) }) ), rm_l := ( FOR bar IN {enumerate(bars)} UNION (SELECT bar.1 { @lp := <str>((bar.0 + 3) * 10) }) ) }; """) # A normal cast of a property. async with self._run_and_rollback(): await self.con.execute(""" ALTER TYPE Foo ALTER PROPERTY p { SET TYPE int64 USING (<int64>.p) } """) await self.assert_query_result( 'SELECT Foo { p } ORDER BY .p', [ {'p': 1}, {'p': 3}, ], ) await self.con.execute(""" ALTER TYPE Foo ALTER PROPERTY m_p { SET TYPE int64 USING (<int64>.m_p) } """) await self.assert_query_result( 'SELECT Foo { m_p } ORDER BY .p', [ {'m_p': {1, 2}}, {'m_p': {3, 4}}, ], ) # Cast to an already-compatible type, but with an explicit expression. async with self._run_and_rollback(): await self.con.execute(""" ALTER TYPE Foo ALTER PROPERTY p { SET TYPE mystr USING (.p ++ '!') } """) await self.assert_query_result( 'SELECT Foo { p } ORDER BY .p', [ {'p': '1!'}, {'p': '3!'}, ], ) # Cast to the _same_ type, but with an explicit expression. async with self._run_and_rollback(): await self.con.execute(""" ALTER TYPE Foo ALTER PROPERTY p { SET TYPE str USING (.p ++ '!') } """) await self.assert_query_result( 'SELECT Foo { p } ORDER BY .p', [ {'p': '1!'}, {'p': '3!'}, ], ) # A reference to another property of the same host type. async with self._run_and_rollback(): await self.con.execute(""" ALTER TYPE Foo ALTER PROPERTY p { SET TYPE int64 USING (<int64>.r_p) } """) await self.assert_query_result( 'SELECT Foo { p } ORDER BY .p', [ {'p': 10}, {'p': 30}, ], ) await self.con.execute(""" ALTER TYPE Foo ALTER PROPERTY m_p { SET TYPE int64 USING (<int64>.m_p + <int64>.r_p) } """) await self.assert_query_result( 'SELECT Foo { m_p } ORDER BY .p', [ {'m_p': {11, 12}}, {'m_p': {33, 34}}, ], ) async with self._run_and_rollback(): # This had trouble if there was a SELECT, at one point. await self.con.execute(""" ALTER TYPE Foo ALTER PROPERTY m_p { SET TYPE int64 USING (SELECT <int64>.m_p + <int64>.r_p) } """) # Conversion expression that reduces cardinality... async with self._run_and_rollback(): await self.con.execute(""" ALTER TYPE Foo ALTER PROPERTY p { SET TYPE int64 USING (<int64>{}) } """) await self.assert_query_result( 'SELECT Foo { p } ORDER BY .p', [ {'p': None}, {'p': None}, ], ) await self.con.execute(""" ALTER TYPE Foo ALTER PROPERTY m_p { SET TYPE int64 USING ( <int64>{} IF <int64>.m_p % 2 = 0 ELSE <int64>.m_p ) } """) await self.assert_query_result( 'SELECT Foo { m_p } ORDER BY .p', [ {'m_p': {1}}, {'m_p': {3}}, ], ) # ... should fail if empty set is produced and the property is required async with self.assertRaisesRegexTx( edgedb.MissingRequiredError, r"missing value for required property 'r_p'" r" of object type 'default::Foo'" ): await self.con.execute(""" ALTER TYPE Foo ALTER PROPERTY r_p { SET TYPE int64 USING (<int64>{}) } """) async with self.assertRaisesRegexTx( edgedb.MissingRequiredError, r"missing value for required property 'rm_p'" r" of object type 'default::Foo'" ): await self.con.execute(""" ALTER TYPE Foo ALTER PROPERTY rm_p { SET TYPE int64 USING ( <int64>{} IF True ELSE <int64>.rm_p ) } """) # Straightforward link cast. async with self._run_and_rollback(): await self.con.execute(""" ALTER TYPE Foo ALTER LINK l { SET TYPE SubBar USING (.l[IS SubBar]) } """) await self.assert_query_result( 'SELECT Foo { l: {name} } ORDER BY .p', [ {'l': None}, {'l': {'name': 'bar2'}}, ], ) await self.con.execute(""" ALTER TYPE Foo ALTER LINK m_l { SET TYPE SubBar USING (.m_l[IS SubBar]) } """) await self.assert_query_result( 'SELECT Foo { m_l: {name} } ORDER BY .p', [ {'m_l': [{'name': 'bar2'}]}, {'m_l': [{'name': 'bar2'}]}, ], ) # Use a more elaborate expression for the tranform. async with self._run_and_rollback(): await self.con.execute(""" ALTER TYPE Foo ALTER LINK l { SET TYPE SubBar USING (SELECT .m_l[IS SubBar] LIMIT 1) } """) await self.assert_query_result( 'SELECT Foo { l: {name, @lp} } ORDER BY .p', [ {'l': {'name': 'bar2', '@lp': '1'}}, {'l': {'name': 'bar2', '@lp': '3'}}, ], ) # Check that minimum cardinality constraint is enforced on links too... async with self.assertRaisesRegexTx( edgedb.MissingRequiredError, r"missing value for required link 'r_l'" r" of object type 'default::Foo'" ): await self.con.execute(""" ALTER TYPE Foo ALTER LINK r_l { SET TYPE SubBar USING (.r_l[IS SubBar]) } """) async with self.assertRaisesRegexTx( edgedb.MissingRequiredError, r"missing value for required link 'rm_l'" r" of object type 'default::Foo'" ): await self.con.execute(""" ALTER TYPE Foo ALTER LINK rm_l { SET TYPE SubBar USING (SELECT SubBar FILTER False LIMIT 1) } """) # Test link property transforms now. async with self._run_and_rollback(): await self.con.execute(""" ALTER TYPE Foo ALTER LINK l ALTER PROPERTY lp { SET TYPE int64 USING (<int64>@lp) } """) await self.assert_query_result( 'SELECT Foo { l: { @lp } } ORDER BY .p', [ {'l': {'@lp': 1}}, {'l': {'@lp': 3}}, ], ) async with self._run_and_rollback(): # Also once had SELECT trouble await self.con.execute(""" ALTER TYPE Foo ALTER LINK l ALTER PROPERTY lp { SET TYPE int64 USING (SELECT <int64>@lp) } """)
) # A normal cast of a property. async with self._run_and_rollback(): await self.con.execute(
test_edgeql_ddl_ptr_set_type_using_01
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_ptr_set_type_validation(self): await self.con.execute(r""" CREATE TYPE Bar; CREATE TYPE Spam; CREATE TYPE Egg; CREATE TYPE Foo { CREATE PROPERTY p -> str; CREATE LINK l -> Bar { CREATE PROPERTY lp -> str; }; }; """) async with self.assertRaisesRegexTx( edgedb.SchemaError, r"property 'p' of object type 'default::Foo' cannot be cast" r" automatically from scalar type 'std::str' to scalar" r" type 'std::int64'" ): await self.con.execute(""" ALTER TYPE Foo ALTER PROPERTY p SET TYPE int64; """) async with self.assertRaisesRegexTx( edgedb.SchemaError, r"result of USING clause for the alteration of" r" property 'p' of object type 'default::Foo' cannot be cast" r" automatically from scalar type 'std::float64' to scalar" r" type 'std::int64'" ): await self.con.execute(""" ALTER TYPE Foo ALTER PROPERTY p SET TYPE int64 USING (<float64>.p) """) async with self.assertRaisesRegexTx( edgedb.SchemaError, r"possibly more than one element returned by the USING clause for" r" the alteration of property 'p' of object type 'default::Foo'," r" while a singleton is expected" ): await self.con.execute(""" ALTER TYPE Foo ALTER PROPERTY p SET TYPE int64 USING ({1, 2}) """) async with self.assertRaisesRegexTx( edgedb.SchemaError, r"link 'l' of object type 'default::Foo' cannot be cast" r" automatically from object type 'default::Bar' to object" r" type 'default::Spam'" ): await self.con.execute(""" ALTER TYPE Foo ALTER LINK l SET TYPE Spam; """) async with self.assertRaisesRegexTx( edgedb.SchemaError, r"result of USING clause for the alteration of" r" link 'l' of object type 'default::Foo' cannot be cast" r" automatically from object type '\(default::Bar & default::Egg\)'" r" to object type 'default::Spam'" ): await self.con.execute(""" ALTER TYPE Foo ALTER LINK l SET TYPE Spam USING (.l[IS Egg]) """) async with self.assertRaisesRegexTx( edgedb.SchemaError, r"possibly more than one element returned by the USING clause for" r" the alteration of link 'l' of object type 'default::Foo', while" r" a singleton is expected" ): await self.con.execute(""" ALTER TYPE Foo ALTER LINK l SET TYPE Spam USING (SELECT Spam) """)
) async with self.assertRaisesRegexTx( edgedb.SchemaError, r"property 'p' of object type 'default::Foo' cannot be cast" r" automatically from scalar type 'std::str' to scalar" r" type 'std::int64'" ): await self.con.execute(
test_edgeql_ddl_ptr_set_type_validation
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_ptr_using_dml_01(self): await self.con.execute( r""" CREATE TYPE Hello; CREATE TYPE World { CREATE LINK hell -> Hello; CREATE MULTI LINK heaven -> Hello; }; INSERT World { heaven := { (INSERT Hello), (INSERT Hello), (INSERT Hello), } }; INSERT World { hell := (INSERT Hello), heaven := { (INSERT Hello), (INSERT Hello), } }; """ ) self.assertEqual(len(await self.con.query("SELECT Hello")), 6) await self.con.execute( r""" ALTER TYPE World { ALTER LINK hell SET REQUIRED USING (INSERT Hello); ALTER LINK heaven SET SINGLE USING (INSERT Hello); } """ ) self.assertEqual(len(await self.con.query("SELECT Hello")), 9) res = await self.con.query( "SELECT World { hell: { id }, heaven: { id } }" ) self.assertEqual(len(res), 2) set_of_hellos = { world.hell.id for world in res }.union({ world.heaven.id for world in res }) self.assertEqual(len(set_of_hellos), 4)
) self.assertEqual(len(await self.con.query("SELECT Hello")), 6) await self.con.execute( r
test_edgeql_ddl_ptr_using_dml_01
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_ptr_using_dml_02(self): await self.con.execute( r""" CREATE TYPE Hello; CREATE TYPE World { CREATE LINK hell -> Hello; CREATE MULTI LINK heaven -> Hello; }; """ ) await self.con.execute( r""" ALTER TYPE World { ALTER LINK hell SET REQUIRED USING (INSERT Hello); ALTER LINK heaven SET SINGLE USING (INSERT Hello); } """ )
) await self.con.execute( r
test_edgeql_ddl_ptr_using_dml_02
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_ptr_set_cardinality_validation(self): await self.con.execute(r""" CREATE TYPE Bar; CREATE TYPE Egg; CREATE TYPE Foo { CREATE MULTI PROPERTY p -> str; CREATE MULTI LINK l -> Bar { CREATE PROPERTY lp -> str; }; }; """) async with self.assertRaisesRegexTx( edgedb.SchemaError, r"cannot automatically convert property 'p' of object type" r" 'default::Foo' to 'single' cardinality" ): await self.con.execute(""" ALTER TYPE Foo ALTER PROPERTY p SET SINGLE; """) async with self.assertRaisesRegexTx( edgedb.SchemaError, r"result of USING clause for the alteration of" r" property 'p' of object type 'default::Foo' cannot be cast" r" automatically from scalar type 'std::float64' to scalar" r" type 'std::int64'" ): await self.con.execute(""" ALTER TYPE Foo ALTER PROPERTY p SET TYPE int64 USING (<float64>.p) """) async with self.assertRaisesRegexTx( edgedb.SchemaError, r"possibly more than one element returned by the USING clause for" r" the alteration of property 'p' of object type 'default::Foo'," r" while a singleton is expected" ): await self.con.execute(""" ALTER TYPE Foo ALTER PROPERTY p SET SINGLE USING ({1, 2}) """) async with self.assertRaisesRegexTx( edgedb.SchemaError, r"cannot automatically convert link 'l' of object type" r" 'default::Foo' to 'single' cardinality" ): await self.con.execute(""" ALTER TYPE Foo ALTER LINK l SET SINGLE; """) async with self.assertRaisesRegexTx( edgedb.SchemaError, r"result of USING clause for the alteration of" r" link 'l' of object type 'default::Foo' cannot be cast" r" automatically from object type 'default::Egg'" r" to object type 'default::Bar'" ): await self.con.execute(""" ALTER TYPE Foo ALTER LINK l SET SINGLE USING (SELECT Egg LIMIT 1); """) async with self.assertRaisesRegexTx( edgedb.SchemaError, r"possibly more than one element returned by the USING clause for" r" the alteration of link 'l' of object type 'default::Foo', while" r" a singleton is expected" ): await self.con.execute(""" ALTER TYPE Foo ALTER LINK l SET SINGLE USING (SELECT Bar) """)
) async with self.assertRaisesRegexTx( edgedb.SchemaError, r"cannot automatically convert property 'p' of object type" r" 'default::Foo' to 'single' cardinality" ): await self.con.execute(
test_edgeql_ddl_ptr_set_cardinality_validation
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_link_long_01(self): link_name = ( 'f123456789_123456789_123456789_123456789' '_123456789_123456789_123456789_123456789' ) await self.con.execute(f""" CREATE ABSTRACT LINK {link_name}; """) await self.con.execute(f""" CREATE TYPE Foo {{ CREATE LINK {link_name} -> Foo; }}; """) await self.con.query(f"SELECT Foo.{link_name}")
) await self.con.execute(f
test_edgeql_ddl_link_long_01
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_function_01(self): await self.con.execute(""" CREATE FUNCTION my_lower(s: std::str) -> std::str USING SQL FUNCTION 'lower'; """) with self.assertRaisesRegex(edgedb.DuplicateFunctionDefinitionError, r'cannot create.*my_lower.*func'): async with self.con.transaction(): await self.con.execute(""" CREATE FUNCTION my_lower(s: SET OF std::str) -> std::str { SET initial_value := ''; USING SQL FUNCTION 'count'; }; """) await self.con.execute(""" DROP FUNCTION my_lower(s: std::str); """) await self.con.execute(""" CREATE FUNCTION my_lower(s: SET OF anytype) -> std::str { USING SQL FUNCTION 'count'; SET initial_value := ''; }; """) with self.assertRaisesRegex(edgedb.DuplicateFunctionDefinitionError, r'cannot create.*my_lower.*func'): async with self.con.transaction(): await self.con.execute(""" CREATE FUNCTION my_lower(s: anytype) -> std::str USING SQL FUNCTION 'lower'; """) await self.con.execute(""" DROP FUNCTION my_lower(s: anytype); """)
) with self.assertRaisesRegex(edgedb.DuplicateFunctionDefinitionError, r'cannot create.*my_lower.*func'): async with self.con.transaction(): await self.con.execute(
test_edgeql_ddl_function_01
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_function_08(self): async with self.assertRaisesRegexTx( edgedb.InvalidFunctionDefinitionError, r'invalid declaration.*unexpected type of the default'): await self.con.execute(""" CREATE FUNCTION ddlf_08(s: std::str = 1) -> std::str USING EdgeQL $$ SELECT "1" $$; """) async with self.assertRaisesRegexTx( edgedb.InvalidFunctionDefinitionError, r'invalid declaration.*unexpected type of the default'): await self.con.execute(""" CREATE FUNCTION ddlf_08(s: std::str = ()) -> std::str USING EdgeQL $$ SELECT "1" $$; """)
) async with self.assertRaisesRegexTx( edgedb.InvalidFunctionDefinitionError, r'invalid declaration.*unexpected type of the default'): await self.con.execute(
test_edgeql_ddl_function_08
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_function_09(self): await self.con.execute(""" CREATE FUNCTION ddlf_09( NAMED ONLY a: int64, NAMED ONLY b: int64 ) -> std::str USING EdgeQL $$ SELECT "1" $$; """) with self.assertRaisesRegex( edgedb.DuplicateFunctionDefinitionError, r'already defined'): async with self.con.transaction(): await self.con.execute(""" CREATE FUNCTION ddlf_09( NAMED ONLY b: int64, NAMED ONLY a: int64 = 1 ) -> std::str USING EdgeQL $$ SELECT "1" $$; """) await self.con.execute(""" CREATE FUNCTION ddlf_09( NAMED ONLY b: str, NAMED ONLY a: int64 ) -> std::str USING EdgeQL $$ SELECT "2" $$; """) await self.assert_query_result( r''' SELECT ddlf_09(a:=1, b:=1); ''', ['1'], ) await self.assert_query_result( r''' SELECT ddlf_09(a:=1, b:='a'); ''', ['2'], )
) with self.assertRaisesRegex( edgedb.DuplicateFunctionDefinitionError, r'already defined'): async with self.con.transaction(): await self.con.execute(
test_edgeql_ddl_function_09
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_function_13(self): with self.assertRaisesRegex( edgedb.UnsupportedFeatureError, r'cannot create.*ddlf_13\(a: SET OF std::int64\).*' r'SET OF parameters in user-defined EdgeQL functions are ' r'not supported'): async with self.con.transaction(): await self.con.execute(r''' CREATE FUNCTION ddlf_13(a: SET OF int64) -> int64 USING EdgeQL $$ SELECT 11 $$; ''') with self.assertRaises(edgedb.InvalidReferenceError): await self.con.execute(""" DROP FUNCTION ddlf_13(a: SET OF int64); """)
) with self.assertRaises(edgedb.InvalidReferenceError): await self.con.execute(
test_edgeql_ddl_function_13
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_function_17(self): await self.con.execute(r''' CREATE FUNCTION ddlf_17(str: std::str) -> int32 USING SQL FUNCTION 'char_length'; ''') with self.assertRaisesRegex( edgedb.InvalidFunctionDefinitionError, r'cannot create.*ddlf_17.*' r'overloading "USING SQL FUNCTION"'): async with self.con.transaction(): await self.con.execute(r''' CREATE FUNCTION ddlf_17(str: std::int64) -> int32 USING SQL FUNCTION 'whatever2'; ''') await self.con.execute(""" DROP FUNCTION ddlf_17(str: std::str); """)
) with self.assertRaisesRegex( edgedb.InvalidFunctionDefinitionError, r'cannot create.*ddlf_17.*' r'overloading "USING SQL FUNCTION"'): async with self.con.transaction(): await self.con.execute(r
test_edgeql_ddl_function_17
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_function_27(self): # This test checks constants, but we have to do DDLs to test them # with constant extraction disabled await self.con.execute(''' CREATE FUNCTION constant_int() -> std::int64 { USING (SELECT 1_024); }; CREATE FUNCTION constant_bigint() -> std::bigint { USING (SELECT 1_024n); }; CREATE FUNCTION constant_float() -> std::float64 { USING (SELECT 1_024.1_250); }; CREATE FUNCTION constant_decimal() -> std::decimal { USING (SELECT 1_024.1_024n); }; ''') try: await self.assert_query_result( r''' SELECT ( int := constant_int(), bigint := constant_bigint(), float := constant_float(), decimal := constant_decimal(), ) ''', [{ "int": 1024, "bigint": 1024, "float": 1024.125, "decimal": 1024.1024, }], [{ "int": 1024, "bigint": 1024, "float": 1024.125, "decimal": decimal.Decimal('1024.1024'), }], ) finally: await self.con.execute(""" DROP FUNCTION constant_int(); DROP FUNCTION constant_float(); DROP FUNCTION constant_bigint(); DROP FUNCTION constant_decimal(); """)
) try: await self.assert_query_result( r
test_edgeql_ddl_function_27
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_function_31(self): await self.con.execute(r''' CREATE FUNCTION foo() -> str USING ('a'); ''') with self.assertRaisesRegex( edgedb.InvalidFunctionDefinitionError, r"return type mismatch"): await self.con.execute(r''' ALTER FUNCTION foo() USING (1); ''')
) with self.assertRaisesRegex( edgedb.InvalidFunctionDefinitionError, r"return type mismatch"): await self.con.execute(r
test_edgeql_ddl_function_31
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_function_32(self): await self.con.execute(r''' CREATE TYPE Foo; CREATE TYPE Bar; INSERT Foo; INSERT Bar; ''') # All these overloads are OK. await self.con.execute(r""" CREATE FUNCTION func32_ok(obj: Foo, a: int64) -> str USING ('Foo int64'); CREATE FUNCTION func32_ok(obj: Bar, a: int64) -> str USING ('Bar int64'); CREATE FUNCTION func32_ok(s: str, a: int64) -> str USING ('str int64'); CREATE FUNCTION func32_ok(s: str, a: Foo) -> str USING ('str Foo'); CREATE FUNCTION func32_ok(s: str, a: Bar) -> str USING ('str Bar'); CREATE FUNCTION func32_ok(s: str, a: str, b: str) -> str USING ('str str str'); """) await self.assert_query_result( r""" WITH Foo := assert_single(Foo), Bar := assert_single(Bar), SELECT { Foo_int64 := func32_ok(Foo, 1), Bar_int64 := func32_ok(Bar, 1), str_int64 := func32_ok("a", 1), str_Foo := func32_ok("a", Foo), str_Bar := func32_ok("a", Bar), str_str_str := func32_ok("a", "b", "c"), } """, [{ "Foo_int64": "Foo int64", "Bar_int64": "Bar int64", "str_int64": "str int64", "str_Foo": "str Foo", "str_Bar": "str Bar", "str_str_str": "str str str", }] ) async with self.assertRaisesRegexTx( edgedb.UnsupportedFeatureError, r"cannot create the .* function: overloading an object " r"type-receiving function with differences in the remaining " r"parameters is not supported", ): await self.con.execute(r""" CREATE FUNCTION func32_a(obj: Foo, a: int32) -> str USING ('foo'); CREATE FUNCTION func32_a(obj: Bar, a: int64) -> str USING ('bar'); """) async with self.assertRaisesRegexTx( edgedb.UnsupportedFeatureError, r"cannot create the .* function: overloading an object " r"type-receiving function with differences in the remaining " r"parameters is not supported", ): await self.con.execute(r""" CREATE FUNCTION func32_a(obj: Foo, obj2: Bar) -> str USING ('foo'); CREATE FUNCTION func32_a(obj: Bar, obj2: Foo) -> str USING ('bar'); """) async with self.assertRaisesRegexTx( edgedb.UnsupportedFeatureError, r"cannot create the .* function: overloading an object " r"type-receiving function with differences in the remaining " r"parameters is not supported", ): await self.con.execute(r""" CREATE FUNCTION func32_a(obj: Foo, a: int32, b: int64) -> str USING ('foo'); CREATE FUNCTION func32_a(obj: Bar, a: int32) -> str USING ('bar'); """) async with self.assertRaisesRegexTx( edgedb.UnsupportedFeatureError, r"cannot create the .* function: overloading an object " r"type-receiving function with differences in the names " r"of parameters is not supported", ): await self.con.execute(r""" CREATE FUNCTION func32_a(obj: Foo, a: int32) -> str USING ('foo'); CREATE FUNCTION func32_a(obj: Bar, b: int32) -> str USING ('bar'); """) async with self.assertRaisesRegexTx( edgedb.UnsupportedFeatureError, r"cannot create the .* function: overloading an object " r"type-receiving function with differences in the type modifiers " r"of parameters is not supported", ): await self.con.execute(r""" CREATE FUNCTION func32_a(obj: Foo, a: int32) -> str USING ('foo'); CREATE FUNCTION func32_a(obj: Bar, a: OPTIONAL int32) -> str USING ('bar'); """) async with self.assertRaisesRegexTx( edgedb.UnsupportedFeatureError, r"cannot create the .* function: object " r"type-receiving functions may not be overloaded on an OPTIONAL " r"parameter" ): await self.con.execute(r""" CREATE FUNCTION func32_a(obj: OPTIONAL Foo) -> str USING ('foo'); CREATE FUNCTION func32_a(obj: OPTIONAL Bar) -> str USING ('bar'); """)
) # All these overloads are OK. await self.con.execute(r
test_edgeql_ddl_function_32
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_function_37(self): obj = await self.con.query_single(''' create type X; create function getUser(id: uuid) -> set of X { using( select X filter .id = id ) }; insert X; insert X; ''') val = await self.con.query_single( ''' select count(getUser(<uuid>$0)) ''', obj.id, ) self.assertEqual(val, 1)
) val = await self.con.query_single(
test_edgeql_ddl_function_37
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_function_39(self): ''' Creating a function operating on or returning an array of valid scalars. ''' await self.con.execute(''' create function get_singleton( a: array<range<int64>> ) -> array<range<int64>> using( a[:1] ); ''') await self.assert_query_result( r''' select get_singleton([range(1, 3), range(1, 2)]) = [range(1, 3)]; ''', [True] )
Creating a function operating on or returning an array of valid scalars.
test_edgeql_ddl_function_39
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_function_40(self): ''' Overloading with a modifying function. ''' await self.con.execute(''' create type Bar; create type Bar2 extending Bar; create function foo(x: Bar) -> int64 { using (1); }; ''') with self.assertRaisesRegex( edgedb.SchemaDefinitionError, 'cannot overload an existing function with a modifying function', ): await self.con.execute(''' create function foo(x: Bar2) -> int64 { set volatility := schema::Volatility.Modifying; using (1); }; ''')
Overloading with a modifying function.
test_edgeql_ddl_function_40
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_function_41(self): ''' Overloading a modifying function. ''' await self.con.execute(''' create type Bar; create type Bar2 extending Bar; create function foo(x: Bar) -> int64 { set volatility := schema::Volatility.Modifying; using (1); }; ''') with self.assertRaisesRegex( edgedb.SchemaDefinitionError, 'cannot overload an existing modifying function', ): await self.con.execute(''' create function foo(x: Bar2) -> int64 { using (1); }; ''')
Overloading a modifying function.
test_edgeql_ddl_function_41
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_function_inh_01(self): await self.con.execute(""" create abstract type T; create function countall() -> int64 USING (count(T)); """) await self.assert_query_result( """SELECT countall()""", [0], ) await self.con.execute(""" create type S1 extending T; insert S1; """) await self.assert_query_result( """SELECT countall()""", [1], ) await self.con.execute(""" create type S2 extending T; insert S2; insert S2; """) await self.assert_query_result( """SELECT countall()""", [3], ) await self.con.execute(""" drop type S2; """) await self.assert_query_result( """SELECT countall()""", [1], )
) await self.assert_query_result( """SELECT countall()""", [0], ) await self.con.execute(
test_edgeql_ddl_function_inh_01
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_function_rename_01(self): await self.con.execute(""" CREATE FUNCTION foo(s: str) -> str { USING (SELECT s) } """) await self.assert_query_result( """SELECT foo("a")""", ["a"], ) await self.con.execute(""" ALTER FUNCTION foo(s: str) RENAME TO bar; """) await self.assert_query_result( """SELECT bar("a")""", ["a"], ) await self.con.execute(""" DROP FUNCTION bar(s: str) """)
) await self.assert_query_result( """SELECT foo("a")""", ["a"], ) await self.con.execute(
test_edgeql_ddl_function_rename_01
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_function_rename_02(self): await self.con.execute(""" CREATE FUNCTION foo(s: str) -> str { USING (SELECT s) }; CREATE FUNCTION bar(s: int64) -> str { USING (SELECT <str>s) }; """) with self.assertRaisesRegex( edgedb.SchemaError, r"can not rename function to 'default::foo' because " r"a function with the same name already exists"): await self.con.execute(""" ALTER FUNCTION bar(s: int64) RENAME TO foo; """)
) with self.assertRaisesRegex( edgedb.SchemaError, r"can not rename function to 'default::foo' because " r"a function with the same name already exists"): await self.con.execute(
test_edgeql_ddl_function_rename_02
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_function_rename_03(self): await self.con.execute(""" CREATE FUNCTION foo(s: str) -> str { USING (SELECT s) }; CREATE FUNCTION foo(s: int64) -> str { USING (SELECT <str>s) }; """) with self.assertRaisesRegex( edgedb.SchemaError, r"renaming an overloaded function is not allowed"): await self.con.execute(""" ALTER FUNCTION foo(s: int64) RENAME TO bar; """)
) with self.assertRaisesRegex( edgedb.SchemaError, r"renaming an overloaded function is not allowed"): await self.con.execute(
test_edgeql_ddl_function_rename_03
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_function_volatility_07(self): await self.con.execute(''' CREATE FUNCTION foo() -> float64 { USING (1); }; CREATE FUNCTION bar() -> float64 { USING (foo()); }; CREATE FUNCTION baz() -> float64 { USING (bar()); }; ''') # Test that the alter propagates multiple times await self.con.execute(''' ALTER FUNCTION foo() SET volatility := "stable"; ''') await self.assert_query_result( r''' SELECT schema::Function {name, volatility} FILTER .name LIKE 'default::%' ORDER BY .name; ''', [ {"name": "default::bar", "volatility": "Stable"}, {"name": "default::baz", "volatility": "Stable"}, {"name": "default::foo", "volatility": "Stable"}, ] )
) # Test that the alter propagates multiple times await self.con.execute(
test_edgeql_ddl_function_volatility_07
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_function_volatility_08(self): await self.con.execute(''' CREATE FUNCTION foo() -> float64 { USING (1); }; CREATE FUNCTION bar() -> float64 { SET volatility := "stable"; USING (foo()); }; ''') async with self.assertRaisesRegexTx( edgedb.SchemaDefinitionError, r"cannot alter function 'default::foo\(\)' because this affects " r".*function 'default::bar\(\)'", ): await self.con.execute(''' ALTER FUNCTION foo() SET volatility := "volatile"; ''')
) async with self.assertRaisesRegexTx( edgedb.SchemaDefinitionError, r"cannot alter function 'default::foo\(\)' because this affects " r".*function 'default::bar\(\)'", ): await self.con.execute(
test_edgeql_ddl_function_volatility_08
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_function_recompile_01(self): # Test that we recompile functions as things change await self.con.execute(''' create alias X0 := '1'; create alias X := X0; create global Y -> str { set default := '2' }; create type Z { create property p := '3' }; insert Z; create function W() -> str using ('4'); create function V0() -> str { set is_inlined := true; using ('5') }; create function V() -> str using (V0()); create function inner() -> set of str using ( X ++ (global Y) ++ Z.p ++ W() ++ V() ); create function test() -> set of str using (inner()); ''') await self.assert_query_result( 'select test()', ['12345'] ) await self.con.execute(''' alter alias X0 using ('A'); ''') await self.assert_query_result( 'select test()', ['A2345'] ) await self.con.execute(''' alter global Y { set default := 'B' }; ''') await self.assert_query_result( 'select test()', ['AB345'] ) await self.con.execute(''' alter type Z alter property p using ('C'); ''') await self.assert_query_result( 'select test()', ['ABC45'] ) await self.con.execute(''' alter function W() { using ('D') }; ''') await self.assert_query_result( 'select test()', ['ABCD5'] ) await self.con.execute(''' alter function V0() { using ('E') }; ''') await self.assert_query_result( 'select test()', ['ABCDE'] ) # Check changing inner function to inlined await self.con.execute(''' alter function inner() { set is_inlined := true; using (X ++ (global Y) ++ Z.p ++ W() ++ V() ++ '!'); }; ''') await self.assert_query_result( 'select test()', ['ABCDE!'] )
) await self.assert_query_result( 'select test()', ['12345'] ) await self.con.execute(
test_edgeql_ddl_function_recompile_01
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_function_recompile_03(self): # Check that modifying functions are recompiled await self.con.execute(''' create type Bar { create property a -> int64 }; create function inner(x: int64) -> Bar using (( insert Bar { a := x } )); create function test(x: int64) -> Bar using (inner(x)); ''') await self.assert_query_result( 'select test(1).a', [1], ) await self.assert_query_result( 'select Bar.a', [1], ) await self.con.execute(''' alter function test(x: int64) { using ((insert Bar { a := x + 10 })); }; ''') await self.assert_query_result( 'select test(2).a', [12], ) await self.assert_query_result( 'select Bar.a', [1, 12], sort=True, )
) await self.assert_query_result( 'select test(1).a', [1], ) await self.assert_query_result( 'select Bar.a', [1], ) await self.con.execute(
test_edgeql_ddl_function_recompile_03
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_module_04(self): async with self.assertRaisesRegexTx( edgedb.UnknownModuleError, "module 'foo' is not in this schema"): await self.con.execute('''\ CREATE MODULE foo::bar; ''') await self.con.execute('''\ CREATE MODULE foo; CREATE MODULE foo::bar; CREATE TYPE foo::Foo; CREATE TYPE foo::bar::Baz; ''') await self.assert_query_result( r''' select foo::bar::Baz ''', [] ) await self.assert_query_result( r''' with module foo::bar select Baz ''', [] ) await self.con.execute('''\ SET MODULE foo::bar; ''') await self.assert_query_result( r''' select foo::bar::Baz ''', [] ) await self.assert_query_result( r''' select Baz ''', [] ) await self.con.execute('''\ SET MODULE foo; ''') # We *don't* support relative references of submodules async with self.assertRaisesRegexTx( edgedb.InvalidReferenceError, "'bar::Baz' does not exist"): await self.con.execute('''\ SELECT bar::Baz ''') await self.assert_query_result( r''' select Foo ''', [] ) await self.con.execute('''\ RESET MODULE; ''') # We *don't* support relative references of submodules async with self.assertRaisesRegexTx( edgedb.InvalidReferenceError, "'bar::Baz' does not exist"): await self.con.execute('''\ WITH MODULE foo SELECT bar::Baz ''') await self.assert_query_result( r''' with m as module foo::bar select m::Baz ''', [] ) await self.assert_query_result( r''' with m as module foo select m::bar::Baz ''', [] )
) await self.con.execute('''\ CREATE MODULE foo; CREATE MODULE foo::bar; CREATE TYPE foo::Foo; CREATE TYPE foo::bar::Baz; ''') await self.assert_query_result( r
test_edgeql_ddl_module_04
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_scalar_02(self): await self.con.execute(''' CREATE ABSTRACT SCALAR TYPE a EXTENDING std::int64; CREATE ABSTRACT SCALAR TYPE b EXTENDING std::str; ''') with self.assertRaisesRegex( edgedb.SchemaError, r'may not have more than one concrete base type'): await self.con.execute(''' CREATE SCALAR TYPE myint EXTENDING a, b; ''')
) with self.assertRaisesRegex( edgedb.SchemaError, r'may not have more than one concrete base type'): await self.con.execute(
test_edgeql_ddl_scalar_02
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_scalar_03(self): await self.con.execute(''' CREATE ABSTRACT SCALAR TYPE a EXTENDING std::int64; CREATE ABSTRACT SCALAR TYPE b EXTENDING std::str; CREATE SCALAR TYPE myint EXTENDING a; ''') with self.assertRaisesRegex( edgedb.SchemaError, r'scalar type may not have more than one concrete base type'): await self.con.execute(''' ALTER SCALAR TYPE myint EXTENDING b; ''')
) with self.assertRaisesRegex( edgedb.SchemaError, r'scalar type may not have more than one concrete base type'): await self.con.execute(
test_edgeql_ddl_scalar_03
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_scalar_07(self): await self.con.execute(''' CREATE SCALAR TYPE a EXTENDING std::str; CREATE SCALAR TYPE b EXTENDING std::str; ''') # I think we want to prohibit this kind of diamond pattern with self.assertRaisesRegex( edgedb.SchemaError, r'may not have more than one concrete base type'): await self.con.execute(''' CREATE SCALAR TYPE myint EXTENDING a, b; ''')
) # I think we want to prohibit this kind of diamond pattern with self.assertRaisesRegex( edgedb.SchemaError, r'may not have more than one concrete base type'): await self.con.execute(
test_edgeql_ddl_scalar_07
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_scalar_08(self): await self.con.execute(''' CREATE SCALAR TYPE myint EXTENDING int64; CREATE TYPE Bar { CREATE PROPERTY b1 -> tuple<myint, tuple<myint>>; CREATE PROPERTY b2 -> tuple<myint, tuple<myint>>; CREATE MULTI PROPERTY b3 -> tuple<z: myint, y: array<myint>>; }; CREATE TYPE Foo { CREATE PROPERTY a1 -> array<myint>; CREATE PROPERTY a2 -> tuple<array<myint>>; CREATE PROPERTY a3 -> array<tuple<array<myint>>>; CREATE PROPERTY a4 -> tuple<myint, str>; CREATE PROPERTY a5 -> tuple<myint, myint>; CREATE PROPERTY a6 -> tuple<myint, tuple<myint>>; CREATE PROPERTY a6b -> tuple<myint, tuple<myint>>; CREATE LINK l -> Bar { CREATE PROPERTY l1 -> tuple<str, myint>; CREATE PROPERTY l2 -> tuple<myint, tuple<myint>>; }; }; ''') count_query = "SELECT count(schema::CollectionType);" orig_count = await self.con.query_single(count_query) await self.con.execute(''' ALTER SCALAR TYPE myint CREATE CONSTRAINT std::one_of(1, 2); ''') self.assertEqual(await self.con.query_single(count_query), orig_count) async with self.assertRaisesRegexTx( edgedb.ConstraintViolationError, 'myint must be one of'): await self.con.execute(''' INSERT Foo { a4 := (10, "oops") }; ''') await self.con.execute(''' INSERT Foo { a3 := [([2],)] }; ''') async with self.assertRaisesRegexTx( edgedb.ConstraintViolationError, 'myint must be one of:'): await self.con.execute(''' ALTER SCALAR TYPE myint DROP CONSTRAINT std::one_of(1, 2); ALTER SCALAR TYPE myint CREATE CONSTRAINT std::one_of(1); ''')
) count_query = "SELECT count(schema::CollectionType);" orig_count = await self.con.query_single(count_query) await self.con.execute(
test_edgeql_ddl_scalar_08
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_scalar_09(self): # We need to support CREATE FINAL SCALAR for enums because it # is written out into old migrations. await self.con.execute(''' CREATE FINAL SCALAR TYPE my_enum EXTENDING enum<'foo', 'bar'>; ''') with self.assertRaisesRegex( edgedb.UnsupportedFeatureError, r'FINAL is not supported'): await self.con.execute(''' CREATE FINAL SCALAR TYPE myint EXTENDING std::int64; ''')
) with self.assertRaisesRegex( edgedb.UnsupportedFeatureError, r'FINAL is not supported'): await self.con.execute(
test_edgeql_ddl_scalar_09
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_scalar_11(self): await self.con.execute(''' create scalar type Foo extending str; ''') with self.assertRaisesRegex( edgedb.SchemaError, r'scalar type must have a concrete base type'): await self.con.execute(''' alter scalar type Foo drop extending str; ''')
) with self.assertRaisesRegex( edgedb.SchemaError, r'scalar type must have a concrete base type'): await self.con.execute(
test_edgeql_ddl_scalar_11
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_scalar_12(self): await self.con.execute(''' create scalar type Foo extending str; ''') with self.assertRaisesRegex( edgedb.SchemaError, r'cannot change concrete base of scalar type ' r'default::Foo from std::str to std::int64'): await self.con.execute(''' alter scalar type Foo { drop extending str; extending int64 LAST; }; ''')
) with self.assertRaisesRegex( edgedb.SchemaError, r'cannot change concrete base of scalar type ' r'default::Foo from std::str to std::int64'): await self.con.execute(
test_edgeql_ddl_scalar_12
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_scalar_14(self): async with self.assertRaisesRegexTx( edgedb.UnsupportedFeatureError, r'unsupported range subtype' ): await self.con.execute( ''' create scalar type Age extending int16; create type User { create property age -> range<Age>; }; ''' ) async with self.assertRaisesRegexTx( edgedb.UnsupportedFeatureError, r'unsupported range subtype' ): await self.con.execute( ''' create type User { create property age -> range<schema::Object>; }; ''' ) async with self.assertRaisesRegexTx( edgedb.UnsupportedFeatureError, r'unsupported range subtype' ): await self.con.execute( ''' create type User { create property age -> multirange<int16>; }; ''' ) async with self.assertRaisesRegexTx( edgedb.UnsupportedFeatureError, r'unsupported range subtype' ): await self.con.execute( ''' create type User { create property age -> multirange<schema::Object>; }; ''' )
create scalar type Age extending int16; create type User { create property age -> range<Age>; };
test_edgeql_ddl_scalar_14
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_policies_02(self): async with self.assertRaisesRegexTx( edgedb.SchemaDefinitionError, r"when expression.* is of invalid type", ): await self.con.execute(""" create type X { create access policy test when (1) allow all using (true); }; """) async with self.assertRaisesRegexTx( edgedb.SchemaDefinitionError, r"using expression.* is of invalid type", ): await self.con.execute(""" create type X { create access policy test allow all using (1); }; """) async with self.assertRaisesRegexTx( edgedb.SchemaDefinitionError, r"using expression.* is of invalid type", ): await self.con.execute(""" create type X { create access policy test allow all using (()); }; """) async with self.assertRaisesRegexTx( edgedb.SchemaDefinitionError, r"possibly an empty set returned", ): await self.con.execute(""" create type X { create property x -> str; create access policy test allow all using (.x not like '%redacted%'); }; """) async with self.assertRaisesRegexTx( edgedb.SchemaDefinitionError, r"possibly more than one element returned", ): await self.con.execute(""" create type X { create access policy test allow all using ({true, false}); }; """) async with self.assertRaisesRegexTx( edgedb.SchemaDefinitionError, r"has a volatile using expression", ): await self.con.execute(""" create type X { create access policy test allow all using (random() < 0.5); }; """)
) async with self.assertRaisesRegexTx( edgedb.SchemaDefinitionError, r"using expression.* is of invalid type", ): await self.con.execute(
test_edgeql_ddl_policies_02
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_policies_03(self): # Ideally we will make this actually work instead of rejecting it! await self.con.execute(""" CREATE TYPE Tgt; CREATE TYPE Foo { CREATE MULTI LINK tgt -> Tgt { CREATE PROPERTY foo -> str; }; CREATE ACCESS POLICY asdf ALLOW ALL USING (all(.tgt@foo LIKE '%!')); }; """) async with self.assertRaisesRegexTx( edgedb.UnsupportedFeatureError, r"may not refer to link properties with default values" ): await self.con.execute(""" ALTER TYPE Foo ALTER LINK tgt ALTER property foo SET default := "!!!"; """)
) async with self.assertRaisesRegexTx( edgedb.UnsupportedFeatureError, r"may not refer to link properties with default values" ): await self.con.execute(
test_edgeql_ddl_policies_03
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_func_policies_10(self): # Make sure we succesfully update multiple functions to thread # through globals when an access policy is created. await self.con.execute(r""" create type X; insert X; create function get_xi() -> set of uuid using (X.id); create function get_x() -> set of uuid using (get_xi()); create required global en -> bool { set default := false }; alter type X { create access policy test allow select using (global en) }; """) await self.assert_query_result( 'select get_x()', [], ) await self.con.execute(''' set global en := true; ''') await self.assert_query_result( 'select get_x()', [str], )
) await self.assert_query_result( 'select get_x()', [], ) await self.con.execute(
test_edgeql_ddl_func_policies_10
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_global_01(self): INTRO_Q = ''' select schema::Global { required, typ := .target.name, default } filter .name = 'default::foo'; ''' await self.con.execute(r""" create global foo -> str; """) await self.assert_query_result( INTRO_Q, [{ "required": False, "typ": "std::str", "default": None, }] ) async with self.assertRaisesRegexTx( edgedb.SchemaDefinitionError, r"required globals must have a default", ): await self.con.execute(""" alter global foo set required; """) await self.con.execute(r""" drop global foo; create required global foo -> str { set default := "" }; """) await self.assert_query_result( INTRO_Q, [{ "required": True, "typ": "std::str", "default": "''", }] ) async with self.assertRaisesRegexTx( edgedb.SchemaDefinitionError, r"default expression is of invalid type", ): await self.con.execute(""" alter global foo set type array<uuid> reset to default; """) async with self.assertRaisesRegexTx( edgedb.SchemaDefinitionError, r"required globals must have a default", ): await self.con.execute(""" alter global foo reset default; """) await self.con.execute(""" alter global foo set optional; alter global foo reset default; alter global foo set type array<int64> reset to default; """) await self.assert_query_result( INTRO_Q, [{ "required": False, "typ": "array<std::int64>", "default": None, }] )
await self.con.execute(r
test_edgeql_ddl_global_01
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_global_02(self): async with self.assertRaisesRegexTx( edgedb.SchemaDefinitionError, "non-computed globals may not be multi", ): await self.con.execute(""" create multi global foo -> str; """) async with self.assertRaisesRegexTx( edgedb.SchemaDefinitionError, r"possibly more than one element returned", ): await self.con.execute(""" create global foo -> str { set default := {"foo", "bar"} }; """) async with self.assertRaisesRegexTx( edgedb.SchemaDefinitionError, r"possibly no elements returned", ): await self.con.execute(""" create required global foo -> str { set default := (select "foo" filter false) }; """) async with self.assertRaisesRegexTx( edgedb.SchemaDefinitionError, r"non-computed globals may not have have object type", ): await self.con.execute(""" create global foo -> Object; """) async with self.assertRaisesRegexTx( edgedb.SchemaDefinitionError, r"non-computed globals may not have have object type", ): await self.con.execute(""" create global foo -> array<Object>; """) async with self.assertRaisesRegexTx( edgedb.SchemaDefinitionError, r"has a volatile default expression, which is not allowed", ): await self.con.execute(""" create global foo -> float64 { set default := random(); }; """) async with self.assertRaisesRegexTx( edgedb.SchemaDefinitionError, "computed globals may not have default values", ): await self.con.execute(""" create global test { using ('abc'); set default := 'def'; } """)
) async with self.assertRaisesRegexTx( edgedb.SchemaDefinitionError, r"possibly more than one element returned", ): await self.con.execute(
test_edgeql_ddl_global_02
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_global_03(self): await self.con.execute(""" create global foo -> str; """) async with self.assertRaisesRegexTx( edgedb.SchemaDefinitionError, r"global variables cannot be referenced from constraint" ): await self.con.execute(""" create type X { create property foo -> str { create constraint expression on ( __subject__ != global foo) } } """) async with self.assertRaisesRegexTx( edgedb.SchemaDefinitionError, r"global variables cannot be referenced from index" ): await self.con.execute(""" create type X { create index on (global foo); } """) await self.con.execute(""" create type X; """) await self.con.execute(""" set global foo := "test" """) await self.con.execute(""" create type Y { create property foo -> str { set default := (global foo); } }; """) await self.con.query(""" insert Y; """) await self.assert_query_result( r''' select Y.foo ''', ['test'] ) # And when adding a default to an existing column await self.con.execute(""" alter type X { create property foo -> str; }; alter type X { alter property foo { set default := (global foo); } }; """) await self.con.query(""" insert X; """) await self.assert_query_result( r''' select X.foo ''', ['test'] )
) async with self.assertRaisesRegexTx( edgedb.SchemaDefinitionError, r"global variables cannot be referenced from constraint" ): await self.con.execute(
test_edgeql_ddl_global_03
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_global_04(self): # mostly the same as _03 but with functions await self.con.execute(""" create global foo -> str; create function gfoo() -> optional str using (global foo) """) async with self.assertRaisesRegexTx( edgedb.SchemaDefinitionError, r"functions that reference global variables cannot be called " r"from constraint" ): await self.con.execute(""" create type X { create property foo -> str { create constraint expression on ( __subject__ != gfoo()) } } """) async with self.assertRaisesRegexTx( edgedb.SchemaDefinitionError, r"functions that reference global variables cannot be called " r"from index" ): await self.con.execute(""" create type X { create index on (gfoo()); } """)
) async with self.assertRaisesRegexTx( edgedb.SchemaDefinitionError, r"functions that reference global variables cannot be called " r"from constraint" ): await self.con.execute(
test_edgeql_ddl_global_04
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_global_06(self): INTRO_Q = ''' select schema::Global { required, cardinality, typ := .target.name, req_comp := contains(.computed_fields, 'required'), card_comp := contains(.computed_fields, 'cardinality'), computed := exists .expr, } filter .name = 'default::foo'; ''' await self.con.execute(''' create global foo := 10; ''') await self.assert_query_result( INTRO_Q, [{ "computed": True, "card_comp": True, "req_comp": True, "required": True, "cardinality": "One", "typ": "default::foo", }] ) await self.con.execute(''' drop global foo; create optional multi global foo := 10; ''') await self.assert_query_result( INTRO_Q, [{ "computed": True, "card_comp": False, "req_comp": False, "required": False, "cardinality": "Many", "typ": "default::foo", }] ) await self.con.execute(''' alter global foo reset optionality; ''') await self.assert_query_result( INTRO_Q, [{ "computed": True, "card_comp": False, "req_comp": True, "required": True, "cardinality": "Many", "typ": "default::foo", }] ) await self.con.execute(''' alter global foo { reset cardinality; reset expression; set type str reset to default; }; ''') await self.assert_query_result( INTRO_Q, [{ "computed": False, "card_comp": False, "req_comp": False, "required": False, "cardinality": "One", "typ": "std::str", }] )
await self.con.execute(
test_edgeql_ddl_global_06
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_global_07(self): await self.con.execute(''' create global foo := <str>Object.id ''') async with self.assertRaisesRegexTx( edgedb.SchemaDefinitionError, r"possibly an empty set returned", ): await self.con.execute(""" alter global foo set required; """) async with self.assertRaisesRegexTx( edgedb.SchemaDefinitionError, r"possibly more than one element returned", ): await self.con.execute(""" alter global foo set single; """) async with self.assertRaisesRegexTx( edgedb.UnsupportedFeatureError, r"cannot specify a type and an expression for a global", ): await self.con.execute(""" alter global foo set type str reset to default; """)
) async with self.assertRaisesRegexTx( edgedb.SchemaDefinitionError, r"possibly an empty set returned", ): await self.con.execute(
test_edgeql_ddl_global_07
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_global_09(self): await self.con.execute(''' create type Org; create global current_org_id -> uuid; create global current_org := ( select Org filter .id = global current_org_id ); create type Widget { create required link org -> Org { set default := global current_org; } }; ''') obj = await self.con.query_single('insert Org') await self.con.execute( ''' set global current_org_id := <uuid>$0 ''', obj.id, ) await self.con.execute('insert Widget') await self.assert_query_result( ''' select Widget { org } ''', [{'org': {'id': obj.id}}], )
) obj = await self.con.query_single('insert Org') await self.con.execute(
test_edgeql_ddl_global_09
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_global_default(self): await self.con.execute(''' create global foo -> str; create type Foo; ''') # Should work; no data in the table to cause trouble await self.con.execute(''' alter type Foo { create required property name -> str { set default := (global foo); } } ''') await self.con.execute(''' set global foo := "test"; insert Foo; reset global foo; ''') await self.assert_query_result( ''' select Foo { name } ''', [{'name': "test"}], ) # Should fail because there is data async with self.assertRaisesRegexTx( edgedb.MissingRequiredError, r"missing value for required property" ): await self.con.execute(''' alter type Foo { create required property name2 -> str { set default := (global foo); } } ''') await self.con.execute(''' alter global foo set default := "!"; create function get_foo() -> optional str using (global foo); ''') # Try it again now that there is a default await self.con.execute(''' alter type Foo { create required property name2 -> str { set default := (global foo); } }; alter type Foo { create required property name3 -> str { set default := (get_foo()); } }; ''') await self.assert_query_result( ''' select Foo { name, name2, name3 } ''', [{'name': "test", 'name2': "!", 'name3': "!"}], )
) # Should work; no data in the table to cause trouble await self.con.execute(
test_edgeql_ddl_global_default
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_link_computable_02(self): await self.con.execute(''' CREATE TYPE LinkTarget; ''') # TODO We want to actually support this, but until then we should # have a decent error. async with self.assertRaisesRegexTx( edgedb.UnsupportedFeatureError, r"including a shape on schema-defined computed links " r"is not yet supported" ): await self.con.execute(""" CREATE TYPE X { CREATE LINK x := LinkTarget { z := 1 } }; """)
) # TODO We want to actually support this, but until then we should # have a decent error. async with self.assertRaisesRegexTx( edgedb.UnsupportedFeatureError, r"including a shape on schema-defined computed links " r"is not yet supported" ): await self.con.execute(
test_edgeql_ddl_link_computable_02
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_annotation_13(self): await self.con.execute(""" CREATE ABSTRACT ANNOTATION anno13; """) with self.assertRaisesRegex( edgedb.UnknownModuleError, "module 'bogus' is not in this schema", ): await self.con.execute(""" ALTER ABSTRACT ANNOTATION anno13 RENAME TO bogus::anno13; """)
) with self.assertRaisesRegex( edgedb.UnknownModuleError, "module 'bogus' is not in this schema", ): await self.con.execute(
test_edgeql_ddl_annotation_13
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_annotation_15(self): await self.con.execute(""" CREATE ABSTRACT INHERITABLE ANNOTATION anno; CREATE TYPE Foo { CREATE PROPERTY prop -> str { CREATE ANNOTATION anno := "parent"; }; }; CREATE TYPE Bar EXTENDING Foo { ALTER PROPERTY prop { ALTER ANNOTATION anno := "child"; } }; """) qry = ''' WITH MODULE schema SELECT Property { obj := .source.name, annotations: {name, @value, @owned} ORDER BY .name } FILTER .name = 'prop' ORDER BY (.obj, .name); ''' await self.assert_query_result( qry, [ { "annotations": [ {"@value": "child", "@owned": True, "name": "default::anno"} ], "obj": "default::Bar" }, { "annotations": [ {"@value": "parent", "@owned": True, "name": "default::anno"} ], "obj": "default::Foo" } ] ) await self.con.execute(""" ALTER TYPE Bar { ALTER PROPERTY prop { ALTER ANNOTATION anno DROP OWNED; } }; """) await self.assert_query_result( qry, [ { "annotations": [ {"@value": "parent", "@owned": False, "name": "default::anno"} ], "obj": "default::Bar" }, { "annotations": [ {"@value": "parent", "@owned": True, "name": "default::anno"} ], "obj": "default::Foo" } ] )
) qry =
test_edgeql_ddl_annotation_15
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_annotation_16(self): await self.con.execute(""" CREATE ABSTRACT ANNOTATION attr1; """) with self.assertRaisesRegex( edgedb.InvalidValueError, r"annotation values must be 'std::str', " r"got scalar type 'std::int64'"): await self.con.execute(""" CREATE SCALAR TYPE TestAttrType1 EXTENDING std::str { CREATE ANNOTATION attr1 := 10; }; """)
) with self.assertRaisesRegex( edgedb.InvalidValueError, r"annotation values must be 'std::str', " r"got scalar type 'std::int64'"): await self.con.execute(
test_edgeql_ddl_annotation_16
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_extending_06(self): async with self.assertRaisesRegexTx( edgedb.SchemaError, r"'std::FreeObject' cannot be a parent type", ): await self.con.execute(""" CREATE TYPE SomeObject6 EXTENDING FreeObject; """) async with self.assertRaisesRegexTx( edgedb.SchemaError, r"'std::FreeObject' cannot be a parent type", ): await self.con.execute(""" CREATE TYPE SomeObject6; ALTER TYPE SomeObject6 EXTENDING FreeObject; """)
) async with self.assertRaisesRegexTx( edgedb.SchemaError, r"'std::FreeObject' cannot be a parent type", ): await self.con.execute(
test_edgeql_ddl_extending_06
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_extending_07(self): await self.con.execute(r""" create type A; create type B extending A; """) with self.assertRaisesRegex( edgedb.SchemaError, r"could not find consistent ancestor order"): await self.con.execute(r""" create type C extending A, B; """)
) with self.assertRaisesRegex( edgedb.SchemaError, r"could not find consistent ancestor order"): await self.con.execute(r
test_edgeql_ddl_extending_07
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_modules_03(self): await self.con.execute(r""" CREATE MODULE test_other; CREATE ABSTRACT TYPE test_other::Named { CREATE REQUIRED PROPERTY name -> str; }; CREATE ABSTRACT TYPE test_other::UniquelyNamed EXTENDING test_other::Named { ALTER PROPERTY name { CREATE DELEGATED CONSTRAINT exclusive; } }; """) try: async with self.con.transaction(): await self.con.execute(r""" START MIGRATION TO { type Status extending test_other::UniquelyNamed; }; POPULATE MIGRATION; COMMIT MIGRATION; """) await self.con.execute(""" DROP TYPE Status; """) finally: await self.con.execute(""" DROP TYPE test_other::UniquelyNamed; DROP TYPE test_other::Named; DROP MODULE test_other; """)
) try: async with self.con.transaction(): await self.con.execute(r
test_edgeql_ddl_modules_03
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_modules_04(self): await self.con.execute(r""" CREATE MODULE test_other; CREATE ABSTRACT TYPE test_other::Named { CREATE REQUIRED PROPERTY name -> str; }; CREATE ABSTRACT TYPE test_other::UniquelyNamed EXTENDING test_other::Named { ALTER PROPERTY name { CREATE DELEGATED CONSTRAINT exclusive; } }; CREATE ABSTRACT ANNOTATION whatever; CREATE TYPE test_other::Foo; CREATE TYPE test_other::Bar { CREATE LINK foo -> test_other::Foo; CREATE ANNOTATION whatever := "huh"; }; ALTER TYPE test_other::Foo { CREATE LINK bar -> test_other::Bar; }; """) async with self.assertRaisesRegexTx( edgedb.SchemaError, "cannot drop module 'test_other' because it is not empty", ): await self.con.execute(r""" DROP MODULE test_other; """)
) async with self.assertRaisesRegexTx( edgedb.SchemaError, "cannot drop module 'test_other' because it is not empty", ): await self.con.execute(r
test_edgeql_ddl_modules_04
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_modules_05(self): await self.con.execute(r""" CREATE MODULE foo; """) async with self.assertRaisesRegexTx( edgedb.SchemaError, "renaming modules is not supported", ): await self.con.execute(r""" ALTER MODULE foo RENAME TO bar; """)
) async with self.assertRaisesRegexTx( edgedb.SchemaError, "renaming modules is not supported", ): await self.con.execute(r
test_edgeql_ddl_modules_05
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_role_05(self): if self.has_create_role: self.skipTest("create role is supported by the backend") con = await self.connect() try: await con.execute(""" ALTER ROLE edgedb SET password := 'test_role_05' """) if self.has_create_database: await con.execute("""CREATE DATABASE test_role_05""") finally: await con.aclose() args = {'password': "test_role_05"} if self.has_create_database: args['database'] = "test_role_05" con = await self.connect(**args) try: await con.execute(""" ALTER ROLE edgedb SET password := 'test' """) finally: await con.aclose() con = await self.connect() try: if self.has_create_database: await tb.drop_db(con, 'test_role_05') finally: await con.aclose()
) if self.has_create_database: await con.execute("""CREATE DATABASE test_role_05""") finally: await con.aclose() args = {'password': "test_role_05"} if self.has_create_database: args['database'] = "test_role_05" con = await self.connect(**args) try: await con.execute(
test_edgeql_ddl_role_05
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_describe_schema(self): # This is ensuring that describing std does not cause errors. # The test validates only a small sample of entries, though. result = await self.con.query_single(""" DESCRIBE MODULE std """) # This is essentially a syntax test from this point on. re_filter = re.compile(r'[\s]+|(#.*?(\n|$))|(,(?=\s*[})]))') result_stripped = re_filter.sub('', result).lower() for expected in [ ''' CREATE SCALAR TYPE std::float32 EXTENDING std::anyfloat; ''', ''' CREATE FUNCTION std::str_lower(s: std::str) -> std::str { SET volatility := 'Immutable'; CREATE ANNOTATION std::description := 'Return a lowercase copy of the input *string*.'; USING SQL FUNCTION 'lower'; }; ''', ''' CREATE INFIX OPERATOR std::`AND`(a: std::bool, b: std::bool) -> std::bool { SET volatility := 'Immutable'; CREATE ANNOTATION std::description := 'Logical conjunction.'; USING SQL EXPRESSION; }; ''', ''' CREATE ABSTRACT INFIX OPERATOR std::`>=`(l: anytype, r: anytype) -> std::bool; ''', ''' CREATE CAST FROM std::str TO std::bool { SET volatility := 'Immutable'; USING SQL FUNCTION 'edgedb.str_to_bool'; }; ''', ''' CREATE CAST FROM std::int64 TO std::int16 { SET volatility := 'Immutable'; USING SQL CAST; ALLOW ASSIGNMENT; }; ''']: expected_stripped = re_filter.sub('', expected).lower() self.assertTrue( expected_stripped in result_stripped, f'`DESCRIBE MODULE std` is missing the following: "{expected}"' )
) # This is essentially a syntax test from this point on. re_filter = re.compile(r'[\s]+|(#.*?(\n|$))|(,(?=\s*[})]))') result_stripped = re_filter.sub('', result).lower() for expected in [
test_edgeql_ddl_describe_schema
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_alias_09(self): await self.con.execute(r""" CREATE ALIAS CreateAlias09 := ( SELECT BaseObject { alias_computable := 'rename alias 03' } ); """) async with self.assertRaisesRegexTx( edgedb.InvalidLinkTargetError, "invalid link type: 'default::CreateAlias09' is an" " expression alias, not a proper object type", ): await self.con.execute(r""" CREATE TYPE AliasType09 { CREATE OPTIONAL SINGLE LINK a -> CreateAlias09; } """)
) async with self.assertRaisesRegexTx( edgedb.InvalidLinkTargetError, "invalid link type: 'default::CreateAlias09' is an" " expression alias, not a proper object type", ): await self.con.execute(r
test_edgeql_ddl_alias_09
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_alias_12(self): await self.con.execute( r""" create alias X := 1; create type Y; create global Z -> int64; """ ) async with self.assertRaisesRegexTx( edgedb.SchemaError, "scalar type 'default::X' already exists" ): # this should ideally say "alias X", but this is better than ISE await self.con.execute( r""" create alias X := 2; """ ) async with self.assertRaisesRegexTx( edgedb.SchemaError, "type 'default::Y' already exists" ): await self.con.execute( r""" create alias Y := 2; """ ) async with self.assertRaisesRegexTx( edgedb.SchemaError, "global 'default::Z' already exists" ): await self.con.execute( r""" create alias Z := 2; """ )
) async with self.assertRaisesRegexTx( edgedb.SchemaError, "scalar type 'default::X' already exists" ): # this should ideally say "alias X", but this is better than ISE await self.con.execute( r
test_edgeql_ddl_alias_12
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_alias_13(self): ''' Creating an alias of an array of valid scalars should be possible. (Related to #6456.) ''' await self.con.execute(r""" create alias ArrAlias := [range(0, 1)]; """) await self.assert_query_result( r''' select ArrAlias = [range(0, 1)]; ''', [True] )
Creating an alias of an array of valid scalars should be possible. (Related to #6456.)
test_edgeql_ddl_alias_13
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_alias_14(self): # Issue #8003 await self.con.execute(r""" create global One := 1; create alias MyAlias := global One; """) async with self.assertRaisesRegexTx( edgedb.SchemaDefinitionError, "index expressions must be immutable" ): await self.con.execute( r""" create type Foo { create index on (MyAlias) }; """ )
) async with self.assertRaisesRegexTx( edgedb.SchemaDefinitionError, "index expressions must be immutable" ): await self.con.execute( r
test_edgeql_ddl_alias_14
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_alias_15(self): # Issue #8003 await self.con.execute( r""" create global One := 1; create alias MyAlias := 1; create type Foo { create index on (MyAlias) }; """ ) async with self.assertRaisesRegexTx( edgedb.SchemaDefinitionError, "cannot alter alias 'default::MyAlias' because this affects " "expression of index of object type 'default::Foo'" ): await self.con.execute( r""" alter alias MyAlias {using (global One)}; """ )
) async with self.assertRaisesRegexTx( edgedb.SchemaDefinitionError, "cannot alter alias 'default::MyAlias' because this affects " "expression of index of object type 'default::Foo'" ): await self.con.execute( r
test_edgeql_ddl_alias_15
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_inheritance_alter_02(self): await self.con.execute(r""" CREATE TYPE InhTest01 { CREATE PROPERTY testp -> int64; }; CREATE TYPE InhTest01_child EXTENDING InhTest01; """) with self.assertRaisesRegex( edgedb.SchemaError, "cannot drop inherited property 'testp'"): await self.con.execute(""" ALTER TYPE InhTest01_child { DROP PROPERTY testp; } """)
) with self.assertRaisesRegex( edgedb.SchemaError, "cannot drop inherited property 'testp'"): await self.con.execute(
test_edgeql_ddl_inheritance_alter_02
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_constraint_08(self): # Test non-delegated object constraints on abstract types await self.con.execute(r""" CREATE TYPE Base { CREATE PROPERTY x -> str { CREATE CONSTRAINT exclusive; } }; CREATE TYPE Foo EXTENDING Base; CREATE TYPE Bar EXTENDING Base; INSERT Foo { x := "a" }; """) with self.assertRaisesRegex( edgedb.ConstraintViolationError, r'violates exclusivity constraint'): await self.con.execute(r""" INSERT Foo { x := "a" }; """)
) with self.assertRaisesRegex( edgedb.ConstraintViolationError, r'violates exclusivity constraint'): await self.con.execute(r
test_edgeql_ddl_constraint_08
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_constraint_18(self): await self.con.execute(r""" create type Foo { create property flag -> bool; create property except -> bool; create constraint expression on (.flag) except (.except); }; """) # Check all combinations of expression outcome and except value for flag in [True, False, None]: for ex in [True, False, None]: op = self.con.query( """ INSERT Foo { flag := <optional bool>$flag, except := <optional bool>$ex, } """, flag=flag, ex=ex, ) # The constraint fails if it is specifically false # (not empty) and except is not true. fail = flag is False and ex is not True if fail: async with self.assertRaisesRegexTx( edgedb.ConstraintViolationError, r'invalid Foo'): await op else: await op
) # Check all combinations of expression outcome and except value for flag in [True, False, None]: for ex in [True, False, None]: op = self.con.query(
test_edgeql_ddl_constraint_18
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_constraint_19(self): # Make sure we distinguish between on and except in name creation; await self.con.execute(r""" create abstract constraint always_fail extending constraint { using (false) }; create type Foo; create type OnTest { create link l -> Foo { create property flag -> bool; create constraint always_fail on (@flag); }; }; create type ExceptTest { create link l -> Foo { create property flag -> bool; create constraint always_fail except (@flag); }; }; """) async with self.assertRaisesRegexTx( edgedb.ConstraintViolationError, r'invalid l'): await self.con.execute(""" insert OnTest { l := (insert Foo) { @flag := false } } """) async with self.assertRaisesRegexTx( edgedb.ConstraintViolationError, r'invalid l'): await self.con.execute(""" insert OnTest { l := (insert Foo) { @flag := true } } """) async with self.assertRaisesRegexTx( edgedb.ConstraintViolationError, r'invalid l'): await self.con.execute(""" insert ExceptTest { l := (insert Foo) { @flag := false } } """) await self.con.execute(""" insert ExceptTest { l := (insert Foo) { @flag := true } } """)
) async with self.assertRaisesRegexTx( edgedb.ConstraintViolationError, r'invalid l'): await self.con.execute(
test_edgeql_ddl_constraint_19
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_constraint_21(self): # We plan on rejecting this, but for now do the thing closest # to right. await self.con.execute(r""" create type A { create property x -> str; create constraint exclusive on (A.x); }; create type B extending A; insert A { x := "!" }; """) async with self.assertRaisesRegexTx( edgedb.ConstraintViolationError, r'violates exclusivity constraint'): await self.con.execute(""" insert B { x := "!" } """)
) async with self.assertRaisesRegexTx( edgedb.ConstraintViolationError, r'violates exclusivity constraint'): await self.con.execute(
test_edgeql_ddl_constraint_21
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_constraint_25(self): await self.con.execute(""" create scalar type Status extending enum<open, closed>; create type Order { create required property status -> Status; } """) # enum casts in constraints await self.con.execute(""" alter type Order { create constraint exclusive on ((Status.open = .status)); }; """) await self.con.execute(""" alter type Order { create constraint exclusive on ((<Status>'open' = .status)); }; """) await self.con.execute(""" alter type Order { create constraint exclusive on (('open' = <str>.status)); }; """) # enum casts in indexes await self.con.execute(""" alter type Order { create index on ((Status.open = .status)); }; """) await self.con.execute(""" alter type Order { create index on ((<Status>'open' = .status)); }; """) await self.con.execute(""" alter type Order { create index on (('open' = <str>.status)); }; """)
) # enum casts in constraints await self.con.execute(
test_edgeql_ddl_constraint_25
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_constraint_32(self): async with self.assertRaisesRegexTx( edgedb.UnsupportedFeatureError, '' ): await self.con.execute(r""" create type S { create constraint expression on (((0, 0)).0 = 0); }; """) async with self.assertRaisesRegexTx( edgedb.UnsupportedFeatureError, '' ): await self.con.execute(r""" create type S { create constraint expression on (((true, 0)).0); }; """)
) async with self.assertRaisesRegexTx( edgedb.UnsupportedFeatureError, '' ): await self.con.execute(r
test_edgeql_ddl_constraint_32
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_constraint_check_01a(self): await self.con.execute(r""" create type Foo { create property foo -> str; }; create type Bar extending Foo; insert Foo { foo := "x" }; insert Bar { foo := "x" }; """) async with self.assertRaisesRegexTx( edgedb.ConstraintViolationError, r'foo violates exclusivity constraint'): await self.con.execute(""" alter type Foo alter property foo { create constraint exclusive }; """)
) async with self.assertRaisesRegexTx( edgedb.ConstraintViolationError, r'foo violates exclusivity constraint'): await self.con.execute(
test_edgeql_ddl_constraint_check_01a
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_constraint_check_06(self): await self.con.execute(r""" create type Tgt; create type Foo { create link foo -> Tgt { create property x -> str; } }; create type Bar extending Foo; insert Tgt; insert Foo { foo := assert_single(Tgt { @x := "foo" }) }; insert Bar { foo := assert_single(Tgt { @x := "foo" }) }; """) async with self.assertRaisesRegexTx( edgedb.ConstraintViolationError, r'x violates exclusivity constraint'): await self.con.execute(""" alter type Foo alter link foo alter property x { create constraint exclusive }; """)
) async with self.assertRaisesRegexTx( edgedb.ConstraintViolationError, r'x violates exclusivity constraint'): await self.con.execute(
test_edgeql_ddl_constraint_check_06
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_constraint_check_09(self): # Test a diamond pattern with a delegated constraint await self.con.execute(r""" CREATE ABSTRACT TYPE R { CREATE REQUIRED PROPERTY name -> std::str { CREATE DELEGATED CONSTRAINT std::exclusive; }; }; CREATE TYPE S EXTENDING R; CREATE TYPE T EXTENDING R; CREATE TYPE V EXTENDING S, T; INSERT S { name := "S" }; INSERT T { name := "T" }; INSERT V { name := "V" }; """) for t1, t2 in ["SV", "TV", "VT", "VS"]: with self.annotate(tables=(t1, t2)): async with self.assertRaisesRegexTx( edgedb.ConstraintViolationError, r'violates exclusivity constraint'): await self.con.execute(f""" insert {t1} {{ name := "{t2}" }} """) async with self.assertRaisesRegexTx( edgedb.ConstraintViolationError, r'violates exclusivity constraint'): await self.con.execute(f""" select {{ (insert {t1} {{ name := "!" }}), (insert {t2} {{ name := "!" }}), }} """) await self.con.execute(r""" ALTER TYPE default::R { DROP PROPERTY name; }; """)
) for t1, t2 in ["SV", "TV", "VT", "VS"]: with self.annotate(tables=(t1, t2)): async with self.assertRaisesRegexTx( edgedb.ConstraintViolationError, r'violates exclusivity constraint'): await self.con.execute(f
test_edgeql_ddl_constraint_check_09
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_constraint_alter_05(self): await self.con.execute(r""" CREATE TYPE Base { CREATE PROPERTY firstname -> str { CREATE CONSTRAINT max_len_value(10); } } """) with self.assertRaisesRegex( edgedb.errors.SchemaError, r"constraint 'std::max_len_value' of property 'firstname' " r"of object type 'default::Base' already exists"): await self.con.execute(r""" ALTER TYPE Base { ALTER PROPERTY firstname { CREATE CONSTRAINT max_len_value(10); } } """)
) with self.assertRaisesRegex( edgedb.errors.SchemaError, r"constraint 'std::max_len_value' of property 'firstname' " r"of object type 'default::Base' already exists"): await self.con.execute(r
test_edgeql_ddl_constraint_alter_05
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_constraint_alter_06(self): await self.con.execute(r""" create type Foo { create property foo -> str {create constraint exclusive;}; }; create type Bar extending Foo; """) async with self.assertRaisesRegexTx( edgedb.errors.ConstraintViolationError, "violates exclusivity constraint"): await self.con.execute(r""" insert Bar { foo := "x" }; insert Foo { foo := "x" }; """) async with self.assertRaisesRegexTx( edgedb.errors.ConstraintViolationError, "violates exclusivity constraint"): await self.con.execute(r""" insert Foo { foo := "x" }; insert Bar { foo := "x" }; """)
) async with self.assertRaisesRegexTx( edgedb.errors.ConstraintViolationError, "violates exclusivity constraint"): await self.con.execute(r
test_edgeql_ddl_constraint_alter_06
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_drop_refuse_02(self): await self.con.execute( ''' create type Player; create global current_player_id: uuid; create global current_player := ( select Player filter .id = global current_player_id ); create type Clan; alter type Player { create link clan: Clan; }; alter type Clan { create access policy allow_select_players allow select using ( global current_player.clan.id ?= .id ); }; ''' ) async with self.assertRaisesRegexTx( edgedb.SchemaDefinitionError, r"cannot drop .+ because this affects expression of access"): await self.con.execute('drop type Player;')
create type Player; create global current_player_id: uuid; create global current_player := ( select Player filter .id = global current_player_id ); create type Clan; alter type Player { create link clan: Clan; }; alter type Clan { create access policy allow_select_players allow select using ( global current_player.clan.id ?= .id ); };
test_edgeql_ddl_drop_refuse_02
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_tuple_properties(self): await self.con.execute(r""" CREATE TYPE TupProp01 { CREATE PROPERTY p1 -> tuple<int64, str>; CREATE PROPERTY p2 -> tuple<foo: int64, bar: str>; CREATE PROPERTY p3 -> tuple<foo: int64, bar: tuple<json, json>>; }; CREATE TYPE TupProp02 { CREATE PROPERTY p1 -> tuple<int64, str>; CREATE PROPERTY p2 -> tuple<json, json>; }; """) # Drop identical p1 properties from both objects, # to check positive refcount. await self.con.execute(r""" ALTER TYPE TupProp01 { DROP PROPERTY p1; }; """) await self.con.execute(r""" ALTER TYPE TupProp02 { DROP PROPERTY p1; }; """) # Re-create the property to check that the associated # composite type was actually removed. await self.con.execute(r""" ALTER TYPE TupProp02 { CREATE PROPERTY p1 -> tuple<int64, str>; }; """) # Now, drop the property that has a nested tuple that # is referred to directly by another property. await self.con.execute(r""" ALTER TYPE TupProp01 { DROP PROPERTY p3; }; """) # Drop the last user. await self.con.execute(r""" ALTER TYPE TupProp02 { DROP PROPERTY p2; }; """) # Re-create to assure cleanup. await self.con.execute(r""" ALTER TYPE TupProp02 { CREATE PROPERTY p3 -> tuple<json, json>; CREATE PROPERTY p4 -> tuple<a: json, b: json>; }; """) await self.con.execute(r""" ALTER TYPE TupProp02 { CREATE PROPERTY p5 -> array<tuple<int64>>; }; """) await self.con.query('DECLARE SAVEPOINT t0') with self.assertRaisesRegex( edgedb.InvalidPropertyTargetError, 'expected a scalar type, or a scalar collection'): await self.con.execute(r""" ALTER TYPE TupProp02 { CREATE PROPERTY p6 -> tuple<TupProp02>; }; """) # Recover. await self.con.query('ROLLBACK TO SAVEPOINT t0;')
) # Drop identical p1 properties from both objects, # to check positive refcount. await self.con.execute(r
test_edgeql_ddl_tuple_properties
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_prop_overload_05(self): await self.con.execute(""" CREATE TYPE UniqueName { CREATE PROPERTY val -> str; }; CREATE TYPE UniqueName_2 { CREATE PROPERTY val -> str; }; CREATE TYPE UniqueName_3 EXTENDING UniqueName, UniqueName_2; """) with self.assertRaisesRegex( edgedb.SchemaDefinitionError, "it is illegal for the property 'val' of object " "type 'default::UniqueName_3' to extend both a computed " "and a non-computed property"): await self.con.execute(""" ALTER TYPE UniqueName { ALTER PROPERTY val { USING ('bad'); }; }; """)
) with self.assertRaisesRegex( edgedb.SchemaDefinitionError, "it is illegal for the property 'val' of object " "type 'default::UniqueName_3' to extend both a computed " "and a non-computed property"): await self.con.execute(
test_edgeql_ddl_prop_overload_05
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_prop_overload_06(self): await self.con.execute(""" CREATE TYPE UniqueName { CREATE PROPERTY val -> str; }; CREATE TYPE UniqueName_2 { CREATE PROPERTY val -> str; }; CREATE TYPE UniqueName_3 { CREATE PROPERTY val := 'ok'; }; CREATE TYPE UniqueName_4 EXTENDING UniqueName, UniqueName_2; """) with self.assertRaisesRegex( edgedb.SchemaDefinitionError, "it is illegal for the property 'val' of object " "type 'default::UniqueName_4' to extend both a computed " "and a non-computed property"): await self.con.execute(""" ALTER TYPE UniqueName_4 EXTENDING UniqueName_3; """)
) with self.assertRaisesRegex( edgedb.SchemaDefinitionError, "it is illegal for the property 'val' of object " "type 'default::UniqueName_4' to extend both a computed " "and a non-computed property"): await self.con.execute(
test_edgeql_ddl_prop_overload_06
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_readonly_04(self): # Test that read-only flag must be consistent in the # inheritance hierarchy. await self.con.execute(''' CREATE TYPE Base0 { CREATE PROPERTY foo -> str; }; CREATE TYPE Base1 { CREATE PROPERTY foo -> str; }; CREATE TYPE Derived EXTENDING Base0, Base1; ''') with self.assertRaisesRegex( edgedb.SchemaDefinitionError, "cannot redefine the readonly flag of property 'foo' of " "object type 'default::Derived': it is defined as False in " "property 'foo' of object type 'default::Base0' and as " "True in property 'foo' of object type 'default::Base1'."): await self.con.execute(''' ALTER TYPE Base1 { ALTER PROPERTY foo { SET readonly := True; }; }; ''')
) with self.assertRaisesRegex( edgedb.SchemaDefinitionError, "cannot redefine the readonly flag of property 'foo' of " "object type 'default::Derived': it is defined as False in " "property 'foo' of object type 'default::Base0' and as " "True in property 'foo' of object type 'default::Base1'."): await self.con.execute(
test_edgeql_ddl_readonly_04
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_readonly_08(self): # Test that read-only flag must be consistent in the # inheritance hierarchy. await self.con.execute(''' CREATE TYPE Base0 { CREATE LINK foo -> Object; }; CREATE TYPE Base1 { CREATE LINK foo -> Object; }; CREATE TYPE Derived EXTENDING Base0, Base1; ''') with self.assertRaisesRegex( edgedb.SchemaDefinitionError, "cannot redefine the readonly flag of link 'foo' of " "object type 'default::Derived': it is defined as False in " "link 'foo' of object type 'default::Base0' and as " "True in link 'foo' of object type 'default::Base1'."): await self.con.execute(''' ALTER TYPE Base1 { ALTER LINK foo { SET readonly := True; }; }; ''')
) with self.assertRaisesRegex( edgedb.SchemaDefinitionError, "cannot redefine the readonly flag of link 'foo' of " "object type 'default::Derived': it is defined as False in " "link 'foo' of object type 'default::Base0' and as " "True in link 'foo' of object type 'default::Base1'."): await self.con.execute(
test_edgeql_ddl_readonly_08
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_readonly_12(self): # Test that read-only flag must be consistent in the # inheritance hierarchy. await self.con.execute(''' CREATE TYPE Base0 { CREATE LINK foo -> Object { CREATE PROPERTY bar -> str; }; }; CREATE TYPE Base1 { CREATE LINK foo -> Object { CREATE PROPERTY bar -> str; }; }; CREATE TYPE Derived EXTENDING Base0, Base1; ''') with self.assertRaisesRegex( edgedb.SchemaDefinitionError, "cannot redefine the readonly flag of property 'bar' of " "link 'foo' of object type 'default::Derived': it is defined " "as False in property 'bar' of link 'foo' of object type " "'default::Base0' and as True in property 'bar' of link " "'foo' of object type 'default::Base1'."): await self.con.execute(''' ALTER TYPE Base1 { ALTER LINK foo { ALTER PROPERTY bar { SET readonly := True; }; }; }; ''')
) with self.assertRaisesRegex( edgedb.SchemaDefinitionError, "cannot redefine the readonly flag of property 'bar' of " "link 'foo' of object type 'default::Derived': it is defined " "as False in property 'bar' of link 'foo' of object type " "'default::Base0' and as True in property 'bar' of link " "'foo' of object type 'default::Base1'."): await self.con.execute(
test_edgeql_ddl_readonly_12
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_required_08(self): # Test normal that required qualifier behavior. await self.con.execute(r""" CREATE TYPE Base { CREATE REQUIRED PROPERTY foo -> str; }; CREATE TYPE Derived EXTENDING Base { ALTER PROPERTY foo { # overloading the property to be required # regardless of the ancestors SET REQUIRED; }; }; """) with self.assertRaisesRegex( edgedb.MissingRequiredError, f"missing value for required property" r" 'foo' of object type 'default::Base'", ): async with self.con.transaction(): await self.con.execute(""" INSERT Base; """) with self.assertRaisesRegex( edgedb.MissingRequiredError, f"missing value for required property" r" 'foo' of object type 'default::Derived'", ): async with self.con.transaction(): await self.con.execute(""" INSERT Derived; """) await self.con.execute(""" ALTER TYPE Base { ALTER PROPERTY foo { SET OPTIONAL; }; }; """) await self.con.execute(""" INSERT Base; """) await self.assert_query_result( r''' SELECT count(Base); ''', [1], ) with self.assertRaisesRegex( edgedb.MissingRequiredError, f"missing value for required property" r" 'foo' of object type 'default::Derived'", ): async with self.con.transaction(): await self.con.execute(""" INSERT Derived; """) await self.con.execute(""" ALTER TYPE Derived { ALTER PROPERTY foo { SET OPTIONAL; }; }; """) await self.con.execute(""" INSERT Derived; """) await self.assert_query_result( r''' SELECT count(Derived); ''', [1], )
) with self.assertRaisesRegex( edgedb.MissingRequiredError, f"missing value for required property" r" 'foo' of object type 'default::Base'", ): async with self.con.transaction(): await self.con.execute(
test_edgeql_ddl_required_08
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_required_09(self): # Test normal that required qualifier behavior. await self.con.execute(r""" CREATE TYPE Base { CREATE OPTIONAL PROPERTY foo -> str; }; CREATE TYPE Derived EXTENDING Base { ALTER PROPERTY foo { # overloading the property to be required # regardless of the ancestors SET REQUIRED; }; }; """) with self.assertRaisesRegex( edgedb.MissingRequiredError, f"missing value for required property" r" 'foo' of object type 'default::Derived'", ): async with self.con.transaction(): await self.con.execute(""" INSERT Derived; """) await self.con.execute(""" INSERT Base; """) await self.assert_query_result( r''' SELECT count(Base); ''', [1], ) with self.assertRaisesRegex( edgedb.MissingRequiredError, f"missing value for required property" r" 'foo' of object type 'default::Derived'", ): async with self.con.transaction(): await self.con.execute(""" INSERT Derived; """) await self.con.execute(""" ALTER TYPE Derived { ALTER PROPERTY foo { SET OPTIONAL; }; }; """) await self.con.execute(""" INSERT Derived; """) await self.assert_query_result( r''' SELECT count(Derived); ''', [1], )
) with self.assertRaisesRegex( edgedb.MissingRequiredError, f"missing value for required property" r" 'foo' of object type 'default::Derived'", ): async with self.con.transaction(): await self.con.execute(
test_edgeql_ddl_required_09
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_required_10(self): # Test normal that required qualifier behavior. await self.con.execute(r""" CREATE TYPE Base { CREATE REQUIRED MULTI PROPERTY name -> str; }; """) async with self.assertRaisesRegexTx( edgedb.MissingRequiredError, r"missing value for required property 'name'" r" of object type 'default::Base'", ): async with self.con.transaction(): await self.con.execute(""" INSERT Base; """) async with self.assertRaisesRegexTx( edgedb.MissingRequiredError, r"missing value for required property 'name'" r" of object type 'default::Base'", ): async with self.con.transaction(): await self.con.execute(""" INSERT Base {name := {}}; """) async with self.assertRaisesRegexTx( edgedb.MissingRequiredError, r"missing value for required property 'name'" r" of object type 'default::Base'", ): async with self.con.transaction(): await self.con.execute(""" WITH names := {'A', 'B'} INSERT Base { name := (SELECT names FILTER names = 'C'), }; """)
) async with self.assertRaisesRegexTx( edgedb.MissingRequiredError, r"missing value for required property 'name'" r" of object type 'default::Base'", ): async with self.con.transaction(): await self.con.execute(
test_edgeql_ddl_required_10
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_required_11(self): # Test normal that required qualifier behavior. await self.con.execute(r""" CREATE TYPE Child; CREATE TYPE Base { CREATE REQUIRED MULTI LINK children -> Child; }; """) with self.assertRaisesRegex( edgedb.MissingRequiredError, r"missing value for required link 'children'" r" of object type 'default::Base'" ): async with self.con.transaction(): await self.con.execute(""" INSERT Base; """) with self.assertRaisesRegex( edgedb.MissingRequiredError, r"missing value for required link 'children'" r" of object type 'default::Base'" ): async with self.con.transaction(): await self.con.execute(""" INSERT Base {children := {}}; """) with self.assertRaisesRegex( edgedb.MissingRequiredError, r"missing value for required link 'children'" r" of object type 'default::Base'" ): async with self.con.transaction(): await self.con.execute(""" INSERT Base { children := (SELECT Child FILTER false) }; """)
) with self.assertRaisesRegex( edgedb.MissingRequiredError, r"missing value for required link 'children'" r" of object type 'default::Base'" ): async with self.con.transaction(): await self.con.execute(
test_edgeql_ddl_required_11
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_index_06(self): # Unfortunately we don't really have a way to test that this # actually works, but I looked at the SQL DDL. await self.con.execute(r""" create type Foo { create property name -> str; create property exclude -> bool; create index on (.name) except (.exclude); }; """) # But we can at least make sure it made it into the schema await self.assert_query_result( ''' SELECT schema::ObjectType { indexes: {expr, except_expr} } FILTER .name = 'default::Foo' ''', [{"indexes": [{"except_expr": ".exclude", "expr": ".name"}]}] )
) # But we can at least make sure it made it into the schema await self.assert_query_result(
test_edgeql_ddl_index_06
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0
async def test_edgeql_ddl_errors_01(self): await self.con.execute(''' CREATE TYPE Err1 { CREATE REQUIRED PROPERTY foo -> str; }; ALTER TYPE Err1 CREATE REQUIRED LINK bar -> Err1; ''') async with self._run_and_rollback(): with self.assertRaisesRegex( edgedb.errors.InvalidReferenceError, "property 'b' does not exist"): await self.con.execute(''' ALTER TYPE Err1 ALTER PROPERTY b CREATE CONSTRAINT std::regexp(r'b'); ''') async with self._run_and_rollback(): with self.assertRaisesRegex( edgedb.errors.InvalidReferenceError, "property 'b' does not exist"): await self.con.execute(''' ALTER TYPE Err1 DROP PROPERTY b ''') async with self._run_and_rollback(): with self.assertRaisesRegex( edgedb.errors.InvalidReferenceError, "constraint 'default::a' does not exist"): await self.con.execute(''' ALTER TYPE Err1 ALTER PROPERTY foo DROP CONSTRAINT a; ''') async with self._run_and_rollback(): with self.assertRaisesRegex( edgedb.errors.InvalidReferenceError, "constraint 'default::a' does not exist"): await self.con.execute(''' ALTER TYPE Err1 ALTER PROPERTY foo ALTER CONSTRAINT a ON (foo > 0) { CREATE ANNOTATION title := 'test' } ''') async with self._run_and_rollback(): with self.assertRaisesRegex( edgedb.errors.InvalidReferenceError, "annotation 'std::title' does not exist"): await self.con.execute(''' ALTER TYPE Err1 ALTER PROPERTY foo ALTER ANNOTATION title := 'aaa' ''') async with self._run_and_rollback(): with self.assertRaisesRegex( edgedb.errors.InvalidReferenceError, "annotation 'std::title' does not exist"): await self.con.execute(''' ALTER TYPE Err1 ALTER PROPERTY foo DROP ANNOTATION title; ''') async with self._run_and_rollback(): with self.assertRaisesRegex( edgedb.errors.InvalidReferenceError, "annotation 'std::title' does not exist"): await self.con.execute(''' ALTER TYPE Err1 ALTER ANNOTATION title := 'aaa' ''') async with self._run_and_rollback(): with self.assertRaisesRegex( edgedb.errors.InvalidReferenceError, "annotation 'std::title' does not exist"): await self.con.execute(''' ALTER TYPE Err1 DROP ANNOTATION title ''') async with self._run_and_rollback(): with self.assertRaisesRegex( edgedb.errors.InvalidReferenceError, r"index on \(.foo\) does not exist on" r" object type 'default::Err1'", ): await self.con.execute(''' ALTER TYPE Err1 DROP INDEX ON (.foo) ''') async with self._run_and_rollback(): with self.assertRaisesRegex( edgedb.errors.InvalidReferenceError, r"index on \(.zz\) does not exist on object type " r"'default::Err1'", ): await self.con.execute(''' ALTER TYPE Err1 DROP INDEX ON (.zz) ''') async with self._run_and_rollback(): with self.assertRaisesRegex( edgedb.errors.InvalidReferenceError, "object type 'default::Err1' has no link or " "property 'zz'"): await self.con.execute(''' ALTER TYPE Err1 CREATE INDEX ON (.zz) ''') async with self._run_and_rollback(): with self.assertRaisesRegex( edgedb.errors.InvalidReferenceError, "object type 'default::Err1' has no link or " "property 'zz'"): await self.con.execute(''' ALTER TYPE Err1 CREATE INDEX ON ((.foo, .zz)) ''') async with self._run_and_rollback(): with self.assertRaisesRegex( edgedb.errors.InvalidReferenceError, "object type 'default::blah' does not exist"): await self.con.execute(''' CREATE TYPE Err1 EXTENDING blah { CREATE PROPERTY foo -> str; }; ''') async with self._run_and_rollback(): with self.assertRaisesRegex( edgedb.errors.InvalidReferenceError, "object type 'default::blah' does not exist"): await self.con.execute(''' CREATE TYPE Err2 EXTENDING blah { CREATE PROPERTY foo -> str; }; ''') async with self._run_and_rollback(): with self.assertRaisesRegex( edgedb.errors.InvalidReferenceError, "link 'b' does not exist"): await self.con.execute(''' ALTER TYPE Err1 ALTER LINK b CREATE CONSTRAINT std::regexp(r'b'); ''') async with self._run_and_rollback(): with self.assertRaisesRegex( edgedb.errors.InvalidReferenceError, "link 'b' does not exist"): await self.con.execute(''' ALTER TYPE Err1 DROP LINK b; ''') async with self._run_and_rollback(): with self.assertRaisesRegex( edgedb.errors.InvalidReferenceError, "annotation 'std::title' does not exist"): await self.con.execute(''' ALTER TYPE Err1 ALTER LINK bar DROP ANNOTATION title; ''') async with self._run_and_rollback(): with self.assertRaisesRegex( edgedb.errors.InvalidReferenceError, "constraint 'std::min_value' does not exist"): await self.con.execute(''' ALTER TYPE Err1 ALTER LINK bar DROP CONSTRAINT min_value(0); ''') async with self._run_and_rollback(): with self.assertRaisesRegex( edgedb.errors.InvalidReferenceError, "property 'spam' does not exist"): await self.con.execute(''' ALTER TYPE Err1 ALTER LINK bar DROP PROPERTY spam; ''')
) async with self._run_and_rollback(): with self.assertRaisesRegex( edgedb.errors.InvalidReferenceError, "property 'b' does not exist"): await self.con.execute(
test_edgeql_ddl_errors_01
python
geldata/gel
tests/test_edgeql_ddl.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ddl.py
Apache-2.0