code
stringlengths 26
870k
| docstring
stringlengths 1
65.6k
| func_name
stringlengths 1
194
| language
stringclasses 1
value | repo
stringlengths 8
68
| path
stringlengths 5
182
| url
stringlengths 46
251
| license
stringclasses 4
values |
---|---|---|---|---|---|---|---|
def test_edgeql_ir_mult_inference_41(self):
"""
SELECT ['card', Card.name][0]
% OK %
DUPLICATE
""" | SELECT ['card', Card.name][0]
% OK %
DUPLICATE | test_edgeql_ir_mult_inference_41 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_42(self):
# It's probably impractical to even try to infer that we're
# only fetching a unique array element here.
"""
SELECT ['card', Card.name][1]
% OK %
DUPLICATE
""" | SELECT ['card', Card.name][1]
% OK %
DUPLICATE | test_edgeql_ir_mult_inference_42 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_43(self):
"""
SELECT DISTINCT Card.element
% OK %
UNIQUE
""" | SELECT DISTINCT Card.element
% OK %
UNIQUE | test_edgeql_ir_mult_inference_43 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_44(self):
"""
SELECT User {
friends_of_friends := .friends.friends,
others := (
SELECT WaterOrEarthCard.owners
)
}
% OK %
UNIQUE
""" | SELECT User {
friends_of_friends := .friends.friends,
others := (
SELECT WaterOrEarthCard.owners
)
}
% OK %
UNIQUE | test_edgeql_ir_mult_inference_44 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_45(self):
"""
SELECT Award {
owner := .<awards[IS User]
}
% OK %
UNIQUE
""" | SELECT Award {
owner := .<awards[IS User]
}
% OK %
UNIQUE | test_edgeql_ir_mult_inference_45 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_46(self):
"""
SELECT User {
card_names := .deck.name,
card_elements := DISTINCT .deck.element,
deck: {
el := User.deck.element[:2]
}
}
% OK %
UNIQUE
""" | SELECT User {
card_names := .deck.name,
card_elements := DISTINCT .deck.element,
deck: {
el := User.deck.element[:2]
}
}
% OK %
UNIQUE | test_edgeql_ir_mult_inference_46 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_47(self):
"""
SELECT 1 IS str
% OK %
UNIQUE
""" | SELECT 1 IS str
% OK %
UNIQUE | test_edgeql_ir_mult_inference_47 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_48(self):
"""
SELECT Award IS Named
% OK %
DUPLICATE
""" | SELECT Award IS Named
% OK %
DUPLICATE | test_edgeql_ir_mult_inference_48 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_49(self):
"""
WITH
A := (
SELECT Award FILTER .name = 'Wow'
)
SELECT A IS Named
% OK %
UNIQUE
""" | WITH
A := (
SELECT Award FILTER .name = 'Wow'
)
SELECT A IS Named
% OK %
UNIQUE | test_edgeql_ir_mult_inference_49 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_50(self):
"""
SELECT Award.name IS str
% OK %
DUPLICATE
""" | SELECT Award.name IS str
% OK %
DUPLICATE | test_edgeql_ir_mult_inference_50 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_51(self):
"""
SELECT INTROSPECT TYPEOF User.deck
% OK %
UNIQUE
""" | SELECT INTROSPECT TYPEOF User.deck
% OK %
UNIQUE | test_edgeql_ir_mult_inference_51 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_52(self):
"""
SELECT (INTROSPECT TYPEOF User.deck).name
% OK %
UNIQUE
""" | SELECT (INTROSPECT TYPEOF User.deck).name
% OK %
UNIQUE | test_edgeql_ir_mult_inference_52 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_53(self):
"""
SELECT User {
card_elements := .deck.element
}
% OK %
UNIQUE
""" | SELECT User {
card_elements := .deck.element
}
% OK %
UNIQUE | test_edgeql_ir_mult_inference_53 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_54(self):
"""
SELECT User {
foo := {1, 1, 2}
}
% OK %
UNIQUE
""" | SELECT User {
foo := {1, 1, 2}
}
% OK %
UNIQUE | test_edgeql_ir_mult_inference_54 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_55a(self):
"""
FOR x IN {'fire', 'water'}
UNION (
SELECT Card
FILTER .element = x
)
% OK %
UNIQUE
""" | FOR x IN {'fire', 'water'}
UNION (
SELECT Card
FILTER .element = x
)
% OK %
UNIQUE | test_edgeql_ir_mult_inference_55a | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_55b(self):
"""
FOR letter IN {'I', 'B'}
UNION (
SELECT Card
FILTER .name[0] = letter
)
% OK %
DUPLICATE
""" | FOR letter IN {'I', 'B'}
UNION (
SELECT Card
FILTER .name[0] = letter
)
% OK %
DUPLICATE | test_edgeql_ir_mult_inference_55b | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_56(self):
"""
SELECT User {
wishlist := (
FOR x IN {'fire', 'water'}
UNION (
SELECT Card
FILTER .element = x
)
)
}
% OK %
UNIQUE
""" | SELECT User {
wishlist := (
FOR x IN {'fire', 'water'}
UNION (
SELECT Card
FILTER .element = x
)
)
}
% OK %
UNIQUE | test_edgeql_ir_mult_inference_56 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_57(self):
"""
SELECT enumerate({2, 2})
% OK %
UNIQUE
""" | SELECT enumerate({2, 2})
% OK %
UNIQUE | test_edgeql_ir_mult_inference_57 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_58(self):
"""
SELECT enumerate(Card)
% OK %
UNIQUE
""" | SELECT enumerate(Card)
% OK %
UNIQUE | test_edgeql_ir_mult_inference_58 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_59(self):
"""
FOR x IN {enumerate({'fire', 'water'})}
UNION (
SELECT Card
FILTER .element = x.1
)
% OK %
UNIQUE
""" | FOR x IN {enumerate({'fire', 'water'})}
UNION (
SELECT Card
FILTER .element = x.1
)
% OK %
UNIQUE | test_edgeql_ir_mult_inference_59 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_59a(self):
"""
FOR x IN {enumerate({'fire', 'water'})}
UNION (
SELECT (
SELECT Card
FILTER .element = x.1
)
)
% OK %
UNIQUE
""" | FOR x IN {enumerate({'fire', 'water'})}
UNION (
SELECT (
SELECT Card
FILTER .element = x.1
)
)
% OK %
UNIQUE | test_edgeql_ir_mult_inference_59a | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_60(self):
"""
FOR x IN {
enumerate(
DISTINCT array_unpack(['fire', 'water']))
}
UNION (
SELECT Card
FILTER .element = x.1
)
% OK %
UNIQUE
""" | FOR x IN {
enumerate(
DISTINCT array_unpack(['fire', 'water']))
}
UNION (
SELECT Card
FILTER .element = x.1
)
% OK %
UNIQUE | test_edgeql_ir_mult_inference_60 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_61(self):
"""
FOR x IN {
enumerate(
array_unpack(['A', 'B']))
}
UNION (
INSERT Card {
name := x.1,
element := 'test',
cost := 0,
req_awards := {}, # wtvr
req_tags := {}, # wtvr
}
)
% OK %
UNIQUE
""" | FOR x IN {
enumerate(
array_unpack(['A', 'B']))
}
UNION (
INSERT Card {
name := x.1,
element := 'test',
cost := 0,
req_awards := {}, # wtvr
req_tags := {}, # wtvr
}
)
% OK %
UNIQUE | test_edgeql_ir_mult_inference_61 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_62(self):
"""
SELECT Card UNION SpecialCard
% OK %
DUPLICATE
""" | SELECT Card UNION SpecialCard
% OK %
DUPLICATE | test_edgeql_ir_mult_inference_62 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_63(self):
"""
FOR card IN {enumerate(Card)}
UNION (SELECT card.1)
% OK %
UNIQUE
""" | FOR card IN {enumerate(Card)}
UNION (SELECT card.1)
% OK %
UNIQUE | test_edgeql_ir_mult_inference_63 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_64(self):
"""
FOR card IN {Card}
UNION card
% OK %
UNIQUE
""" | FOR card IN {Card}
UNION card
% OK %
UNIQUE | test_edgeql_ir_mult_inference_64 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_65(self):
"""
WITH C := <Card>{}
FOR card IN {C}
UNION card
% OK %
EMPTY
""" | WITH C := <Card>{}
FOR card IN {C}
UNION card
% OK %
EMPTY | test_edgeql_ir_mult_inference_65 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_66(self):
"""
FOR card IN {Card, SpecialCard}
UNION card
% OK %
DUPLICATE
""" | FOR card IN {Card, SpecialCard}
UNION card
% OK %
DUPLICATE | test_edgeql_ir_mult_inference_66 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_67(self):
"""
SELECT
(SELECT User FILTER .name = "foo")
??
(SELECT User FILTER .name = "bar")
% OK %
UNIQUE
""" | SELECT
(SELECT User FILTER .name = "foo")
??
(SELECT User FILTER .name = "bar")
% OK %
UNIQUE | test_edgeql_ir_mult_inference_67 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_68(self):
"""
SELECT
(SELECT User FILTER .name = "foo")
??
{
User,
User,
}
% OK %
DUPLICATE
""" | SELECT
(SELECT User FILTER .name = "foo")
??
{
User,
User,
}
% OK %
DUPLICATE | test_edgeql_ir_mult_inference_68 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_69(self):
"""
SELECT
{
(INSERT User { name := "a" }),
(INSERT User { name := "b" }),
}
% OK %
UNIQUE
""" | SELECT
{
(INSERT User { name := "a" }),
(INSERT User { name := "b" }),
}
% OK %
UNIQUE | test_edgeql_ir_mult_inference_69 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_70(self):
"""
WITH
X1 := Card {
z := (.<deck[IS User],)
}
SELECT X1 {
foo := .z.0
}.foo
% OK %
UNIQUE
""" | WITH
X1 := Card {
z := (.<deck[IS User],)
}
SELECT X1 {
foo := .z.0
}.foo
% OK %
UNIQUE | test_edgeql_ir_mult_inference_70 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_71(self):
"""
FOR card IN {assert_distinct(Card UNION SpecialCard)}
UNION card
% OK %
UNIQUE
""" | FOR card IN {assert_distinct(Card UNION SpecialCard)}
UNION card
% OK %
UNIQUE | test_edgeql_ir_mult_inference_71 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_error_01(self):
"""
SELECT User {
bad_link := {Card, Card},
name,
}
""" | SELECT User {
bad_link := {Card, Card},
name,
} | test_edgeql_ir_mult_inference_error_01 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_error_02(self):
"""
WITH
A := {Card, Card}
SELECT User {
bad_link := A,
name,
}
""" | WITH
A := {Card, Card}
SELECT User {
bad_link := A,
name,
} | test_edgeql_ir_mult_inference_error_02 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_72(self):
"""
SELECT ()
% OK %
UNIQUE
""" | SELECT ()
% OK %
UNIQUE | test_edgeql_ir_mult_inference_72 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_73(self):
"""
SELECT {(), ()}
% OK %
DUPLICATE
""" | SELECT {(), ()}
% OK %
DUPLICATE | test_edgeql_ir_mult_inference_73 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_74(self):
"""
SELECT <array<str>>[]
% OK %
UNIQUE
""" | SELECT <array<str>>[]
% OK %
UNIQUE | test_edgeql_ir_mult_inference_74 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_75(self):
"""
SELECT <str>{}
% OK %
EMPTY
""" | SELECT <str>{}
% OK %
EMPTY | test_edgeql_ir_mult_inference_75 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_76(self):
"""
SELECT (Card, User).1
% OK %
DUPLICATE
""" | SELECT (Card, User).1
% OK %
DUPLICATE | test_edgeql_ir_mult_inference_76 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_77(self):
"""
for x in {1, 2} union { foo := 10 }
% OK %
UNIQUE
""" | for x in {1, 2} union { foo := 10 }
% OK %
UNIQUE | test_edgeql_ir_mult_inference_77 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_78(self):
"""
with F := { foo := 10 }
for x in {1, 2} union F
% OK %
DUPLICATE
""" | with F := { foo := 10 }
for x in {1, 2} union F
% OK %
DUPLICATE | test_edgeql_ir_mult_inference_78 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_79(self):
"""
for x in {1, 2, 3} union (with z := x, select z)
% OK %
UNIQUE
""" | for x in {1, 2, 3} union (with z := x, select z)
% OK %
UNIQUE | test_edgeql_ir_mult_inference_79 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_80(self):
"""
for x in {1,2} union (for y in {3, 4} union x)
% OK %
DUPLICATE
""" | for x in {1,2} union (for y in {3, 4} union x)
% OK %
DUPLICATE | test_edgeql_ir_mult_inference_80 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_81(self):
"""
for x in {1,2} union (for y in {3, 4} union y)
% OK %
DUPLICATE
""" | for x in {1,2} union (for y in {3, 4} union y)
% OK %
DUPLICATE | test_edgeql_ir_mult_inference_81 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_82(self):
"""
select 1 union 1
% OK %
DUPLICATE
""" | select 1 union 1
% OK %
DUPLICATE | test_edgeql_ir_mult_inference_82 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_83(self):
"""
select 1 + (2 intersect 3)
% OK %
UNIQUE
""" | select 1 + (2 intersect 3)
% OK %
UNIQUE | test_edgeql_ir_mult_inference_83 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_84(self):
"""
select 1 + (2 intersect {3, 3})
% OK %
UNIQUE
""" | select 1 + (2 intersect {3, 3})
% OK %
UNIQUE | test_edgeql_ir_mult_inference_84 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_85(self):
"""
select 1 + ({2, 2} intersect {3, 3})
% OK %
DUPLICATE
""" | select 1 + ({2, 2} intersect {3, 3})
% OK %
DUPLICATE | test_edgeql_ir_mult_inference_85 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_86(self):
"""
select {2, 2} intersect <int64>{}
% OK %
EMPTY
""" | select {2, 2} intersect <int64>{}
% OK %
EMPTY | test_edgeql_ir_mult_inference_86 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_87(self):
"""
select 1 + (2 except 3)
% OK %
UNIQUE
""" | select 1 + (2 except 3)
% OK %
UNIQUE | test_edgeql_ir_mult_inference_87 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_88(self):
"""
select 1 + (2 except {3, 3})
% OK %
UNIQUE
""" | select 1 + (2 except {3, 3})
% OK %
UNIQUE | test_edgeql_ir_mult_inference_88 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_89(self):
"""
select 1 + ({2, 2} except {3, 3})
% OK %
DUPLICATE
""" | select 1 + ({2, 2} except {3, 3})
% OK %
DUPLICATE | test_edgeql_ir_mult_inference_89 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_90(self):
"""
if <bool>$0 then
(insert User { name := "test" })
else
(insert User { name := "???" })
% OK %
UNIQUE
""" | if <bool>$0 then
(insert User { name := "test" })
else
(insert User { name := "???" })
% OK %
UNIQUE | test_edgeql_ir_mult_inference_90 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_91(self):
"""
if <bool>$0 then
(insert User { name := "test" })
else
{(insert User { name := "???" }), (insert User { name := "!!!" })}
% OK %
UNIQUE
""" | if <bool>$0 then
(insert User { name := "test" })
else
{(insert User { name := "???" }), (insert User { name := "!!!" })}
% OK %
UNIQUE | test_edgeql_ir_mult_inference_91 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
def test_edgeql_ir_mult_inference_92(self):
"""
if <bool>$0 then
(insert User { name := "test" })
else
<User>{}
% OK %
UNIQUE
""" | if <bool>$0 then
(insert User { name := "test" })
else
<User>{}
% OK %
UNIQUE | test_edgeql_ir_mult_inference_92 | python | geldata/gel | tests/test_edgeql_ir_mult_inference.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_mult_inference.py | Apache-2.0 |
async def test_edgeql_insert_nested_09(self):
# test a single link with a link property
await self.con.execute(r'''
INSERT InsertTest {
name := 'insert nested 9',
l2 := 0,
sub := (
INSERT Subordinate {
name := 'nested sub 9',
@note := 'sub note 9',
}
)
}
''')
await self.assert_query_result(r'''
SELECT InsertTest {
name,
sub: {
name,
@note
}
} FILTER
.name = 'insert nested 9'
''', [{
'name': 'insert nested 9',
'sub': {
'name': 'nested sub 9',
'@note': 'sub note 9',
}
}]) | )
await self.assert_query_result(r | test_edgeql_insert_nested_09 | 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_returning_02(self):
await self.assert_query_result(
'''
INSERT DefaultTest1 {
foo := 'ret1',
num := 1,
};
''',
[{
'id': uuid.UUID,
}],
)
await self.assert_query_result(
'''
SELECT (INSERT DefaultTest1 {
foo := 'ret2',
num := 2,
}) {foo};
''',
[{
'foo': 'ret2',
}],
)
await self.assert_query_result(
'''
SELECT (INSERT DefaultTest1 {
foo := 'ret3',
num := 3,
}).num;
''',
[3],
)
obj = await self.con._fetchall(
'''
INSERT DefaultTest1 {
foo := 'ret1',
num := 1,
};
''',
__typeids__=True,
__typenames__=True,
)
self.assertTrue(hasattr(obj[0], 'id'))
self.assertTrue(hasattr(obj[0], '__tid__'))
self.assertEqual(obj[0].__tname__, 'default::DefaultTest1') | INSERT DefaultTest1 {
foo := 'ret1',
num := 1,
};
''',
[{
'id': uuid.UUID,
}],
)
await self.assert_query_result( | test_edgeql_insert_returning_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_returning_04(self):
await self.assert_query_result(
r'''
SELECT (INSERT DefaultTest1 {
foo := 'DT returning 4',
num := 33,
}) {foo, num};
''',
[{
'foo': 'DT returning 4',
'num': 33,
}],
)
await self.assert_query_result(
r'''
WITH
I := (INSERT InsertTest {
name := 'IT returning 4',
l2 := 9999,
})
SELECT
DefaultTest1 {foo, num}
FILTER DefaultTest1.num > I.l2;
''',
[],
)
await self.assert_query_result(
r'''
WITH
I := (INSERT InsertTest {
name := 'IT returning 4',
l2 := 9,
})
SELECT
DefaultTest1 {foo, num}
FILTER DefaultTest1.num > I.l2;
''',
[{
'foo': 'DT returning 4',
'num': 33,
}],
) | ,
[{
'foo': 'DT returning 4',
'num': 33,
}],
)
await self.assert_query_result(
r | test_edgeql_insert_returning_04 | 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_returning_09(self):
# make sure a WITH bound insert makes it into the returned data
await self.assert_query_result(
r'''
WITH N := (INSERT Note {name := "!" }),
SELECT ((
INSERT Person {
name := "Phil Emarg",
notes := N,
}
)) { name, notes: {name} };
''',
[{
'name': 'Phil Emarg',
'notes': [{'name': '!'}],
}],
)
# make sure it works when *doubly* nested!
await self.assert_query_result(
r'''
WITH S := (INSERT Subordinate { name := "sub" }),
N := (INSERT Note {name := "!", subject := S }),
SELECT ((
INSERT Person {
name := "Madeline Hatch",
notes := N,
}
)) { name, notes: {name, subject[IS Subordinate]: {name}} };
''',
[{
'name': 'Madeline Hatch',
'notes': [{'name': '!', 'subject': {'name': "sub"}}],
}],
)
# ... *doubly* nested, but the inner insert is a multi link
await self.assert_query_result(
r'''
WITH N := (INSERT Note {name := "!" }),
P := (INSERT Person {
name := "Emmanuel Villip",
notes := N,
}),
SELECT ((
INSERT PersonWrapper { person := P }
)) { person: { name, notes: {name} } };
''',
[{
'person': {
'name': 'Emmanuel Villip',
'notes': [{'name': '!'}],
},
}],
) | ,
[{
'name': 'Phil Emarg',
'notes': [{'name': '!'}],
}],
)
# make sure it works when *doubly* nested!
await self.assert_query_result(
r | test_edgeql_insert_returning_09 | 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_returning_11(self):
await self.con.execute(r'''
INSERT Note { name := "note", note := "a" };
''')
# test that subtypes get returned by a nested update
await self.assert_query_result(
r'''
SELECT
(INSERT Person {
name := "test",
notes := (
UPDATE Note FILTER .name = "note"
SET { note := "b" }
)
})
{ name, notes: {note} };
''',
[{
'name': 'test',
'notes': [{'note': "b"}],
}],
) | )
# test that subtypes get returned by a nested update
await self.assert_query_result(
r | test_edgeql_insert_returning_11 | 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_returning_14(self):
await self.con.execute(r'''
INSERT DerivedNote { name := "dnote", note := "a" };
INSERT DerivedNote { name := "anote", note := "some note" };
''')
# test that subtypes get returned by a nested update
# same as 13, but test that it happens even after doing a type filter!
await self.assert_query_result(
r'''
SELECT
(INSERT Person {
name := "test",
notes := assert_distinct({
(SELECT Note FILTER .name = "anote"),
(INSERT DerivedNote { name := "new note", note := "hi" }),
(UPDATE Note FILTER .name = "dnote" SET { note := "b" }),
})
})
{
name,
dnotes := (SELECT .notes[IS DerivedNote] {name, note}
ORDER BY .name)
}
''',
[
{
"name": "test",
"dnotes": [
{"name": "anote", "note": "some note"},
{"name": "dnote", "note": "b"},
{"name": "new note", "note": "hi"}
]
}
]
) | )
# test that subtypes get returned by a nested update
# same as 13, but test that it happens even after doing a type filter!
await self.assert_query_result(
r | test_edgeql_insert_returning_14 | 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_returning_15(self):
await self.con.execute('''
alter type Person {
create access policy ok allow all using (true);
};
''')
# Nested, with a required link that forces an assert_exists
# to get injected.
await self.assert_query_result(
r'''
WITH P := (INSERT Person {name := "Emmanuel Villip"}),
SELECT ((
INSERT PersonWrapper { person := P }
)) { person: { name } };
''',
[{"person": {"name": "Emmanuel Villip"}}],
) | )
# Nested, with a required link that forces an assert_exists
# to get injected.
await self.assert_query_result(
r | test_edgeql_insert_returning_15 | 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_conflict_policy_02(self):
# An UNLESS CONFLICT with an invisible conflicting object
# raises an exception. Notionally this is since the SELECT
# we do can't find the object, and so we can't fetch it for
# an ELSE clause.
await self.con.execute('''
alter type Person {
create access policy yes allow all using (true);
create access policy no deny select using (true);
};
''')
Q = '''
insert Person { name := "test" }
unless conflict on (.name) else (Person);
'''
await self.con.execute(Q)
async with self.assertRaisesRegexTx(
edgedb.ConstraintViolationError,
"violates exclusivity constraint"):
await self.con.execute(Q)
Q = '''
insert Person {
name := "test2", note := (insert Note { name := "" }) }
unless conflict on (.name) else (Person);
'''
await self.con.execute(Q)
async with self.assertRaisesRegexTx(
edgedb.ConstraintViolationError,
"violates exclusivity constraint"):
await self.con.execute(Q) | )
Q = | test_edgeql_insert_conflict_policy_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_policy_cast(self):
# Test for #6305, where a cast in a global used in an access policy
# was causing a stray volatility ref to show up in the wrong CTE
await self.con.execute('''
create global sub_id -> uuid;
create global sub := <Subordinate>(global sub_id);
alter type Note {
create access policy asdf allow all using (
(.subject in global sub) ?? false
)
};
''')
sub = await self.con.query_single('''
insert Subordinate { name := "asdf" };
''')
async with self.assertRaisesRegexTx(
edgedb.AccessPolicyError,
"violation on insert of default::Note"):
await self.con.execute('''
insert Person { notes := (insert Note { name := "" }) };
''')
async with self.assertRaisesRegexTx(
edgedb.AccessPolicyError,
"violation on insert of default::Note"):
await self.con.execute('''
insert Person {
notes := (insert Note {
name := "",
subject := assert_single(
(select Subordinate filter .name = 'asdf'))
})
};
''')
await self.con.execute('''
set global sub_id := <uuid>$0
''', sub.id)
await self.con.execute('''
insert Person {
notes := (insert Note {
name := "",
subject := assert_single(
(select Subordinate filter .name = 'asdf'))
})
};
''') | )
sub = await self.con.query_single( | test_edgeql_insert_policy_cast | 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_for_06(self):
res = await self.con.query(r'''
FOR a IN {"a", "b"}
FOR b IN {"c", "d"}
INSERT Note {name := b};
''')
self.assertEqual(len(res), 4)
await self.assert_query_result(
r'''
SELECT Note.name
ORDER BY Note.name;
''',
["c", "c", "d", "d"]
) | )
self.assertEqual(len(res), 4)
await self.assert_query_result(
r | test_edgeql_insert_for_06 | 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_for_08(self):
res = await self.con.query(r'''
FOR a IN {"a", "b"}
FOR b IN {"a", "b"}
FOR c IN {a++b++"a", a++b++"b"}
INSERT Note {name := c};
''')
self.assertEqual(len(res), 8)
await self.assert_query_result(
r'''
SELECT Note.name
ORDER BY Note.name;
''',
["aaa", "aab", "aba", "abb", "baa", "bab", "bba", "bbb"]
) | )
self.assertEqual(len(res), 8)
await self.assert_query_result(
r | test_edgeql_insert_for_08 | 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_for_12(self):
# FOR that has a correlated SELECT and INSERT
await self.assert_query_result(
r'''
FOR a in {"foo", "bar"} UNION (
(a,(INSERT Note {name:=a}))
)
''',
[["bar", {}], ["foo", {}]],
sort=True,
)
await self.assert_query_result(
r'''
SELECT Note.name
ORDER BY Note.name;
''',
["bar", "foo"]
) | ,
[["bar", {}], ["foo", {}]],
sort=True,
)
await self.assert_query_result(
r | test_edgeql_insert_for_12 | 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_for_13(self):
await self.assert_query_result(
r'''
FOR a in {"foo", "bar"} UNION (
SELECT (INSERT Note {name:=a}) {name}
)
''',
[{"name": "bar"}, {"name": "foo"}],
sort=lambda x: x['name']
)
await self.assert_query_result(
r'''
SELECT Note.name
ORDER BY Note.name;
''',
["bar", "foo"]
) | ,
[{"name": "bar"}, {"name": "foo"}],
sort=lambda x: x['name']
)
await self.assert_query_result(
r | test_edgeql_insert_for_13 | 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_for_14(self):
# Nested FOR that has a correlated SELECT and INSERT
await self.assert_query_result(
r'''
FOR a in {"a", "b"} UNION (
FOR b in {"c", "d"} UNION (
(a, b, (INSERT Note {name:=a++b}).name)
)
)
''',
[
["a", "c", "ac"],
["a", "d", "ad"],
["b", "c", "bc"],
["b", "d", "bd"],
],
sort=True
)
await self.assert_query_result(
r'''
SELECT Note.name
ORDER BY Note.name;
''',
["ac", "ad", "bc", "bd"]
) | ,
[
["a", "c", "ac"],
["a", "d", "ad"],
["b", "c", "bc"],
["b", "d", "bd"],
],
sort=True
)
await self.assert_query_result(
r | test_edgeql_insert_for_14 | 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_default_05(self):
# Issue #730
await self.con.execute(r'''
# The 'number' property is supposed to be
# self-incrementing and read-only.
INSERT DefaultTest8;
INSERT DefaultTest8;
INSERT DefaultTest8;
''')
try:
await self.assert_query_result(
r'''
SELECT DefaultTest8.number;
''',
{1, 2, 3},
)
except AssertionError:
if self.is_repeat:
await self.assert_query_result(
r'''
SELECT DefaultTest8.number;
''',
{4, 5, 6},
)
else:
raise | )
try:
await self.assert_query_result(
r | test_edgeql_insert_default_05 | 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_default_09(self):
async with self.assertRaisesRegexTx(
edgedb.SchemaDefinitionError,
r"default expression cannot refer to multi properties",
):
await self.migrate(
r"""
type Hello {
multi property b -> int32;
property a -> int32 {
default := count(.b);
};
}
"""
)
async with self.assertRaisesRegexTx(
edgedb.SchemaDefinitionError,
r"default expression cannot refer to links",
):
await self.migrate(
r"""
type World {
property w -> int32;
}
type Hello {
link world -> World;
property hello -> int32 {
default := .world.w;
};
}
"""
)
async with self.assertRaisesRegexTx(
edgedb.SchemaDefinitionError,
r"default expression cannot refer to links",
):
await self.migrate(
r"""
type World {
property w -> int32;
}
type Hello {
multi link world -> World;
property hello -> int32 {
default := count(.world);
};
}
"""
) | )
async with self.assertRaisesRegexTx(
edgedb.SchemaDefinitionError,
r"default expression cannot refer to links",
):
await self.migrate(
r | test_edgeql_insert_default_09 | 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_dunder_default_02(self):
async with self.assertRaisesRegexTx(
edgedb.InvalidReferenceError,
r"__default__ cannot be used in this expression",
_hint='Default expression uses DML',
):
await self.con.execute(r'''
INSERT DunderDefaultTest02_B {
default_with_insert := __default__
};
''')
async with self.assertRaisesRegexTx(
edgedb.InvalidReferenceError,
r"__default__ cannot be used in this expression",
_hint='Default expression uses DML',
):
await self.con.execute(r'''
INSERT DunderDefaultTest02_B {
default_with_update := __default__
};
''')
async with self.assertRaisesRegexTx(
edgedb.InvalidReferenceError,
r"__default__ cannot be used in this expression",
_hint='Default expression uses DML',
):
await self.con.execute(r'''
INSERT DunderDefaultTest02_B {
default_with_delete := __default__
};
''')
await self.con.execute(r'''
INSERT DunderDefaultTest02_A { a := 1 };
INSERT DunderDefaultTest02_A { a := 2 };
INSERT DunderDefaultTest02_A { a := 3 };
INSERT DunderDefaultTest02_A { a := 4 };
INSERT DunderDefaultTest02_B {
default_with_insert := (
select DunderDefaultTest02_A
filter DunderDefaultTest02_A.a = 1
),
default_with_update := (
select DunderDefaultTest02_A
filter DunderDefaultTest02_A.a = 2
),
default_with_delete := (
select DunderDefaultTest02_A
filter DunderDefaultTest02_A.a = 3
),
default_with_select := __default__
};
''')
await self.assert_query_result(
r'''
SELECT DunderDefaultTest02_B {
a := .default_with_select.a
};
''',
[
{'a': [4]},
]
) | )
async with self.assertRaisesRegexTx(
edgedb.InvalidReferenceError,
r"__default__ cannot be used in this expression",
_hint='Default expression uses DML',
):
await self.con.execute(r | test_edgeql_insert_dunder_default_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_tuples_01(self):
await self.assert_query_result(
r"""
with noobs := {
((insert InsertTest { l2 := 1 }), "bar"),
((insert InsertTest { l2 := 2 }), "eggs"),
},
select noobs;
""",
[
({}, "bar"),
({}, "eggs"),
]
)
await self.assert_query_result(
r"""
select {
((insert InsertTest { l2 := 1 }), "bar"),
((insert InsertTest { l2 := 2 }), "eggs"),
}
""",
[
({}, "bar"),
({}, "eggs"),
]
) | ,
[
({}, "bar"),
({}, "eggs"),
]
)
await self.assert_query_result(
r | test_edgeql_insert_tuples_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_tuples_04(self):
await self.assert_query_result(
r"""
with noobs := {
((insert Subordinate { name := "foo" }), "bar"),
((insert Subordinate { name := "spam" }), "eggs"),
},
select (insert InsertTest {
l2 := 1,
subordinates := assert_distinct(
noobs.0 { @comment := noobs.1 }),
}) { subordinates: {name, @comment} order by .name };
""",
[
{
"subordinates": [
{"name": "foo", "@comment": "bar"},
{"name": "spam", "@comment": "eggs"}
]
}
],
)
await self.assert_query_result(
r"""
select InsertTest { subordinates: {name, @comment} };
""",
[
{
"subordinates": [
{"name": "foo", "@comment": "bar"},
{"name": "spam", "@comment": "eggs"}
]
}
],
) | ,
[
{
"subordinates": [
{"name": "foo", "@comment": "bar"},
{"name": "spam", "@comment": "eggs"}
]
}
],
)
await self.assert_query_result(
r | test_edgeql_insert_tuples_04 | 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_unless_conflict_01(self):
query = r'''
SELECT
((INSERT Person {name := "test"} UNLESS CONFLICT)
?? (SELECT Person FILTER .name = "test")) {name};
'''
await self.assert_query_result(
query,
[{"name": "test"}],
)
await self.assert_query_result(
query,
[{"name": "test"}],
)
query2 = r'''
SELECT
((INSERT Person {name := <str>$0} UNLESS CONFLICT ON .name)
?? (SELECT Person FILTER .name = <str>$0));
'''
res = await self.con.query(query2, "test2")
res2 = await self.con.query(query2, "test2")
self.assertEqual([x.id for x in res], [x.id for x in res2])
res3 = await self.con.query(query2, "test3")
self.assertNotEqual([x.id for x in res], [x.id for x in res3]) | await self.assert_query_result(
query,
[{"name": "test"}],
)
await self.assert_query_result(
query,
[{"name": "test"}],
)
query2 = r | test_edgeql_insert_unless_conflict_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_unless_conflict_02(self):
async with self.assertRaisesRegexTx(
edgedb.QueryError,
"UNLESS CONFLICT argument must be a property"):
await self.con.query(r'''
INSERT Person {name := "hello"}
UNLESS CONFLICT ON 20;
''')
async with self.assertRaisesRegexTx(
edgedb.QueryError,
"UNLESS CONFLICT argument must be a property of "
"the type being inserted"):
await self.con.query(r'''
INSERT Person {name := "hello"}
UNLESS CONFLICT ON Note.name;
''')
async with self.assertRaisesRegexTx(
edgedb.QueryError,
"UNLESS CONFLICT property must have a "
"single exclusive constraint"):
await self.con.query(r'''
INSERT Note {name := "hello"}
UNLESS CONFLICT ON .name;
''')
async with self.assertRaisesRegexTx(
edgedb.QueryError,
"object type 'std::Object' has no link or property 'name'"):
await self.con.query(r'''
SELECT (
INSERT Person {name := "hello"}
UNLESS CONFLICT ON .name
ELSE DefaultTest1
) {name};
''')
async with self.assertRaisesRegexTx(
edgedb.QueryError,
"possibly more than one element returned by an expression "
"for a computed link 'foo' declared as 'single'"):
await self.con.query(r'''
WITH X := (
INSERT Person {name := "hello"}
UNLESS CONFLICT ON .name
ELSE (DETACHED Person)
)
SELECT {
single foo := X
};
''')
async with self.assertRaisesRegexTx(
edgedb.QueryError,
"possibly more than one element returned by an expression "
"for a computed link 'foo' declared as 'single'"):
await self.con.query(r'''
WITH X := (
INSERT Person {name := "hello"}
UNLESS CONFLICT ON .name
ELSE Note
)
SELECT {
single foo := X
};
''')
async with self.assertRaisesRegexTx(
edgedb.QueryError,
"possibly an empty set returned by an expression for a "
"computed link 'foo' declared as 'required'"):
await self.con.query(r'''
WITH X := (
INSERT Person {name := "hello"}
UNLESS CONFLICT ON .name
)
SELECT {
required foo := X
};
''') | )
async with self.assertRaisesRegexTx(
edgedb.QueryError,
"UNLESS CONFLICT argument must be a property of "
"the type being inserted"):
await self.con.query(r | test_edgeql_insert_unless_conflict_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_unless_conflict_04(self):
query = r'''
SELECT (
INSERT Person {name := "test"} UNLESS CONFLICT
ON .name ELSE (SELECT Person)
) {name};
'''
await self.assert_query_result(
query,
[{"name": "test"}],
)
await self.assert_query_result(
query,
[{"name": "test"}],
)
await self.assert_query_result(
r'''SELECT Person {name}''',
[{"name": "test"}],
)
query2 = r'''
INSERT Person {name := <str>$0} UNLESS CONFLICT
ON .name ELSE (SELECT Person)
'''
res = await self.con.query(query2, "test2")
res2 = await self.con.query(query2, "test2")
self.assertEqual([x.id for x in res], [x.id for x in res2])
res3 = await self.con.query(query2, "test3")
self.assertNotEqual([x.id for x in res], [x.id for x in res3]) | await self.assert_query_result(
query,
[{"name": "test"}],
)
await self.assert_query_result(
query,
[{"name": "test"}],
)
await self.assert_query_result(
r'''SELECT Person {name}''',
[{"name": "test"}],
)
query2 = r | test_edgeql_insert_unless_conflict_04 | 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_unless_conflict_05(self):
await self.con.execute(r'''
INSERT Person { name := "Phil Emarg" }
''')
query = r'''
SELECT (
INSERT Person {name := "Emmanuel Villip"} UNLESS CONFLICT
ON .name ELSE (UPDATE Person SET { tag := "redo" })
) {name, tag};
'''
await self.assert_query_result(
query,
[{"name": "Emmanuel Villip", "tag": None}],
)
await self.assert_query_result(
"SELECT Person {name, tag} ORDER BY .name",
[{"name": "Emmanuel Villip", "tag": None},
{"name": "Phil Emarg", "tag": None}],
)
await self.assert_query_result(
query,
[{"name": "Emmanuel Villip", "tag": "redo"}],
)
# Only the correct record should be updated
await self.assert_query_result(
"SELECT Person {name, tag} ORDER BY .name",
[{"name": "Emmanuel Villip", "tag": "redo"},
{"name": "Phil Emarg", "tag": None}],
sort=lambda x: x['name']
) | )
query = r | test_edgeql_insert_unless_conflict_05 | 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_unless_conflict_07(self):
# Test it using default values
query = r'''
SELECT (
INSERT Person UNLESS CONFLICT
ON .name ELSE (UPDATE Person SET { tag := "redo" })
) {name};
'''
await self.assert_query_result(
query,
[{"name": "Nemo"}],
)
await self.assert_query_result(
"SELECT Person {name, tag}",
[{"name": "Nemo", "tag": None}]
)
await self.assert_query_result(
query,
[{"name": "Nemo"}],
)
await self.con.execute(r'''
INSERT Person { name := "Phil Emarg" }
''')
# Only the correct record should be updated
await self.assert_query_result(
"SELECT Person {name, tag} ORDER BY .name",
[{"name": "Nemo", "tag": "redo"},
{"name": "Phil Emarg", "tag": None}],
) | await self.assert_query_result(
query,
[{"name": "Nemo"}],
)
await self.assert_query_result(
"SELECT Person {name, tag}",
[{"name": "Nemo", "tag": None}]
)
await self.assert_query_result(
query,
[{"name": "Nemo"}],
)
await self.con.execute(r | test_edgeql_insert_unless_conflict_07 | 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_unless_conflict_16(self):
# unless conflict with a volatile key
for _ in range(10):
await self.con.execute(r'''
DELETE Person;
''')
for _ in range(3):
res = await self.con.query(r'''
INSERT Person { name := <str>math::floor(random() * 2) }
UNLESS CONFLICT ON (.name) ELSE (Person)
''')
self.assertEqual(len(res), 1) | )
for _ in range(3):
res = await self.con.query(r | test_edgeql_insert_unless_conflict_16 | 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_unless_conflict_20b(self):
await self.con.execute(r'''
INSERT Person { name := "1" };
''')
# This is maybe what we want? Though it would also possibly
# be reasonable to require filtering Person explicitly?
# (we'll also want a test case with inheriting from two parents
await self.assert_query_result(
r'''
FOR x IN {"1", "2"} UNION (
INSERT DerivedPerson { name := x }
UNLESS CONFLICT ON (.name)
ELSE (UPDATE Person SET { tag := "!" })
);
''',
[{}],
)
await self.assert_query_result(
r'''
SELECT Person {name, tag, sub: Person IS DerivedPerson}
ORDER BY .name
''',
[
{'name': "1", 'tag': "!", 'sub': False},
{'name': "2", 'tag': None, 'sub': True},
]
) | )
# This is maybe what we want? Though it would also possibly
# be reasonable to require filtering Person explicitly?
# (we'll also want a test case with inheriting from two parents
await self.assert_query_result(
r | test_edgeql_insert_unless_conflict_20b | 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_unless_conflict_23(self):
# Test that scoping of default parameters doesn't get messed up
obj1 = await self.con.query_single('''
insert DerivedPerson { sub_key := "foo" };
''')
obj2 = await self.con.query_single('''
insert DerivedPerson {
name := "new",
sub_key := <str>json_get(
to_json('{ "sub_key": "foo"}'), 'sub_key')
}
unless conflict on .sub_key else (select DerivedPerson);
''')
self.assertEqual(obj1.id, obj2.id)
obj3 = await self.con.query('''
with
raw_data := to_json('[{"sub_key": "foo"}]')
for item in json_array_unpack(raw_data) union (
insert DerivedPerson {
name := "new",
sub_key := <str>json_get(item, 'sub_key')
}
unless conflict on .sub_key else (select DerivedPerson)
);
''')
self.assertEqual(len(obj3), 1)
self.assertEqual(obj1.id, tuple(obj3)[0].id) | )
obj2 = await self.con.query_single( | test_edgeql_insert_unless_conflict_23 | 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_unless_conflict_25(self):
await self.con.execute('''
create type X {
create required property n -> str {
create constraint exclusive;
}
};
create type Y {
create required link l -> X {
create constraint exclusive;
}
};
''')
q = '''
INSERT Y {
l := (INSERT X { n := <str>$n } UNLESS CONFLICT ON (.n) ELSE (X))
}
UNLESS CONFLICT ON (.l);
'''
await self.assert_query_result(
q, [{}], variables={'n': "1"},
)
await self.assert_query_result(
q, [], variables={'n': "1"},
)
await self.con.execute('''
insert X { n := "2" }
''')
await self.assert_query_result(
q, [{}], variables={'n': "2"},
)
await self.assert_query_result(
q, [], variables={'n': "2"},
) | )
q = | test_edgeql_insert_unless_conflict_25 | 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_unless_conflict_27(self):
DML_Q = '''
WITH P := (
insert Person { name := <str>$0 }
unless conflict on .name else (Person)
)
insert Person2a {
first := <str>$1, last := '', bff := P
} unless conflict on (.first, .last) else (
update Person2a set { bff := P }
)
'''
Q = '''
select Person2a { bff: {name} } filter .first = <str>$0
'''
# Try all 4 combinations of which conflict clauses fire
all_args = [
('a', 'x'),
('b', 'x'),
('b', 'y'),
('c', 'y'),
]
for friend, person in all_args:
await self.assert_query_result(
DML_Q,
[{}],
variables=(friend, person),
msg=f'insert {(friend, person)}',
)
await self.assert_query_result(
Q,
[{'bff': {'name': friend}}],
variables=(person,),
msg=f'check {(friend, person)}',
) | Q = | test_edgeql_insert_unless_conflict_27 | 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_dependent_16(self):
await self.assert_query_result(
r'''
SELECT (
INSERT Person {
name := "Test",
note := (INSERT Note {name := "tag!" })
} UNLESS CONFLICT
) {name};
''',
[{"name": "Test"}]
)
await self.assert_query_result(
r'''
SELECT (
INSERT Person {
name := "Test",
note := (
UPDATE (SELECT Note LIMIT 1)
SET { name := "owned" })
} UNLESS CONFLICT
) {name};
''',
[]
)
# Make sure the update did not happen
await self.assert_query_result(
r'''SELECT Note { name }''',
[{"name": "tag!"}],
) | ,
[{"name": "Test"}]
)
await self.assert_query_result(
r | test_edgeql_insert_dependent_16 | 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_dependent_23(self):
await self.con.execute('''
INSERT Person2a {
first := "Madeline",
last := "Hatch1",
}
''')
# test with something that has an object constraint
query = r'''
SELECT (
INSERT Person2a {
first := "Phil",
last := "Emarg",
note := (INSERT Note {name := "tag!" }),
} UNLESS CONFLICT
) {first, last};
'''
await self.assert_query_result(
query,
[{"first": "Phil", "last": "Emarg"}]
)
await self.assert_query_result(
query,
[],
)
# Make sure only 1 insert into Note happened
await self.assert_query_result(
r'''SELECT count(Note)''',
[1],
) | )
# test with something that has an object constraint
query = r | test_edgeql_insert_dependent_23 | 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_dependent_25(self):
await self.con.execute('''
INSERT Person2b {
first := "Madeline",
last := "Hatch3",
}
''')
# test with something that has a computed constraint using ON
query = r'''
SELECT (
INSERT Person2b {
first := "Phil",
last := "Emarg",
note := (INSERT Note {name := "tag!" }),
}
UNLESS CONFLICT ON (.name)
ELSE (SELECT Person2b)
) {name};
'''
await self.assert_query_result(
query,
[{"name": "Phil Emarg"}]
)
await self.assert_query_result(
query,
[{"name": "Phil Emarg"}]
)
# Make sure only 1 insert into Note happened
await self.assert_query_result(
r'''SELECT count(Note)''',
[1],
) | )
# test with something that has a computed constraint using ON
query = r | test_edgeql_insert_dependent_25 | 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_dependent_28(self):
await self.con.execute(r"""
create type X {
create required property name -> str {
create constraint exclusive
};
create multi link notes -> Note;
};
""")
# The Madeline note insert shouldn't happen
q = r"""
INSERT X {name := "Madeline Hatch",
notes := (INSERT Note {name := "tag" })}
UNLESS CONFLICT;
"""
await self.con.query(q)
await self.con.query(q)
# Should only be one note
await self.assert_query_result(
r'''SELECT count(Note)''',
[1],
) | )
# The Madeline note insert shouldn't happen
q = r | test_edgeql_insert_dependent_28 | 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_nested_volatile_01(self):
await self.con.execute('''
INSERT Subordinate {
name := 'subtest 1'
};
INSERT Subordinate {
name := 'subtest 2'
};
INSERT InsertTest {
name := 'insert nested',
l2 := 0,
subordinates := (
SELECT Subordinate {
@comment := <str>uuid_generate_v1mc()
}
)
};
''')
# Each object should get a distinct @comment
await self.assert_query_result(
r'''
SELECT count(DISTINCT InsertTest.subordinates@comment);
''',
[2]
) | )
# Each object should get a distinct @comment
await self.assert_query_result(
r | test_edgeql_insert_nested_volatile_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_cross_type_conflict_10(self):
await self.con.execute('''
CREATE ABSTRACT TYPE Named {
CREATE PROPERTY name -> str {
CREATE CONSTRAINT exclusive;
}
};
CREATE ABSTRACT TYPE Titled {
CREATE PROPERTY title -> str {
CREATE CONSTRAINT exclusive;
}
};
CREATE TYPE Foo EXTENDING Named, Titled;
CREATE TYPE Bar EXTENDING Named, Titled;
''')
async with self.assertRaisesRegexTx(
edgedb.ConstraintViolationError,
"name violates exclusivity constraint"):
await self.con.execute(r'''
WITH name := 'Madeline Hatch',
B := (INSERT Bar {name := name}),
F := (INSERT Foo {name := name}),
SELECT (B, F);
''')
async with self.assertRaisesRegexTx(
edgedb.ConstraintViolationError,
"title violates exclusivity constraint"):
await self.con.execute(r'''
WITH name := 'Madeline Hatch',
B := (INSERT Bar {title := name}),
F := (INSERT Foo {title := name}),
SELECT (B, F);
''') | )
async with self.assertRaisesRegexTx(
edgedb.ConstraintViolationError,
"name violates exclusivity constraint"):
await self.con.execute(r | test_edgeql_insert_cross_type_conflict_10 | 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_update_cross_type_conflict_13(self):
# ... make sure we don't try enforcing on non-exclusive constraints
await self.con.execute('''
CREATE TYPE Foo {
CREATE REQUIRED PROPERTY name -> str;
CREATE REQUIRED PROPERTY x -> int64;
CREATE CONSTRAINT expression on ((.x >= 0));
};
INSERT Foo { name := "bar", x := 1 };
INSERT Foo { name := "baz", x := 2 };
''')
query1 = r'''
UPDATE Foo FILTER true SET { name := .name };
'''
query2 = r'''
UPDATE Foo FILTER true SET { x := .x + 1 };
'''
await self.con.execute(query1)
await self.con.execute(query2)
await self.con.execute('''
CREATE TYPE Bar EXTENDING Foo;
''')
await self.con.execute(query1)
await self.con.execute(query2) | )
query1 = r | test_edgeql_insert_update_cross_type_conflict_13 | 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_update_cross_type_conflict_14(self):
await self.con.execute('''
create type A {
create property foo -> int64 {
create constraint exclusive;
}
};
create type B extending A;
create type X extending B;
create type Y extending B;
''')
with self.assertRaisesRegex(edgedb.ConstraintViolationError,
"violates exclusivity constraint"):
await self.con.execute('''
with x := (insert X { foo := 0 }),
y := (insert Y { foo := 0 }),
select {x, y};
''') | )
with self.assertRaisesRegex(edgedb.ConstraintViolationError,
"violates exclusivity constraint"):
await self.con.execute( | test_edgeql_insert_update_cross_type_conflict_14 | 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_update_cross_type_conflict_17(self):
await self.con.execute('''
create type T;
create type X {
create multi link l -> T {
create property x -> str { create constraint exclusive; }
};
};
create type Y extending X;
insert X;
insert Y;
''')
with self.assertRaisesRegex(
edgedb.UnsupportedFeatureError,
"do not support exclusive constraints on link properties"):
await self.con.execute('''
update X set { l := (insert T { @x := 'x' }) };
''') | )
with self.assertRaisesRegex(
edgedb.UnsupportedFeatureError,
"do not support exclusive constraints on link properties"):
await self.con.execute( | test_edgeql_insert_update_cross_type_conflict_17 | 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_and_delete_02(self):
# Assigning the result of a DELETE as a link during an INSERT
# should be an error.
await self.con.execute('''
INSERT Note { name := 'delete me' };
''')
with self.assertRaisesRegex(edgedb.ConstraintViolationError,
r"deletion of default::Note.+ is "
r"prohibited by link target policy"):
await self.con.execute('''
INSERT Person {
name := 'foo',
note := (
DELETE Note FILTER .name = 'delete me' LIMIT 1
)
}
''') | )
with self.assertRaisesRegex(edgedb.ConstraintViolationError,
r"deletion of default::Note.+ is "
r"prohibited by link target policy"):
await self.con.execute( | test_edgeql_insert_and_delete_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_explicit_id_06(self):
await self.con.execute('''
configure session set allow_user_specified_id := true
''')
async with self.assertRaisesRegexTx(
edgedb.MissingRequiredError,
"missing value for required property"
):
await self.con.execute(r'''
INSERT Person {
id := <optional uuid>{},
name := "test",
}
''') | )
async with self.assertRaisesRegexTx(
edgedb.MissingRequiredError,
"missing value for required property"
):
await self.con.execute(r | test_edgeql_insert_explicit_id_06 | 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_except_constraint_01(self):
# Test basic behavior of a constraint using except
await self.con.execute('''
insert ExceptTest { name := "foo" };
''')
async with self.assertRaisesRegexTx(
edgedb.ConstraintViolationError,
"violates exclusivity constraint"):
await self.con.execute('''
insert ExceptTest { name := "foo" };
''')
async with self.assertRaisesRegexTx(
edgedb.ConstraintViolationError,
"violates exclusivity constraint"):
await self.con.execute('''
insert ExceptTest { name := "foo", deleted := false };
''')
await self.con.execute('''
insert ExceptTest { name := "foo", deleted := true };
''')
await self.con.execute('''
insert ExceptTest { name := "bar", deleted := true };
''')
await self.con.execute('''
insert ExceptTest { name := "bar", deleted := true };
''')
await self.con.execute('''
insert ExceptTest { name := "bar" };
''')
async with self.assertRaisesRegexTx(
edgedb.ConstraintViolationError,
"violates exclusivity constraint"):
await self.con.execute('''
insert ExceptTest { name := "bar" };
''')
await self.con.execute('''
insert ExceptTest { name := "baz" };
''')
await self.con.execute('''
insert ExceptTestSub { name := "bar", deleted := true };
''')
# Now we are going to drop the constraint and then add it back in,
# nothing should error
await self.con.execute('''
alter type ExceptTest {
drop constraint exclusive on (.name) except (.deleted);
};
''')
await self.con.execute('''
alter type ExceptTest {
create constraint exclusive on (.name) except (.deleted);
};
''')
# Now drop it, and add something that *will* break, and recreate it
await self.con.execute('''
alter type ExceptTest {
drop constraint exclusive on (.name) except (.deleted);
};
''')
await self.con.execute('''
insert ExceptTestSub { name := "baz" };
''')
async with self.assertRaisesRegexTx(
edgedb.ConstraintViolationError,
"violates exclusivity constraint"):
await self.con.execute('''
alter type ExceptTest {
create constraint exclusive on (.name) except (.deleted);
};
''') | )
async with self.assertRaisesRegexTx(
edgedb.ConstraintViolationError,
"violates exclusivity constraint"):
await self.con.execute( | test_edgeql_insert_except_constraint_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_in_free_object_01(self):
await self.assert_query_result(
r"""
select {
obj := (
INSERT InsertTest {
name := 'insert simple 01',
l2 := 0,
}
)
}
""",
[{"obj": {"id": str}}],
)
await self.assert_query_result(
r"""
select {
obj := (
INSERT InsertTest {
name := 'insert simple 02',
l2 := 0,
}
) { name, l2 }
}
""",
[{"obj": {'name': "insert simple 02", 'l2': 0}}],
)
await self.assert_query_result(
r"""
select {
objs := (
for name in {'one', 'two'} union (
INSERT InsertTest {
name := name, l2 := 0,
}
)
)
}
""",
[{"objs": [{"id": str}, {"id": str}]}],
) | ,
[{"obj": {"id": str}}],
)
await self.assert_query_result(
r | test_edgeql_insert_in_free_object_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_in_free_object_02(self):
async with self.assertRaisesRegexTx(
edgedb.QueryError,
"mutations are invalid in a shape's computed expression"):
await self.con.query('''
select { foo := 1 } {
obj := (
INSERT InsertTest {
name := 'insert simple 02',
l2 := 0,
}
) { name, l2 }
}
''')
async with self.assertRaisesRegexTx(
edgedb.QueryError,
"mutations are invalid in a shape's computed expression"):
await self.con.query('''
select (for x in {1,2} union FreeObject) {
obj := (
INSERT InsertTest {
name := 'insert simple 01',
l2 := 0,
}
)
};
''')
async with self.assertRaisesRegexTx(
edgedb.QueryError,
"mutations are invalid in a shape's computed expression"):
await self.con.query('''
with X := {
obj := (
INSERT InsertTest {
name := 'insert simple 01',
l2 := 0,
}
)
}, select X;
''') | )
async with self.assertRaisesRegexTx(
edgedb.QueryError,
"mutations are invalid in a shape's computed expression"):
await self.con.query( | test_edgeql_insert_in_free_object_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_rebind_with_typenames_01(self):
await self.assert_query_result(
'''
with
update1 := (insert InsertTest {l2:=1}),
select (select update1);
''',
[{'id': str}],
always_typenames=True,
)
await self.assert_query_result(
'''
with
update1 := (insert InsertTest {l2:=1}),
select {update1};
''',
[{'id': str}],
always_typenames=True,
) | with
update1 := (insert InsertTest {l2:=1}),
select (select update1);
''',
[{'id': str}],
always_typenames=True,
)
await self.assert_query_result( | test_edgeql_insert_rebind_with_typenames_01 | python | geldata/gel | tests/test_edgeql_insert.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_insert.py | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.