code
stringlengths
26
870k
docstring
stringlengths
1
65.6k
func_name
stringlengths
1
194
language
stringclasses
1 value
repo
stringlengths
8
68
path
stringlengths
5
194
url
stringlengths
46
254
license
stringclasses
4 values
def test_edgeql_ir_card_inference_90(self): """ SELECT User { m := assert_distinct(assert_exists(Card)) } % OK % m: AT_LEAST_ONE """
SELECT User { m := assert_distinct(assert_exists(Card)) } % OK % m: AT_LEAST_ONE
test_edgeql_ir_card_inference_90
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_91(self): """ SELECT User { m := assert_distinct(assert_exists(assert_single(Card))) } % OK % m: ONE """
SELECT User { m := assert_distinct(assert_exists(assert_single(Card))) } % OK % m: ONE
test_edgeql_ir_card_inference_91
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_92(self): """ WITH inserted := (INSERT Award { name := <str>$0 }), all := (inserted UNION (SELECT Award)), SELECT DISTINCT (all { name }) ORDER BY .name ASC % OK % name: ONE """
WITH inserted := (INSERT Award { name := <str>$0 }), all := (inserted UNION (SELECT Award)), SELECT DISTINCT (all { name }) ORDER BY .name ASC % OK % name: ONE
test_edgeql_ir_card_inference_92
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_93(self): """ SELECT (User { friends: { required bs := .name } }, User.friends.name ?? 'a') % OK % MANY """
SELECT (User { friends: { required bs := .name } }, User.friends.name ?? 'a') % OK % MANY
test_edgeql_ir_card_inference_93
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_94(self): """ SELECT User { foo := enumerate(.name) } % OK % foo: ONE """
SELECT User { foo := enumerate(.name) } % OK % foo: ONE
test_edgeql_ir_card_inference_94
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_95(self): """ WITH x := User SELECT ( WITH y := x SELECT (y,).0 ) % OK % MANY """
WITH x := User SELECT ( WITH y := x SELECT (y,).0 ) % OK % MANY
test_edgeql_ir_card_inference_95
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_96(self): """ SELECT ( (SELECT User), (User,).0, ) % OK % MANY """
SELECT ( (SELECT User), (User,).0, ) % OK % MANY
test_edgeql_ir_card_inference_96
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_97(self): """ SELECT ( (User,).0, (User,).0, ) % OK % MANY """
SELECT ( (User,).0, (User,).0, ) % OK % MANY
test_edgeql_ir_card_inference_97
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_98(self): """ SELECT (Card.name ?? "N/A", Card.element ?? "N/A") % OK % AT_LEAST_ONE """
SELECT (Card.name ?? "N/A", Card.element ?? "N/A") % OK % AT_LEAST_ONE
test_edgeql_ir_card_inference_98
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_99(self): """ SELECT {1, 2} LIMIT 1 % OK % ONE """
SELECT {1, 2} LIMIT 1 % OK % ONE
test_edgeql_ir_card_inference_99
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_100(self): """ SELECT assert_exists(User) LIMIT 1 % OK % ONE """
SELECT assert_exists(User) LIMIT 1 % OK % ONE
test_edgeql_ir_card_inference_100
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_101(self): """ SELECT 1 LIMIT 0 % OK % AT_MOST_ONE """
SELECT 1 LIMIT 0 % OK % AT_MOST_ONE
test_edgeql_ir_card_inference_101
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_102(self): """ SELECT 1 LIMIT (SELECT count(User)) % OK % AT_MOST_ONE """
SELECT 1 LIMIT (SELECT count(User)) % OK % AT_MOST_ONE
test_edgeql_ir_card_inference_102
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_103(self): """ SELECT {1, 2} LIMIT (SELECT count(User)) % OK % MANY """
SELECT {1, 2} LIMIT (SELECT count(User)) % OK % MANY
test_edgeql_ir_card_inference_103
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_104(self): """ SELECT 1 OFFSET 2 % OK % AT_MOST_ONE """
SELECT 1 OFFSET 2 % OK % AT_MOST_ONE
test_edgeql_ir_card_inference_104
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_105(self): """ select User filter .avatar.name = 'Dragon' % OK % MANY """
select User filter .avatar.name = 'Dragon' % OK % MANY
test_edgeql_ir_card_inference_105
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_106(self): """ select User filter .unique_avatar.name = 'Dragon' % OK % AT_MOST_ONE """
select User filter .unique_avatar.name = 'Dragon' % OK % AT_MOST_ONE
test_edgeql_ir_card_inference_106
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_107(self): """ WITH __scope_0_Hero := DETACHED default::User UPDATE __scope_0_Hero FILTER (__scope_0_Hero.name = "Spider-Man") SET { name := ("The Amazing " ++ __scope_0_Hero.name) } % OK % AT_MOST_ONE """
WITH __scope_0_Hero := DETACHED default::User UPDATE __scope_0_Hero FILTER (__scope_0_Hero.name = "Spider-Man") SET { name := ("The Amazing " ++ __scope_0_Hero.name) } % OK % AT_MOST_ONE
test_edgeql_ir_card_inference_107
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_108(self): """ WITH __scope_0_Hero := DETACHED default::User SELECT __scope_0_Hero FILTER (__scope_0_Hero.name = "Spider-Man") % OK % AT_MOST_ONE """
WITH __scope_0_Hero := DETACHED default::User SELECT __scope_0_Hero FILTER (__scope_0_Hero.name = "Spider-Man") % OK % AT_MOST_ONE
test_edgeql_ir_card_inference_108
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_109(self): """ select User filter (detached (select User limit 1)).name = 'Alice' % OK % MANY """
select User filter (detached (select User limit 1)).name = 'Alice' % OK % MANY
test_edgeql_ir_card_inference_109
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_110(self): """ with z := (select User { asdf := .name }) select ( even := z.asdf, elements := count(z) ) % OK % MANY """
with z := (select User { asdf := .name }) select ( even := z.asdf, elements := count(z) ) % OK % MANY
test_edgeql_ir_card_inference_110
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_111(self): """ with z := (select User { asdf := {.name} }) select ( even := z.asdf, elements := count(z) ) % OK % MANY """
with z := (select User { asdf := {.name} }) select ( even := z.asdf, elements := count(z) ) % OK % MANY
test_edgeql_ir_card_inference_111
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_112(self): """ select <str>to_json('null') % OK % AT_MOST_ONE """
select <str>to_json('null') % OK % AT_MOST_ONE
test_edgeql_ir_card_inference_112
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_113(self): """ select <array<str>>[] % OK % ONE """
select <array<str>>[] % OK % ONE
test_edgeql_ir_card_inference_113
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_114(self): """ select 1 + (2 intersect 3) % OK % AT_MOST_ONE """
select 1 + (2 intersect 3) % OK % AT_MOST_ONE
test_edgeql_ir_card_inference_114
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_115(self): """ select 1 + (2 intersect {3, 4}) % OK % AT_MOST_ONE """
select 1 + (2 intersect {3, 4}) % OK % AT_MOST_ONE
test_edgeql_ir_card_inference_115
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_116(self): """ select 1 + ({2, 3} intersect {3, 4}) % OK % MANY """
select 1 + ({2, 3} intersect {3, 4}) % OK % MANY
test_edgeql_ir_card_inference_116
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_117(self): """ select 1 + ({2, 3} intersect <int64>{}) % OK % AT_MOST_ONE """
select 1 + ({2, 3} intersect <int64>{}) % OK % AT_MOST_ONE
test_edgeql_ir_card_inference_117
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_118(self): """ select 1 + (2 except 3) % OK % AT_MOST_ONE """
select 1 + (2 except 3) % OK % AT_MOST_ONE
test_edgeql_ir_card_inference_118
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_119(self): """ select 1 + (2 except {3, 4}) % OK % AT_MOST_ONE """
select 1 + (2 except {3, 4}) % OK % AT_MOST_ONE
test_edgeql_ir_card_inference_119
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_120(self): """ select 1 + ({2, 3} except {3, 4}) % OK % MANY """
select 1 + ({2, 3} except {3, 4}) % OK % MANY
test_edgeql_ir_card_inference_120
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_121(self): """ with X := {User, User}, select X filter .name = 'Alice' % OK % MANY """
with X := {User, User}, select X filter .name = 'Alice' % OK % MANY
test_edgeql_ir_card_inference_121
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_122(self): """ with X := {User, User}, update X filter .name = 'Alice' set { } % OK % MANY """
with X := {User, User}, update X filter .name = 'Alice' set { } % OK % MANY
test_edgeql_ir_card_inference_122
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_123(self): """ select Card { req_awards } % OK % req_awards: AT_LEAST_ONE """
select Card { req_awards } % OK % req_awards: AT_LEAST_ONE
test_edgeql_ir_card_inference_123
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_124(self): """ select Card { x := .req_awards } % OK % x: AT_LEAST_ONE """
select Card { x := .req_awards } % OK % x: AT_LEAST_ONE
test_edgeql_ir_card_inference_124
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_125(self): """ select Card { required x := .req_awards } % OK % x: AT_LEAST_ONE """
select Card { required x := .req_awards } % OK % x: AT_LEAST_ONE
test_edgeql_ir_card_inference_125
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_126(self): """ select Card { req_tags } % OK % req_tags: AT_LEAST_ONE """
select Card { req_tags } % OK % req_tags: AT_LEAST_ONE
test_edgeql_ir_card_inference_126
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_127(self): """ select Card { x := .req_tags } % OK % x: AT_LEAST_ONE """
select Card { x := .req_tags } % OK % x: AT_LEAST_ONE
test_edgeql_ir_card_inference_127
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_128(self): """ select Card { required x := .req_tags } % OK % x: AT_LEAST_ONE """
select Card { required x := .req_tags } % OK % x: AT_LEAST_ONE
test_edgeql_ir_card_inference_128
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_129(self): """ select assert(<bool>{}) % OK % AT_MOST_ONE """
select assert(<bool>{}) % OK % AT_MOST_ONE
test_edgeql_ir_card_inference_129
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_130(self): """ select assert(<bool>{}, message := {'uh', 'oh'}) % OK % MANY """
select assert(<bool>{}, message := {'uh', 'oh'}) % OK % MANY
test_edgeql_ir_card_inference_130
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_131(self): """ select assert(true, message := {'uh', 'oh'}) % OK % AT_LEAST_ONE """
select assert(true, message := {'uh', 'oh'}) % OK % AT_LEAST_ONE
test_edgeql_ir_card_inference_131
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_132(self): """ select distinct <str>{} % OK % AT_MOST_ONE """
select distinct <str>{} % OK % AT_MOST_ONE
test_edgeql_ir_card_inference_132
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_133(self): """ select distinct 1 % OK % ONE """
select distinct 1 % OK % ONE
test_edgeql_ir_card_inference_133
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_134(self): """ select distinct {1, 2} % OK % AT_LEAST_ONE """
select distinct {1, 2} % OK % AT_LEAST_ONE
test_edgeql_ir_card_inference_134
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_135(self): """ <str>{} if true else {'foo', 'bar'} % OK % MANY """
<str>{} if true else {'foo', 'bar'} % OK % MANY
test_edgeql_ir_card_inference_135
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_136(self): """ <str>{} if true else 'foo' % OK % AT_MOST_ONE """
<str>{} if true else 'foo' % OK % AT_MOST_ONE
test_edgeql_ir_card_inference_136
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_137(self): """ 'bar' if true else 'foo' % OK % ONE """
'bar' if true else 'foo' % OK % ONE
test_edgeql_ir_card_inference_137
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_138(self): """ assert_exists(1, message := {"uh", "oh"}) % OK % AT_LEAST_ONE """
assert_exists(1, message := {"uh", "oh"}) % OK % AT_LEAST_ONE
test_edgeql_ir_card_inference_138
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_139(self): """ if <bool>$0 then (insert User { name := "test" }) else (insert User { name := "???" }) % OK % ONE """
if <bool>$0 then (insert User { name := "test" }) else (insert User { name := "???" }) % OK % ONE
test_edgeql_ir_card_inference_139
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_140(self): """ if <bool>$0 then (insert User { name := "test" }) else {(insert User { name := "???" }), (insert User { name := "!!!" })} % OK % AT_LEAST_ONE """
if <bool>$0 then (insert User { name := "test" }) else {(insert User { name := "???" }), (insert User { name := "!!!" })} % OK % AT_LEAST_ONE
test_edgeql_ir_card_inference_140
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_141(self): """ if <bool>$0 then (insert User { name := "test" }) else <User>{} % OK % AT_MOST_ONE """
if <bool>$0 then (insert User { name := "test" }) else <User>{} % OK % AT_MOST_ONE
test_edgeql_ir_card_inference_141
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_142(self): """ select Named { [is Card].element } % OK % element: AT_MOST_ONE """
select Named { [is Card].element } % OK % element: AT_MOST_ONE
test_edgeql_ir_card_inference_142
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_143(self): """ select Named { element := [is Card].element } % OK % element: AT_MOST_ONE """
select Named { element := [is Card].element } % OK % element: AT_MOST_ONE
test_edgeql_ir_card_inference_143
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_144(self): """ select ( select assert_exists(Named) { [is Card].element } limit 1).element % OK % AT_MOST_ONE """
select ( select assert_exists(Named) { [is Card].element } limit 1).element % OK % AT_MOST_ONE
test_edgeql_ir_card_inference_144
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_145(self): """ select Named { [is Named].name } % OK % name: ONE """
select Named { [is Named].name } % OK % name: ONE
test_edgeql_ir_card_inference_145
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_146(self): """ select User { [is Named].name } % OK % name: ONE """
select User { [is Named].name } % OK % name: ONE
test_edgeql_ir_card_inference_146
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_147(self): """ select Named { [is User].name } """
select Named { [is User].name }
test_edgeql_ir_card_inference_147
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_148(self): """ select Named { name := [is User].name } """
select Named { name := [is User].name }
test_edgeql_ir_card_inference_148
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_149(self): """ select Named { [is schema::Object].name } """
select Named { [is schema::Object].name }
test_edgeql_ir_card_inference_149
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_150(self): """ select User { [is schema::Object].name } """
select User { [is schema::Object].name }
test_edgeql_ir_card_inference_150
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_151(self): # lnk has a *delegated* constraint """ select Tgt { back := .<lnk[is Src] } % OK % back: MANY """
select Tgt { back := .<lnk[is Src] } % OK % back: MANY
test_edgeql_ir_card_inference_151
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_152(self): """ select Tgt { back := .<lnk[is SrcSub1] } % OK % back: AT_MOST_ONE """
select Tgt { back := .<lnk[is SrcSub1] } % OK % back: AT_MOST_ONE
test_edgeql_ir_card_inference_152
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_153(self): # Constraint is delegated, shouldn't apply here """ select Named filter .name = '' % OK % MANY """
select Named filter .name = '' % OK % MANY
test_edgeql_ir_card_inference_153
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_154(self): # Constraint is delegated, shouldn't apply here """ select Named2 filter .name = '' % OK % MANY """
select Named2 filter .name = '' % OK % MANY
test_edgeql_ir_card_inference_154
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_155(self): # But should apply to this subtype """ select Named2Sub filter .name = '' % OK % AT_MOST_ONE """
select Named2Sub filter .name = '' % OK % AT_MOST_ONE
test_edgeql_ir_card_inference_155
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
def test_edgeql_ir_card_inference_156(self): """ select global Alice % OK % AT_MOST_ONE """
select global Alice % OK % AT_MOST_ONE
test_edgeql_ir_card_inference_156
python
geldata/gel
tests/test_edgeql_ir_card_inference.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_ir_card_inference.py
Apache-2.0
async def test_edgeql_fts_schema_language_01(self): await self.con.execute( ''' create scalar type MyLangs extending enum<English, PigLatin, Esperanto>; create type Doc1 { create required property x -> str; create index fts::index on ( fts::with_options(.x, language := MyLangs.English) ); }; create type Doc2 { create required property x -> str; }; ''' ) async with self.assertRaisesRegexTx( edgedb.UnsupportedFeatureError, "languages `esperanto`, `piglatin` not supported", ): # In this case, language is not a constant, so we fallback to all # possible values of the enum. This then fails because some of them # are not supported by postgres. await self.con.execute( """ alter type Doc2 create index fts::index on ( fts::with_options(.x, language := MyLangs.English if .x = 'blah' else MyLangs.PigLatin ) ); """ )
create scalar type MyLangs extending enum<English, PigLatin, Esperanto>; create type Doc1 { create required property x -> str; create index fts::index on ( fts::with_options(.x, language := MyLangs.English) ); }; create type Doc2 { create required property x -> str; };
test_edgeql_fts_schema_language_01
python
geldata/gel
tests/test_edgeql_fts_schema.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_fts_schema.py
Apache-2.0
async def test_edgeql_fts_schema_language_02(self): # test that adding an fts index, existing objects are also indexed await self.con.execute( ''' create type Doc { create required property x -> str; }; insert Doc { x := 'hello world' }; alter type Doc { create index fts::index on ( fts::with_options(.x, language := fts::Language.eng) ); }; ''' ) await self.assert_query_result( r''' select fts::search(Doc, 'world', language := 'eng').object.x; ''', ['hello world'], )
create type Doc { create required property x -> str; }; insert Doc { x := 'hello world' }; alter type Doc { create index fts::index on ( fts::with_options(.x, language := fts::Language.eng) ); };
test_edgeql_fts_schema_language_02
python
geldata/gel
tests/test_edgeql_fts_schema.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_fts_schema.py
Apache-2.0
async def test_edgeql_fts_schema_language_03(self): # Test adding an index to existing schema await self.con.execute( r""" start migration to { module default { type Text { required text0: str; required text1: str; required text2: str; required text3: str; required text4: str; required text5: str; required text6: str; } } }; populate migration; commit migration; """ ) await self.con.execute( ''' alter type default::Text { create index fts::index on (( fts::with_options(.text0, language := fts::Language.eng), fts::with_options(.text1, language := fts::Language.eng), fts::with_options(.text2, language := fts::Language.eng), fts::with_options(.text3, language := fts::Language.eng), fts::with_options(.text4, language := fts::Language.eng), fts::with_options(.text5, language := fts::Language.eng), fts::with_options(.text6, language := fts::Language.eng), )); } ''' ) # The search is actually valid now, even though there's nothing # there. await self.assert_query_result( r''' select fts::search( Text, 'something', language := 'eng' ) ''', [], )
) await self.con.execute(
test_edgeql_fts_schema_language_03
python
geldata/gel
tests/test_edgeql_fts_schema.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_fts_schema.py
Apache-2.0
async def test_edgeql_fts_schema_language_04(self): await self.con.execute( ''' create type Text { create required property text: str; create index fts::index on ( fts::with_options( .text, language := fts::Language.eng, weight_category := fts::Weight.A ) ); }; insert Text {text := 'Questo pane buonissimo'}; ''' ) # No result in Italian because it's indexed in English await self.assert_query_result( r''' select fts::search(Text, 'pane', language := 'ita').object.text; ''', [], ) await self.assert_query_result( r''' select fts::search(Text, 'pane', language := 'eng').object.text; ''', ['Questo pane buonissimo'], ) # Change the language and try again await self.con.execute( ''' alter type Text { drop index fts::index on ( fts::with_options( .text, language := fts::Language.eng, weight_category := fts::Weight.A ) ); }; alter type Text { create index fts::index on ( fts::with_options( .text, language := fts::Language.ita, weight_category := fts::Weight.A ) ); }; administer reindex(Text); ''' ) await self.assert_query_result( r''' select fts::search(Text, 'pane', language := 'ita').object.text; ''', ['Questo pane buonissimo'], ) await self.assert_query_result( r''' select fts::search(Text, 'pane', language := 'eng').object.text; ''', [], )
create type Text { create required property text: str; create index fts::index on ( fts::with_options( .text, language := fts::Language.eng, weight_category := fts::Weight.A ) ); }; insert Text {text := 'Questo pane buonissimo'};
test_edgeql_fts_schema_language_04
python
geldata/gel
tests/test_edgeql_fts_schema.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_fts_schema.py
Apache-2.0
async def test_edgeql_fts_schema_language_05(self): # test that adding/removing an fts index via inheritance, existing # objects are also indexed accordingly await self.con.execute( r''' create type Doc { create required property x -> str; }; insert Doc { x := 'hello world' }; # move the property to a Base type start migration to { module default { abstract type Base { required property x -> str; }; type Doc extending Base; } }; populate migration; commit migration; # Add an index on the Base type alter type Base { create index fts::index on ( fts::with_options(.x, language := fts::Language.eng) ); }; ''' ) await self.assert_query_result( r''' select fts::search(Doc, 'world', language := 'eng').object.x; ''', ['hello world'], ) # Remove the index await self.con.execute( r''' alter type Base { drop index fts::index on ( fts::with_options(.x, language := fts::Language.eng) ); }; ''' ) async with self.assertRaisesRegexTx( edgedb.InvalidReferenceError, r'std::fts::search\(\) requires an std::fts::index index', ): await self.con.execute( r''' select fts::search(Doc, 'world', language := 'eng').object.x; ''' )
) await self.assert_query_result( r
test_edgeql_fts_schema_language_05
python
geldata/gel
tests/test_edgeql_fts_schema.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_fts_schema.py
Apache-2.0
async def test_edgeql_fts_schema_weight_01(self): # Add and then change the weights on a couple of properties. await self.con.execute( r''' create type Doc { create required property a -> str; create required property b -> str; }; insert Doc { a := 'hello world', b := 'running fox', }; insert Doc { a := 'goodbye everyone', b := 'sleepy fox', }; alter type Doc { create index fts::index on (( fts::with_options( .a, language := fts::Language.eng, weight_category := fts::Weight.A, ), fts::with_options( .b, language := fts::Language.eng, weight_category := fts::Weight.A, ), )); }; ''' ) await self.assert_query_result( r''' with res := fts::search( Doc, 'hello world sleepy fox', language := 'eng' ) select res.object { a, b, } order by res.score desc; ''', [ {"a": "hello world", "b": "running fox"}, {"a": "goodbye everyone", "b": "sleepy fox"}, ], ) # Give props distinc categories. await self.con.execute( r''' alter type Doc { drop index fts::index on (( fts::with_options( .a, language := fts::Language.eng, weight_category := fts::Weight.A, ), fts::with_options( .b, language := fts::Language.eng, weight_category := fts::Weight.A, ), )); }; alter type Doc { create index fts::index on (( fts::with_options( .a, language := fts::Language.eng, weight_category := fts::Weight.A, ), fts::with_options( .b, language := fts::Language.eng, weight_category := fts::Weight.B, ), )); }; ''' ) await self.assert_query_result( r''' with res := fts::search( Doc, 'hello world sleepy fox', language := 'eng', weights := [0.1, 1], ) select res.object { a, b, } order by res.score desc; ''', [ {"a": "goodbye everyone", "b": "sleepy fox"}, {"a": "hello world", "b": "running fox"}, ], )
) await self.assert_query_result( r
test_edgeql_fts_schema_weight_01
python
geldata/gel
tests/test_edgeql_fts_schema.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_fts_schema.py
Apache-2.0
async def test_edgeql_fts_schema_weight_02(self): # Change inherited weights await self.con.execute( r''' create abstract type Base { create required property a -> str; create required property b -> str; }; create type Doc extending Base; insert Doc { a := 'hello world', b := 'running fox', }; insert Doc { a := 'goodbye everyone', b := 'sleepy fox', }; alter type Base { create index fts::index on (( fts::with_options( .a, language := fts::Language.eng, weight_category := fts::Weight.A, ), fts::with_options( .b, language := fts::Language.eng, weight_category := fts::Weight.A, ), )); }; ''' ) await self.assert_query_result( r''' with res := fts::search( Doc, 'hello world sleepy fox', language := 'eng' ) select res.object { a, b, } order by res.score desc; ''', [ {"a": "hello world", "b": "running fox"}, {"a": "goodbye everyone", "b": "sleepy fox"}, ], ) # Give props distinc categories. await self.con.execute( r''' alter type Base { drop index fts::index on (( fts::with_options( .a, language := fts::Language.eng, weight_category := fts::Weight.A, ), fts::with_options( .b, language := fts::Language.eng, weight_category := fts::Weight.A, ), )); }; alter type Base { create index fts::index on (( fts::with_options( .a, language := fts::Language.eng, weight_category := fts::Weight.A, ), fts::with_options( .b, language := fts::Language.eng, weight_category := fts::Weight.B, ), )); }; ''' ) await self.assert_query_result( r''' with res := fts::search( Doc, 'hello world sleepy fox', language := 'eng', weights := [0.1, 1], ) select res.object { a, b, } order by res.score desc; ''', [ {"a": "goodbye everyone", "b": "sleepy fox"}, {"a": "hello world", "b": "running fox"}, ], )
) await self.assert_query_result( r
test_edgeql_fts_schema_weight_02
python
geldata/gel
tests/test_edgeql_fts_schema.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_fts_schema.py
Apache-2.0
async def test_edgeql_fts_schema_weight_03(self): # Override inherited weights await self.con.execute( r''' create abstract type Base { create required property a -> str; create required property b -> str; create index fts::index on (( fts::with_options( .a, language := fts::Language.eng, weight_category := fts::Weight.A, ), fts::with_options( .b, language := fts::Language.eng, weight_category := fts::Weight.A, ), )); }; create type Doc extending Base; insert Doc { a := 'hello world', b := 'running fox', }; insert Doc { a := 'goodbye everyone', b := 'sleepy fox', }; ''' ) await self.assert_query_result( r''' with res := fts::search( Doc, 'hello world sleepy fox', language := 'eng', weights := [0.1, 1], ) select res.object { a, b, } order by res.score desc; ''', [ {"a": "hello world", "b": "running fox"}, {"a": "goodbye everyone", "b": "sleepy fox"}, ], ) # Override Doc to give props distinct categories. await self.con.execute( r''' alter type Doc { create index fts::index on (( fts::with_options( .a, language := fts::Language.eng, weight_category := fts::Weight.A, ), fts::with_options( .b, language := fts::Language.eng, weight_category := fts::Weight.B, ), )); }; ''' ) await self.assert_query_result( r''' with res := fts::search( Doc, 'hello world sleepy fox', language := 'eng', weights := [0.1, 1], ) select res.object { a, b, } order by res.score desc; ''', [ {"a": "goodbye everyone", "b": "sleepy fox"}, {"a": "hello world", "b": "running fox"}, ], )
) await self.assert_query_result( r
test_edgeql_fts_schema_weight_03
python
geldata/gel
tests/test_edgeql_fts_schema.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_fts_schema.py
Apache-2.0
async def test_edgeql_rewrites_01(self): # basic overriding of properties await self.con.execute( ''' alter type Movie { alter property title { create rewrite insert using ('inserted'); create rewrite update using ('updated'); }; }; ''' ) await self.con.execute('insert Movie { title:= "Whiplash" }') # title is required, but we don't specify it await self.con.execute('insert Movie { }') await self.assert_query_result( 'select Movie { title }', [{"title": "inserted"}, {"title": "inserted"}], ) await self.con.execute('update Movie set { title:= "The Godfather" }') await self.assert_query_result( 'select Movie { title }', [{"title": "updated"}, {"title": "updated"}], )
alter type Movie { alter property title { create rewrite insert using ('inserted'); create rewrite update using ('updated'); }; };
test_edgeql_rewrites_01
python
geldata/gel
tests/test_edgeql_rewrites.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_rewrites.py
Apache-2.0
async def test_edgeql_rewrites_02(self): await self.con.execute( ''' alter type Movie { alter property title { create rewrite insert using (.title); create rewrite update using (.title); }; }; ''' ) await self.con.execute('insert Movie { title := "Whiplash" }') await self.assert_query_result( 'select Movie { title }', [{"title": "Whiplash"}], ) async with self.assertRaisesRegexTx( edgedb.MissingRequiredError, r"missing value for required property" ): await self.con.execute('insert Movie { }') # if title is specified # __subject__.title refers to the new value await self.con.execute('update Movie set { title:= "The Godfather" }') await self.assert_query_result( 'select Movie { title }', [{"title": "The Godfather"}], ) # if title is not specified # __subject__.title refers to the existing value await self.con.execute('update Movie set { }') await self.assert_query_result( 'select Movie { title }', [{"title": "The Godfather"}], )
alter type Movie { alter property title { create rewrite insert using (.title); create rewrite update using (.title); }; };
test_edgeql_rewrites_02
python
geldata/gel
tests/test_edgeql_rewrites.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_rewrites.py
Apache-2.0
async def test_edgeql_rewrites_03(self): # interaction with default await self.con.execute( ''' alter type Movie { alter property title { create rewrite insert using (.title ++ ' (new)'); set default := 'untitled'; }; }; ''' ) await self.con.execute('insert Movie { title:= "Whiplash" }') await self.con.execute('insert Movie') await self.assert_query_result( 'select Movie { title }', [{"title": "Whiplash (new)"}, {"title": "untitled (new)"}], )
alter type Movie { alter property title { create rewrite insert using (.title ++ ' (new)'); set default := 'untitled'; }; };
test_edgeql_rewrites_03
python
geldata/gel
tests/test_edgeql_rewrites.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_rewrites.py
Apache-2.0
async def test_edgeql_rewrites_04(self): # __specified__ await self.con.execute( ''' alter type Content alter property title set optional; alter type Movie { create property title_specified: bool { create rewrite insert using (__specified__.title); }; }; ''' ) await self.con.execute('insert Movie { title:= "Whiplash" }') await self.con.execute('insert Movie') await self.assert_query_result( 'select Movie { title, title_specified }', [ {"title_specified": True}, {"title_specified": False}, ], )
alter type Content alter property title set optional; alter type Movie { create property title_specified: bool { create rewrite insert using (__specified__.title); }; };
test_edgeql_rewrites_04
python
geldata/gel
tests/test_edgeql_rewrites.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_rewrites.py
Apache-2.0
async def test_edgeql_rewrites_05(self): # Rewrites should also be applied to children types. await self.con.execute( ''' alter type Content { create property updated_at -> str { create rewrite update using ('just now'); }; }; ''' ) await self.con.execute('insert Movie { title:= "The Godfather" }') await self.assert_query_result( 'select Movie { title, updated_at }', [{"title": "The Godfather", "updated_at": None}], ) await self.con.execute( 'update Movie set { title:= "The Godfather II" }' ) await self.assert_query_result( 'select Movie { title, updated_at }', [{"title": "The Godfather II", "updated_at": "just now"}], )
alter type Content { create property updated_at -> str { create rewrite update using ('just now'); }; };
test_edgeql_rewrites_05
python
geldata/gel
tests/test_edgeql_rewrites.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_rewrites.py
Apache-2.0
async def test_edgeql_rewrites_06(self): # Rewrites override parent overrides. await self.con.execute( ''' alter type Content { alter property title { set optional; create rewrite update using (__subject__.title ++ ' - content updated'); }; }; alter type Movie { alter property title { create rewrite update using (__subject__.title ++ ' - movie updated'); }; }; ''' ) await self.con.execute('insert Movie { title:= "The Godfather" }') await self.con.execute('insert Content { title:= "Harry Potter" }') await self.con.execute('update Content set { title := .title }') await self.assert_query_result( 'select Content { title } order by .title', [ {"title": "Harry Potter - content updated"}, {"title": "The Godfather - movie updated"}, ], )
alter type Content { alter property title { set optional; create rewrite update using (__subject__.title ++ ' - content updated'); }; }; alter type Movie { alter property title { create rewrite update using (__subject__.title ++ ' - movie updated'); }; };
test_edgeql_rewrites_06
python
geldata/gel
tests/test_edgeql_rewrites.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_rewrites.py
Apache-2.0
async def test_edgeql_rewrites_07(self): await self.con.execute( ''' alter type Content alter property title set optional; alter type Movie { alter property title { create rewrite update using (__subject__.title ++ ' - updated'); }; }; ''' ) await self.con.execute('insert Movie { title:= "The Godfather" }') await self.con.execute('update Movie set { title:= "Whiplash" }') await self.assert_query_result( 'select Movie { title }', [{"title": "Whiplash - updated"}], ) await self.con.execute('update Movie set { }') await self.assert_query_result( 'select Movie { title }', [{"title": "Whiplash - updated - updated"}], )
alter type Content alter property title set optional; alter type Movie { alter property title { create rewrite update using (__subject__.title ++ ' - updated'); }; };
test_edgeql_rewrites_07
python
geldata/gel
tests/test_edgeql_rewrites.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_rewrites.py
Apache-2.0
async def test_edgeql_rewrites_08(self): # __old__ await self.con.execute( ''' alter type Movie { alter property title { create rewrite update using (__subject__.title ++ ' - ' ++ __old__.title); }; }; ''' ) await self.con.execute('insert Movie { title:= "Whiplash" }') await self.con.execute('update Movie set { title:= "The Godfather" }') await self.assert_query_result( 'select Movie { title }', [{"title": "The Godfather - Whiplash"}], ) await self.con.execute('update Movie set { }') await self.assert_query_result( 'select Movie { title }', [{"title": "The Godfather - Whiplash - The Godfather - Whiplash"}], ) async with self.assertRaisesRegexTx( edgedb.InvalidReferenceError, r"__old__ cannot be used in this expression" ): await self.con.execute( ''' alter type Movie { alter property title { create rewrite insert using (__old__.title); }; }; ''' )
alter type Movie { alter property title { create rewrite update using (__subject__.title ++ ' - ' ++ __old__.title); }; };
test_edgeql_rewrites_08
python
geldata/gel
tests/test_edgeql_rewrites.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_rewrites.py
Apache-2.0
async def test_edgeql_rewrites_09(self): # a common use case await self.con.execute( ''' alter type Content { create property title_updated -> str { set default := 'never'; create rewrite update using ( 'just now' if __specified__.title else __old__.title_updated ); }; }; ''' ) await self.con.execute('insert Content { title := "Harry Potter" }') await self.con.execute('insert Movie { title := "Whiplash" }') await self.con.execute( ''' insert Movie { title := "The Godfather", title_updated := "a long time ago" } ''' ) await self.assert_query_result( 'select Movie { title, title_updated } order by .title', [ {"title": "The Godfather", "title_updated": "a long time ago"}, {"title": "Whiplash", "title_updated": "never"}, ], ) await self.con.execute( ''' update Content filter .title = "Whiplash" set { title := "Up" } ''' ) await self.assert_query_result( 'select Movie { title, title_updated } order by .title', [ {"title": "The Godfather", "title_updated": "a long time ago"}, {"title": "Up", "title_updated": "just now"}, ], )
alter type Content { create property title_updated -> str { set default := 'never'; create rewrite update using ( 'just now' if __specified__.title else __old__.title_updated ); }; };
test_edgeql_rewrites_09
python
geldata/gel
tests/test_edgeql_rewrites.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_rewrites.py
Apache-2.0
async def test_edgeql_rewrites_10(self): # Rewrites need to obey the covariant check await self.con.execute('insert Movie { title:= "Whiplash" }') await self.con.execute( ''' create type Collection { create property name -> str; create link elements -> Content; }; create type Library extending Collection { alter link elements set type Book; }; alter type Collection { alter link elements { create rewrite update using ((select Content filter .title = 'Whiplash' limit 1)); }; }; ''' ) await self.con.execute('insert Library') async with self.assertRaisesRegexTx( edgedb.InvalidLinkTargetError, r"invalid target for link 'elements"): await self.con.execute('update Collection set { elements := {} }') async with self.assertRaisesRegexTx( edgedb.InvalidLinkTargetError, r"invalid target for link 'elements"): await self.con.execute('update Library set { elements := {} }') async with self.assertRaisesRegexTx( edgedb.InvalidLinkTargetError, r"invalid target for link 'elements"): await self.con.execute('update Collection set { name := "x" }') async with self.assertRaisesRegexTx( edgedb.InvalidLinkTargetError, r"invalid target for link 'elements"): await self.con.execute('update Library set { name := "x" }') async with self.assertRaisesRegexTx( edgedb.InvalidLinkTargetError, r"invalid target for link 'elements"): await self.con.execute('update Collection set { }') async with self.assertRaisesRegexTx( edgedb.InvalidLinkTargetError, r"invalid target for link 'elements"): await self.con.execute('update Library set { }')
create type Collection { create property name -> str; create link elements -> Content; }; create type Library extending Collection { alter link elements set type Book; }; alter type Collection { alter link elements { create rewrite update using ((select Content filter .title = 'Whiplash' limit 1)); }; };
test_edgeql_rewrites_10
python
geldata/gel
tests/test_edgeql_rewrites.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_rewrites.py
Apache-2.0
async def test_edgeql_rewrites_11(self): # Update triggers child overrides on unknown fields await self.con.execute( ''' alter type Movie { alter property release_year { create rewrite update using (__subject__.release_year + 1); }; }; ''' ) await self.con.execute(''' insert Movie { title := "The Godfather", release_year := 1972 } ''') await self.con.execute(''' update Content set { title := .title ++ "!"} ''') await self.assert_query_result( 'select Movie { title, release_year }', [ {"title": "The Godfather!", "release_year": 1973}, ], )
alter type Movie { alter property release_year { create rewrite update using (__subject__.release_year + 1); }; };
test_edgeql_rewrites_11
python
geldata/gel
tests/test_edgeql_rewrites.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_rewrites.py
Apache-2.0
async def test_edgeql_rewrites_12(self): # Update triggers child overrides on unknown fields # inherited from an unrelated base await self.con.execute( ''' create type Counted { create required property count -> int64 { set default := 0; create rewrite update using (__subject__.count + 1); } }; alter type Movie extending Counted; ''' ) await self.con.execute(''' insert Movie { title := "The Godfather" } ''') await self.con.execute(''' update Content set { title := .title ++ "!"} ''') await self.con.execute(''' update Content set { title := .title ++ "!"} ''') await self.assert_query_result( 'select Movie { title, count }', [ {"title": "The Godfather!!", "count": 2}, ], )
create type Counted { create required property count -> int64 { set default := 0; create rewrite update using (__subject__.count + 1); } }; alter type Movie extending Counted;
test_edgeql_rewrites_12
python
geldata/gel
tests/test_edgeql_rewrites.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_rewrites.py
Apache-2.0
async def test_edgeql_rewrites_13(self): await self.con.execute( ''' alter type Movie { alter property release_year { create rewrite insert using (__subject__.release_year + 1); create rewrite update using (__subject__.release_year + 1); }; create access policy ok allow all; create access policy no_even deny insert, update write using ((.release_year ?? 0) % 2 = 0); }; ''' ) async with self.assertRaisesRegexTx(edgedb.AccessPolicyError, ''): await self.con.execute(''' insert Movie { title := "The Godfather", release_year := 1971 }; ''') await self.con.execute(''' insert Movie { title := "The Godfather", release_year := 1972 }; ''') await self.assert_query_result( 'select Movie { title, release_year }', [ {"title": "The Godfather", "release_year": 1973}, ], ) async with self.assertRaisesRegexTx(edgedb.AccessPolicyError, ''): await self.con.execute(''' update Movie set { release_year := 101 }; ''') await self.con.execute(''' update Movie set { release_year := 100 }; ''') await self.assert_query_result( 'select Movie { title, release_year }', [ {"title": "The Godfather", "release_year": 101}, ], )
alter type Movie { alter property release_year { create rewrite insert using (__subject__.release_year + 1); create rewrite update using (__subject__.release_year + 1); }; create access policy ok allow all; create access policy no_even deny insert, update write using ((.release_year ?? 0) % 2 = 0); };
test_edgeql_rewrites_13
python
geldata/gel
tests/test_edgeql_rewrites.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_rewrites.py
Apache-2.0
async def test_edgeql_rewrites_14(self): await self.con.execute( ''' create type Foo { create property r -> float64; create property x -> float64 { create rewrite insert, update using (.r * 2); }; }; ''' ) await self.con.execute(''' insert Foo { r := random() }; ''') await self.assert_query_result( 'select Foo { z := (.r * 2 = .x) }', [ {"z": True}, ], ) await self.con.execute(''' update Foo set { r := random() }; ''') await self.assert_query_result( 'select Foo { z := (.r * 2 = .x) }', [ {"z": True}, ], )
create type Foo { create property r -> float64; create property x -> float64 { create rewrite insert, update using (.r * 2); }; };
test_edgeql_rewrites_14
python
geldata/gel
tests/test_edgeql_rewrites.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_rewrites.py
Apache-2.0
async def test_edgeql_rewrites_15(self): await self.con.execute(''' create type X { create property foo -> float64 { create rewrite insert, update using (random()) } }; ''') await self.con.execute(''' for _ in {1, 2} union (insert X); ''') await self.assert_query_result( 'select count(distinct X.foo);', [2], ) await self.con.execute(''' update X set {}; ''') await self.assert_query_result( 'select count(distinct X.foo);', [2], )
) await self.con.execute(
test_edgeql_rewrites_15
python
geldata/gel
tests/test_edgeql_rewrites.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_rewrites.py
Apache-2.0
async def test_edgeql_rewrites_16(self): await self.con.execute(''' create type X { create required property bar -> int64; create property foo -> float64 { create rewrite insert, update using (.bar + random()) } }; ''') await self.con.execute(''' for x in {1, 2} union (insert X { bar := x } ); ''') await self.assert_query_result( 'select math::floor(X.foo);', {1, 2}, ) await self.con.execute(''' for x in {1, 2} union ( update X filter .bar = x set { bar := x*2 } ); ''') await self.assert_query_result( 'select math::floor(X.foo);', {2, 4}, ) await self.assert_query_result( 'select count(distinct (X { z := .foo - math::floor(.foo) }).z)', [2], )
) await self.con.execute(
test_edgeql_rewrites_16
python
geldata/gel
tests/test_edgeql_rewrites.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_rewrites.py
Apache-2.0
async def test_edgeql_rewrites_17(self): # Test stuff that *references* multi properties check = 'select (S.sum, S.delta)' # XXX: I bet it doesn't work for defaults await self.con.execute(''' create type S { create multi property vals -> int64; create property sum -> int64 { create rewrite insert, update using (sum(.vals)) }; create property delta -> int64 { create rewrite insert using (sum(.vals)); create rewrite update using (sum(.vals) - sum(__old__.vals)) }; }; ''') await self.con.execute(''' insert S { vals := {1, 2, 3} } ''') await self.assert_query_result(check, [(6, 6)]) await self.con.execute(''' update S set { vals := {4, 5, 6} } ''') await self.assert_query_result(check, [(15, 9)]) await self.con.execute(''' update S set { vals += {3, 4} } ''') await self.assert_query_result(check, [(22, 7)]) await self.con.execute(''' update S set { vals -= 5 } ''') await self.assert_query_result(check, [(17, -5)])
) await self.con.execute(
test_edgeql_rewrites_17
python
geldata/gel
tests/test_edgeql_rewrites.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_rewrites.py
Apache-2.0
async def test_edgeql_rewrites_18(self): # Rewrites with DML in them await self.con.execute(''' create type Tgt { create property name -> str }; create type D { create property name -> str; create link t -> Tgt { create rewrite insert, update using ( insert Tgt { name := __subject__.name } ); }; }; ''') await self.con.execute(''' insert D { name := "foo" } ''') await self.con.execute(''' for x in {'bar', 'baz'} union ( insert D { name := x } ) ''') await self.assert_query_result( ''' select D { name, tname := .t.name } ''', tb.bag([ {'name': "foo", 'tname': "foo"}, {'name': "bar", 'tname': "bar"}, {'name': "baz", 'tname': "baz"}, ]), ) await self.con.execute(''' update D filter .name = 'foo' set { name := "spam" } ''') await self.con.execute(''' for x in {('bar', 'eggs'), ('baz', 'ham')} union ( update D filter .name = x.0 set { name := x.1 } ) ''') await self.assert_query_result( ''' select D { name, tname := .t.name } ''', tb.bag([ {'name': "spam", 'tname': "spam"}, {'name': "eggs", 'tname': "eggs"}, {'name': "ham", 'tname': "ham"}, ]), ) await self.con.execute(''' update D set { name := .name ++ "!" } ''') await self.assert_query_result( ''' select D { name, tname := .t.name } ''', tb.bag([ {'name': "spam!", 'tname': "spam!"}, {'name': "eggs!", 'tname': "eggs!"}, {'name': "ham!", 'tname': "ham!"}, ]), )
) await self.con.execute(
test_edgeql_rewrites_18
python
geldata/gel
tests/test_edgeql_rewrites.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_rewrites.py
Apache-2.0
async def test_edgeql_rewrites_19(self): # Rewrites with DML in them, and the DML has a chained rewrite await self.con.execute(''' create type Tgt { create property name -> str { create rewrite insert using (.name ++ '!') } }; create type D { create property name -> str; create link t -> Tgt { create rewrite insert, update using ( insert Tgt { name := __subject__.name } ); }; }; ''') await self.con.execute(''' insert D { name := "foo" } ''') await self.con.execute(''' for x in {'bar', 'baz'} union ( insert D { name := x } ) ''') await self.assert_query_result( ''' select D { name, tname := .t.name } ''', tb.bag([ {'name': "foo", 'tname': "foo!"}, {'name': "bar", 'tname': "bar!"}, {'name': "baz", 'tname': "baz!"}, ]), ) await self.con.execute(''' update D filter .name = 'foo' set { name := "spam" } ''') await self.con.execute(''' for x in {('bar', 'eggs'), ('baz', 'ham')} union ( update D filter .name = x.0 set { name := x.1 } ) ''') await self.assert_query_result( ''' select D { name, tname := .t.name } ''', tb.bag([ {'name': "spam", 'tname': "spam!"}, {'name': "eggs", 'tname': "eggs!"}, {'name': "ham", 'tname': "ham!"}, ]), ) await self.con.execute(''' update D set { name := .name ++ "!" } ''') await self.assert_query_result( ''' select D { name, tname := .t.name } ''', tb.bag([ {'name': "spam!", 'tname': "spam!!"}, {'name': "eggs!", 'tname': "eggs!!"}, {'name': "ham!", 'tname': "ham!!"}, ]), )
) await self.con.execute(
test_edgeql_rewrites_19
python
geldata/gel
tests/test_edgeql_rewrites.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_rewrites.py
Apache-2.0
async def test_edgeql_rewrites_20(self): async with self.assertRaisesRegexTx( edgedb.QueryError, r"rewrite rule cycle" ): await self.con.execute(''' create type Recursive; alter type Recursive { create link rec -> Recursive { create rewrite insert using (insert Recursive) } }; ''') async with self.assertRaisesRegexTx( edgedb.QueryError, r"rewrite rule cycle" ): await self.con.execute(''' create type Foo; create type Bar { create link rec -> Foo { create rewrite insert using (insert Foo) } }; alter type Foo { create link rec -> Bar { create rewrite insert using (insert Bar) } }; ''')
) async with self.assertRaisesRegexTx( edgedb.QueryError, r"rewrite rule cycle" ): await self.con.execute(
test_edgeql_rewrites_20
python
geldata/gel
tests/test_edgeql_rewrites.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_rewrites.py
Apache-2.0
async def test_edgeql_rewrites_21(self): await self.con.execute(''' create type Conflicted; alter type Conflicted { create property a -> str { create rewrite insert using ('nope') }; create constraint exclusive on (.a); }; create type SubConflicted extending Conflicted; ''') async with self.assertRaisesRegexTx( edgedb.UnsupportedFeatureError, r"INSERT UNLESS CONFLICT cannot be used on .* have a rewrite rule" ): await self.con.execute(''' INSERT Conflicted UNLESS CONFLICT ON (.a) ''') async with self.assertRaisesRegexTx( edgedb.UnsupportedFeatureError, r"INSERT UNLESS CONFLICT cannot be used on .* have a rewrite rule" ): await self.con.execute(''' INSERT Conflicted { a := 'hello' } UNLESS CONFLICT ON (.a) ''') async with self.assertRaisesRegexTx( edgedb.UnsupportedFeatureError, r"INSERT UNLESS CONFLICT cannot be used on .* have a rewrite rule" ): await self.con.execute(''' INSERT Conflicted { a := 'hello' } UNLESS CONFLICT ''')
) async with self.assertRaisesRegexTx( edgedb.UnsupportedFeatureError, r"INSERT UNLESS CONFLICT cannot be used on .* have a rewrite rule" ): await self.con.execute(
test_edgeql_rewrites_21
python
geldata/gel
tests/test_edgeql_rewrites.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_rewrites.py
Apache-2.0
async def test_edgeql_rewrites_22(self): await self.con.execute( ''' insert Project { name := ' hello ' }; ''' ) await self.assert_query_result( ''' select Project { name } ''', [ {'name': 'hello'}, ], ) await self.con.execute( ''' update Project set { name := ' world ' }; ''' ) await self.assert_query_result( ''' select Project { name } ''', [ {'name': 'world'}, ], ) await self.con.execute( ''' alter type Project { alter property name { create rewrite insert, update using ('hidden'); }; }; ''' ) await self.con.execute( ''' insert Project { name := ' hey ' }; ''' ) await self.assert_query_result( ''' select Project { name } ''', tb.bag( [ {'name': 'world'}, {'name': 'hidden'}, ] ), ) await self.con.execute( ''' update Project set { name := ' hoy ' }; ''' ) await self.assert_query_result( ''' select Project { name } ''', tb.bag( [ {'name': 'hidden'}, {'name': 'hidden'}, ] ), )
insert Project { name := ' hello ' };
test_edgeql_rewrites_22
python
geldata/gel
tests/test_edgeql_rewrites.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_rewrites.py
Apache-2.0
async def test_edgeql_rewrites_23(self): await self.con.execute( ''' alter type Person { alter property first_name { create rewrite update using ('updated'); }; }; insert Person { first_name := 'initial' }; ''' ) await self.assert_query_result( 'select Person { first_name }', [{'first_name': 'initial'}], ) await self.con.execute( ''' with A := Person update A set {}; ''' ) await self.assert_query_result( 'select Person { first_name }', [{'first_name': 'updated'}], )
alter type Person { alter property first_name { create rewrite update using ('updated'); }; }; insert Person { first_name := 'initial' };
test_edgeql_rewrites_23
python
geldata/gel
tests/test_edgeql_rewrites.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_rewrites.py
Apache-2.0
async def test_edgeql_rewrites_24(self): await self.con.execute( ''' create type X { create property tup -> tuple<int64, str> { create rewrite insert, update using ((1, '2')); }; }; insert X; ''' ) await self.assert_query_result( 'select X { tup }', [{'tup': (1, '2')}], ) await self.con.execute( ''' update X set {}; ''' ) await self.assert_query_result( 'select X { tup }', [{'tup': (1, '2')}], )
create type X { create property tup -> tuple<int64, str> { create rewrite insert, update using ((1, '2')); }; }; insert X;
test_edgeql_rewrites_24
python
geldata/gel
tests/test_edgeql_rewrites.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_rewrites.py
Apache-2.0
async def test_edgeql_rewrites_25(self): async with self.assertRaisesRegexTx( edgedb.SchemaDefinitionError, r"rewrite expression is of invalid type", ): await self.con.execute( ''' create type X { create property foo -> str { create rewrite insert using (10); }; }; ''' ) async with self.assertRaisesRegexTx( edgedb.SchemaDefinitionError, r"rewrite expression may not include a shape", ): await self.con.execute( ''' create type X { create link foo -> std::Object { create rewrite insert using ( (select std::Object { __type__: {name} }) ); }; }; ''' )
create type X { create property foo -> str { create rewrite insert using (10); }; };
test_edgeql_rewrites_25
python
geldata/gel
tests/test_edgeql_rewrites.py
https://github.com/geldata/gel/blob/master/tests/test_edgeql_rewrites.py
Apache-2.0