MCPcopy
hub / github.com/geldata/gel / test_edgeql_insert_unless_conflict_22

Method test_edgeql_insert_unless_conflict_22

tests/test_edgeql_insert.py:3755–3815  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

3753 )
3754
3755 async def test_edgeql_insert_unless_conflict_22(self):
3756 await self.con.execute('''
3757 CREATE TYPE Foo {
3758 CREATE REQUIRED PROPERTY foo -> str {
3759 CREATE CONSTRAINT exclusive;
3760 };
3761 };
3762 CREATE TYPE Bar {
3763 CREATE REQUIRED PROPERTY bar -> str {
3764 CREATE CONSTRAINT exclusive;
3765 };
3766 };
3767 CREATE TYPE Baz extending Foo, Bar;
3768 ''')
3769
3770 await self.con.execute(r'''
3771 INSERT Foo { foo := "foo" };
3772 INSERT Bar { bar := "bar" };
3773 ''')
3774
3775 await self.assert_query_result(
3776 r'''
3777 INSERT Baz { foo := "!", bar := "bar" }
3778 UNLESS CONFLICT ON (.bar)
3779 ''',
3780 [],
3781 )
3782
3783 async with self.assertRaisesRegexTx(
3784 edgedb.ConstraintViolationError,
3785 "violates exclusivity constraint"):
3786 await self.con.execute(
3787 r'''
3788 INSERT Baz { foo := "!", bar := "bar" }
3789 UNLESS CONFLICT ON (.foo)
3790 ''',
3791 )
3792
3793 await self.assert_query_result(
3794 r'''
3795 INSERT Baz { foo := "foo", bar := "!" }
3796 UNLESS CONFLICT
3797 ''',
3798 [],
3799 )
3800
3801 await self.assert_query_result(
3802 r'''
3803 INSERT Baz { foo := "!", bar := "bar" }
3804 UNLESS CONFLICT
3805 ''',
3806 [],
3807 )
3808
3809 await self.assert_query_result(
3810 r'''
3811 INSERT Baz { foo := "foo", bar := "bar" }
3812 UNLESS CONFLICT

Callers

nothing calls this directly

Calls 3

executeMethod · 0.80
assertRaisesRegexTxMethod · 0.80
assert_query_resultMethod · 0.45

Tested by

no test coverage detected