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 |
---|---|---|---|---|---|---|---|
async def test_edgeql_migration_describe_property_02(self):
# Migration that creates a type with property.
await self.con.execute('''
START MIGRATION TO {
module test {
type Type02 {
property field02 -> str;
};
};
};
''')
await self.assert_describe_migration({
'confirmed': [],
'complete': False,
'proposed': {
'statements': [{
'text': (
'CREATE TYPE test::Type02 {\n'
' CREATE PROPERTY field02'
': std::str;\n'
'};'
)
}],
'prompt': "did you create object type 'test::Type02'?",
},
})
# Auto-complete migration
await self.fast_forward_describe_migration()
res = await self.con.query('''
INSERT test::Type02 {
field02 := 'prop_test'
};
''')
# Migration that drops a property.
await self.con.execute('''
START MIGRATION TO {
module test {
type Type02;
};
};
''')
await self.assert_describe_migration({
'confirmed': [],
'complete': False,
'proposed': {
'statements': [{
'text': (
'ALTER TYPE test::Type02 {\n'
' DROP PROPERTY field02;\n'
'};'
)
}],
'prompt': (
"did you drop property 'field02'"
" of object type 'test::Type02'?"
),
},
})
# Auto-complete migration
await self.fast_forward_describe_migration()
await self.assert_query_result('''
SELECT test::Type02 {
id
};
''', [{
'id': res[0].id
}])
# Make sure that property dropped cleanly by re-creating and
# using the property again.
await self.con.execute('''
START MIGRATION TO {
module test {
type Type02 {
property field02 -> str;
};
};
};
''')
await self.assert_describe_migration({
'confirmed': [],
'complete': False,
'proposed': {
'statements': [{
'text': (
'ALTER TYPE test::Type02 {\n'
' CREATE PROPERTY field02'
': std::str;\n'
'};'
)
}],
'prompt': (
"did you create property 'field02'"
" of object type 'test::Type02'?"
),
},
})
# Auto-complete migration
await self.fast_forward_describe_migration()
await self.assert_query_result('''
SELECT test::Type02 {
id,
field02,
};
''', [{
'id': res[0].id,
'field02': None,
}]) | )
await self.assert_describe_migration({
'confirmed': [],
'complete': False,
'proposed': {
'statements': [{
'text': (
'CREATE TYPE test::Type02 {\n'
' CREATE PROPERTY field02'
': std::str;\n'
'};'
)
}],
'prompt': "did you create object type 'test::Type02'?",
},
})
# Auto-complete migration
await self.fast_forward_describe_migration()
res = await self.con.query( | test_edgeql_migration_describe_property_02 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_describe_link_01(self):
# Migration that renames a link.
await self.con.execute(r'''
START MIGRATION TO {
module test {
type Foo;
type Type01 {
link foo1 -> Foo;
};
};
};
# just initialize Foo, since we're interested in the other type
CREATE TYPE test::Foo;
''')
await self.assert_describe_migration({
'confirmed': ['CREATE TYPE test::Foo;'],
'complete': False,
'proposed': {
'statements': [{
'text': (
'CREATE TYPE test::Type01 {\n'
' CREATE LINK foo1'
': test::Foo;\n'
'};'
)
}],
'prompt': "did you create object type 'test::Type01'?",
},
})
# Auto-complete migration
await self.fast_forward_describe_migration()
res = await self.con.query('''
WITH MODULE test
SELECT (
INSERT Type01 {
foo1 := (INSERT Foo)
}
) {
foo1
};
''')
await self.con.execute('''
START MIGRATION TO {
module test {
type Foo;
type Type01 {
link foo01 -> Foo;
};
};
};
''')
await self.assert_describe_migration({
'confirmed': [],
'complete': False,
'proposed': {
'statements': [{
'text': (
'ALTER TYPE test::Type01 {\n'
' ALTER LINK foo1 {\n'
' RENAME TO foo01;\n'
' };\n'
'};'
)
}],
'prompt': (
"did you rename link 'foo1' of object type"
" 'test::Type01' to 'foo01'?"
),
},
})
# Auto-complete migration
await self.fast_forward_describe_migration()
await self.assert_query_result('''
SELECT test::Type01 {
foo01: {
id
}
};
''', [{'foo01': {'id': res[0].foo1.id}}]) | )
await self.assert_describe_migration({
'confirmed': ['CREATE TYPE test::Foo;'],
'complete': False,
'proposed': {
'statements': [{
'text': (
'CREATE TYPE test::Type01 {\n'
' CREATE LINK foo1'
': test::Foo;\n'
'};'
)
}],
'prompt': "did you create object type 'test::Type01'?",
},
})
# Auto-complete migration
await self.fast_forward_describe_migration()
res = await self.con.query( | test_edgeql_migration_describe_link_01 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_describe_link_02(self):
# Migration that creates a type with link.
await self.con.execute(r'''
START MIGRATION TO {
module test {
type Foo;
type Type02 {
link foo02 -> Foo;
};
};
};
# just initialize Foo, since we're interested in the other type
CREATE TYPE test::Foo;
''')
await self.assert_describe_migration({
'confirmed': ['CREATE TYPE test::Foo;'],
'complete': False,
'proposed': {
'statements': [{
'text': (
'CREATE TYPE test::Type02 {\n'
' CREATE LINK foo02'
': test::Foo;\n'
'};'
)
}],
'prompt': "did you create object type 'test::Type02'?",
},
})
# Auto-complete migration
await self.fast_forward_describe_migration()
res = await self.con.query('''
WITH MODULE test
SELECT (
INSERT Type02 {
foo02 := (INSERT Foo)
}
) {
foo02
}
''')
# Migration that drops a link.
await self.con.execute('''
START MIGRATION TO {
module test {
type Foo;
type Type02;
};
};
''')
await self.assert_describe_migration({
'confirmed': [],
'complete': False,
'proposed': {
'statements': [{
'text': (
'ALTER TYPE test::Type02 {\n'
' DROP LINK foo02;\n'
'};'
)
}],
'prompt': (
"did you drop link 'foo02' of object type 'test::Type02'?"
),
},
})
# Auto-complete migration
await self.fast_forward_describe_migration()
await self.assert_query_result('''
SELECT test::Type02 {
id
};
''', [{
'id': res[0].id
}])
await self.assert_query_result('''
SELECT test::Foo {
id
};
''', [{
'id': res[0].foo02.id
}])
# Make sure that link dropped cleanly by re-creating and
# using the link again.
await self.con.execute('''
START MIGRATION TO {
module test {
type Foo;
type Type02 {
link foo02 -> Foo;
};
};
};
''')
await self.assert_describe_migration({
'confirmed': [],
'complete': False,
'proposed': {
'statements': [{
'text': (
'ALTER TYPE test::Type02 {\n'
' CREATE LINK foo02'
': test::Foo;\n'
'};'
)
}],
'prompt': (
"did you create link 'foo02'"
" of object type 'test::Type02'?"
),
},
})
# Auto-complete migration
await self.fast_forward_describe_migration()
await self.assert_query_result('''
SELECT test::Type02 {
id,
foo02: {
id
},
};
''', [{
'id': res[0].id,
'foo02': None,
}]) | )
await self.assert_describe_migration({
'confirmed': ['CREATE TYPE test::Foo;'],
'complete': False,
'proposed': {
'statements': [{
'text': (
'CREATE TYPE test::Type02 {\n'
' CREATE LINK foo02'
': test::Foo;\n'
'};'
)
}],
'prompt': "did you create object type 'test::Type02'?",
},
})
# Auto-complete migration
await self.fast_forward_describe_migration()
res = await self.con.query( | test_edgeql_migration_describe_link_02 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_describe_link_03(self):
# Migration that renames a link.
await self.con.execute(r'''
START MIGRATION TO {
module test {
abstract link foo3;
};
};
''')
await self.assert_describe_migration({
'confirmed': [],
'complete': False,
'proposed': {
'statements': [{
'text': (
'CREATE ABSTRACT LINK test::foo3;'
)
}],
'prompt': "did you create abstract link 'test::foo3'?",
},
})
# Auto-complete migration
await self.fast_forward_describe_migration()
await self.con.execute('''
START MIGRATION TO {
module test {
abstract link foo03;
};
};
''')
await self.assert_describe_migration({
'confirmed': [],
'complete': False,
'proposed': {
'statements': [{
'text': (
'ALTER ABSTRACT LINK test::foo3 '
'RENAME TO test::foo03;'
)
}],
'prompt': (
"did you rename abstract link 'test::foo3' to "
"'test::foo03'?"
),
},
})
# Auto-complete migration
await self.fast_forward_describe_migration()
await self.con.execute('''
START MIGRATION TO {
module test {
};
};
''')
await self.assert_describe_migration({
'confirmed': [],
'complete': False,
'proposed': {
'statements': [{
'text': (
'DROP ABSTRACT LINK test::foo03;'
)
}],
'prompt': (
"did you drop abstract link 'test::foo03'?"
),
},
})
# Auto-complete migration
await self.fast_forward_describe_migration() | )
await self.assert_describe_migration({
'confirmed': [],
'complete': False,
'proposed': {
'statements': [{
'text': (
'CREATE ABSTRACT LINK test::foo3;'
)
}],
'prompt': "did you create abstract link 'test::foo3'?",
},
})
# Auto-complete migration
await self.fast_forward_describe_migration()
await self.con.execute( | test_edgeql_migration_describe_link_03 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_describe_index_01(self):
# Migration that creates index.
await self.con.execute(r'''
START MIGRATION TO {
module test {
type Foo {
property a -> int64;
};
};
};
''')
# Auto-complete migration
await self.fast_forward_describe_migration()
await self.con.execute('''
START MIGRATION TO {
module test {
type Foo {
property a -> int64;
index on (.a)
};
};
};
''')
await self.assert_describe_migration({
'confirmed': [],
'complete': False,
'proposed': {
'prompt': (
"did you create index on (.a) "
"of object type 'test::Foo'?"
)
}
}) | )
# Auto-complete migration
await self.fast_forward_describe_migration()
await self.con.execute( | test_edgeql_migration_describe_index_01 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_describe_index_02(self):
# Migration that drops index expression.
await self.con.execute(r'''
START MIGRATION TO {
module test {
type Foo {
property a -> int64;
index on (.a)
};
};
};
''')
# Auto-complete migration
await self.fast_forward_describe_migration()
await self.con.execute('''
START MIGRATION TO {
module test {
type Foo {
property a -> int64;
};
};
};
''')
await self.assert_describe_migration({
'confirmed': [],
'complete': False,
'proposed': {
'prompt': (
"did you drop index on (.a) "
"of object type 'test::Foo'?"
)
}
}) | )
# Auto-complete migration
await self.fast_forward_describe_migration()
await self.con.execute( | test_edgeql_migration_describe_index_02 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_describe_index_03(self):
# Migration that creates index on link property
await self.con.execute(r'''
START MIGRATION TO {
module test {
type Foo {
link bar -> Bar {
baz -> int64;
}
};
type Bar;
};
};
''')
# Auto-complete migration
await self.fast_forward_describe_migration()
await self.con.execute('''
START MIGRATION TO {
module test {
type Foo {
link bar -> Bar {
baz -> int64;
index on (@baz);
}
};
type Bar;
};
};
''')
await self.assert_describe_migration({
'confirmed': [],
'complete': False,
'proposed': {
'prompt': (
"did you create index on (@baz) "
"of link 'bar'?"
)
}
}) | )
# Auto-complete migration
await self.fast_forward_describe_migration()
await self.con.execute( | test_edgeql_migration_describe_index_03 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_describe_index_04(self):
# Migration that drops index on link property
await self.con.execute(r'''
START MIGRATION TO {
module test {
type Foo {
link bar -> Bar {
baz -> int64;
index on (@baz);
}
};
type Bar;
};
};
''')
# Auto-complete migration
await self.fast_forward_describe_migration()
await self.con.execute('''
START MIGRATION TO {
module test {
type Foo {
link bar -> Bar {
baz -> int64;
}
};
type Bar;
};
};
''')
await self.assert_describe_migration({
'confirmed': [],
'complete': False,
'proposed': {
'prompt': (
"did you drop index on (@baz) "
"of link 'bar'?"
)
}
}) | )
# Auto-complete migration
await self.fast_forward_describe_migration()
await self.con.execute( | test_edgeql_migration_describe_index_04 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_describe_index_05(self):
# Migration that creates index.
await self.con.execute('''
START MIGRATION TO {
module default {
type Foo {
property x -> int64;
index on (.x);
};
};
};
''')
# Auto-complete migration
await self.fast_forward_describe_migration()
await self.con.execute('''
START MIGRATION TO {
module default {
type Foo {
property y -> int64;
index on (.y);
};
};
};
''')
await self.interact([
("did you drop index on (.x) of object type 'default::Foo'?", "n"),
"did you rename property 'x' of object type 'default::Foo' to 'y'?",
]) | )
# Auto-complete migration
await self.fast_forward_describe_migration()
await self.con.execute( | test_edgeql_migration_describe_index_05 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_describe_scalar_01(self):
# Migration that renames a type.
await self.con.execute('''
START MIGRATION TO {
module test {
scalar type ScalarType1 extending int64;
};
};
''')
await self.assert_describe_migration({
'confirmed': [],
'complete': False,
'proposed': {
'statements': [{
'text': (
'CREATE SCALAR TYPE test::ScalarType1'
' EXTENDING std::int64;'
)
}],
'prompt': "did you create scalar type 'test::ScalarType1'?",
},
})
# Auto-complete migration
await self.fast_forward_describe_migration()
await self.assert_query_result('''
SELECT <test::ScalarType1>'1' + 2;
''', [3])
await self.con.execute('''
START MIGRATION TO {
module test {
scalar type ScalarType01 extending int64;
};
};
''')
await self.assert_describe_migration({
'confirmed': [],
'complete': False,
'proposed': {
'statements': [{
'text': (
'ALTER SCALAR TYPE test::ScalarType1'
' RENAME TO test::ScalarType01;'
)
}],
'prompt': (
"did you rename scalar type 'test::ScalarType1' to "
"'test::ScalarType01'?"
),
},
})
# Auto-complete migration
await self.fast_forward_describe_migration()
await self.assert_query_result('''
SELECT <test::ScalarType01>'2' + 1;
''', [3]) | )
await self.assert_describe_migration({
'confirmed': [],
'complete': False,
'proposed': {
'statements': [{
'text': (
'CREATE SCALAR TYPE test::ScalarType1'
' EXTENDING std::int64;'
)
}],
'prompt': "did you create scalar type 'test::ScalarType1'?",
},
})
# Auto-complete migration
await self.fast_forward_describe_migration()
await self.assert_query_result( | test_edgeql_migration_describe_scalar_01 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_describe_scalar_02(self):
# Migration that creates a type.
await self.con.execute('''
START MIGRATION TO {
module test {
scalar type ScalarType02 extending str;
};
};
''')
await self.assert_describe_migration({
'confirmed': [],
'complete': False,
'proposed': {
'statements': [{
'text': (
'CREATE SCALAR TYPE test::ScalarType02'
' EXTENDING std::str;'
)
}],
'prompt': "did you create scalar type 'test::ScalarType02'?",
},
})
# Auto-complete migration
await self.fast_forward_describe_migration()
await self.assert_query_result('''
SELECT <test::ScalarType02>1 ++ '2';
''', ['12'])
# Migration that drops a type.
await self.con.execute('''
START MIGRATION TO {
module test {
};
};
''')
await self.assert_describe_migration({
'confirmed': [],
'complete': False,
'proposed': {
'statements': [{
'text': (
'DROP SCALAR TYPE test::ScalarType02;'
)
}],
'prompt': (
"did you drop scalar type 'test::ScalarType02'?"
),
},
})
# Auto-complete migration
await self.fast_forward_describe_migration()
await self.assert_query_result('''
WITH MODULE schema
SELECT ScalarType
FILTER .name = 'test::ScalarType02';
''', [])
# Make sure that type dropped cleanly by re-creating and
# using the type again.
await self.con.execute('''
START MIGRATION TO {
module test {
scalar type ScalarType02 extending str;
};
};
''')
await self.assert_describe_migration({
'confirmed': [],
'complete': False,
'proposed': {
'statements': [{
'text': (
'CREATE SCALAR TYPE test::ScalarType02'
' EXTENDING std::str;'
)
}],
'prompt': "did you create scalar type 'test::ScalarType02'?",
},
})
# Auto-complete migration
await self.fast_forward_describe_migration()
await self.assert_query_result('''
SELECT <test::ScalarType02>2 ++ '1';
''', ['21']) | )
await self.assert_describe_migration({
'confirmed': [],
'complete': False,
'proposed': {
'statements': [{
'text': (
'CREATE SCALAR TYPE test::ScalarType02'
' EXTENDING std::str;'
)
}],
'prompt': "did you create scalar type 'test::ScalarType02'?",
},
})
# Auto-complete migration
await self.fast_forward_describe_migration()
await self.assert_query_result( | test_edgeql_migration_describe_scalar_02 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_describe_enum_01(self):
# Migration that renames an enum.
await self.con.execute('''
START MIGRATION TO {
module test {
scalar type EnumType1 extending enum<foo, bar>;
};
};
''')
await self.assert_describe_migration({
'confirmed': [],
'complete': False,
'proposed': {
'statements': [{
'text': (
"CREATE SCALAR TYPE test::EnumType1"
" EXTENDING enum<foo, bar>;"
)
}],
'prompt': "did you create scalar type 'test::EnumType1'?",
},
})
# Auto-complete migration
await self.fast_forward_describe_migration()
await self.assert_query_result('''
SELECT <test::EnumType1>'bar';
''', ['bar'])
await self.con.execute('''
START MIGRATION TO {
module test {
scalar type EnumType01 extending enum<foo, bar>;
};
};
''')
await self.assert_describe_migration({
'confirmed': [],
'complete': False,
'proposed': {
'statements': [{
'text': (
'ALTER SCALAR TYPE test::EnumType1'
' RENAME TO test::EnumType01;'
)
}],
'prompt': (
"did you rename scalar type 'test::EnumType1' to "
"'test::EnumType01'?"
),
},
})
# Auto-complete migration
await self.fast_forward_describe_migration()
await self.assert_query_result('''
SELECT <test::EnumType01>'foo';
''', ['foo']) | )
await self.assert_describe_migration({
'confirmed': [],
'complete': False,
'proposed': {
'statements': [{
'text': (
"CREATE SCALAR TYPE test::EnumType1"
" EXTENDING enum<foo, bar>;"
)
}],
'prompt': "did you create scalar type 'test::EnumType1'?",
},
})
# Auto-complete migration
await self.fast_forward_describe_migration()
await self.assert_query_result( | test_edgeql_migration_describe_enum_01 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_describe_enum_02(self):
# Migration that creates an enum.
await self.con.execute('''
START MIGRATION TO {
module test {
scalar type EnumType02 extending enum<foo, bar>;
};
};
''')
await self.assert_describe_migration({
'confirmed': [],
'complete': False,
'proposed': {
'statements': [{
'text': (
"CREATE SCALAR TYPE test::EnumType02"
" EXTENDING enum<foo, bar>;"
)
}],
'prompt': "did you create scalar type 'test::EnumType02'?",
},
})
# Auto-complete migration
await self.fast_forward_describe_migration()
await self.assert_query_result('''
SELECT <test::EnumType02>'bar';
''', ['bar'])
# Migration that drops an enum.
await self.con.execute('''
START MIGRATION TO {
module test {
};
};
''')
await self.assert_describe_migration({
'confirmed': [],
'complete': False,
'proposed': {
'statements': [{
'text': (
'DROP SCALAR TYPE test::EnumType02;'
)
}],
'prompt': (
"did you drop scalar type 'test::EnumType02'?"
),
},
})
# Auto-complete migration
await self.fast_forward_describe_migration()
await self.assert_query_result('''
WITH MODULE schema
SELECT ScalarType
FILTER .name = 'test::EnumType02';
''', [])
# Make sure that enum dropped cleanly by re-creating and
# using the enum again.
await self.con.execute('''
START MIGRATION TO {
module test {
scalar type EnumType02 extending enum<foo, bar>;
};
};
''')
await self.assert_describe_migration({
'confirmed': [],
'complete': False,
'proposed': {
'statements': [{
'text': (
"CREATE SCALAR TYPE test::EnumType02"
" EXTENDING enum<foo, bar>;"
)
}],
'prompt': "did you create scalar type 'test::EnumType02'?",
},
})
# Auto-complete migration
await self.fast_forward_describe_migration()
await self.assert_query_result('''
SELECT <test::EnumType02>'foo';
''', ['foo']) | )
await self.assert_describe_migration({
'confirmed': [],
'complete': False,
'proposed': {
'statements': [{
'text': (
"CREATE SCALAR TYPE test::EnumType02"
" EXTENDING enum<foo, bar>;"
)
}],
'prompt': "did you create scalar type 'test::EnumType02'?",
},
})
# Auto-complete migration
await self.fast_forward_describe_migration()
await self.assert_query_result( | test_edgeql_migration_describe_enum_02 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_describe_annotation_01(self):
# Migration that renames an annotation.
await self.migrate('''
abstract annotation my_anno1;
''')
await self.con.execute('''
START MIGRATION TO {
module test {
abstract annotation renamed_anno1;
};
};
''')
await self.assert_describe_migration({
'confirmed': [],
'complete': False,
'proposed': {
'statements': [{
'text': (
'ALTER ABSTRACT ANNOTATION test::my_anno1 '
'RENAME TO test::renamed_anno1;'
)
}],
},
}) | )
await self.con.execute( | test_edgeql_migration_describe_annotation_01 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_describe_annotation_02(self):
# Migration that creates an annotation.
await self.con.execute('''
START MIGRATION TO {
module test {
abstract annotation my_anno2;
type AnnoType2 {
annotation my_anno2 := 'test_my_anno2';
}
};
};
''')
await self.con.execute('''
CREATE TYPE test::AnnoType2;
''')
await self.assert_describe_migration({
'confirmed': [
'CREATE TYPE test::AnnoType2;'
],
'complete': False,
'proposed': {
'statements': [{
'text': (
'CREATE ABSTRACT ANNOTATION test::my_anno2;'
)
}],
},
})
# Auto-complete migration
await self.fast_forward_describe_migration()
# Migration that drops an annotation.
await self.con.execute('''
START MIGRATION TO {
module test {
type AnnoType2;
};
};
''')
await self.assert_describe_migration({
'confirmed': [],
'complete': False,
'proposed': {
'statements': [{
'text': (
'ALTER TYPE test::AnnoType2 {\n'
' DROP ANNOTATION test::my_anno2;\n'
'};'
)
}],
},
})
# Auto-complete migration
await self.con.execute('''
ALTER TYPE test::AnnoType2 {
DROP ANNOTATION test::my_anno2;
};
''')
await self.assert_describe_migration({
'complete': False,
'proposed': {
'statements': [{
'text': (
'DROP ABSTRACT ANNOTATION test::my_anno2;'
)
}],
},
})
# Auto-complete migration
await self.fast_forward_describe_migration()
# Make sure that annotation dropped cleanly by re-creating and
# using the annotation.
await self.con.execute('''
START MIGRATION TO {
module test {
abstract annotation my_anno2;
type AnnoType2 {
annotation my_anno2 := 'retest_my_anno2';
}
};
};
''')
await self.assert_describe_migration({
'confirmed': [],
'complete': False,
'proposed': {
'statements': [{
'text': (
'CREATE ABSTRACT ANNOTATION test::my_anno2;'
)
}],
},
})
# Auto-complete migration
await self.fast_forward_describe_migration()
await self.assert_query_result(
r"""
WITH MODULE schema
SELECT ObjectType {
name,
annotations: {
name,
@value,
},
} FILTER .name = 'test::AnnoType2';
""",
[{
'name': 'test::AnnoType2',
'annotations': [{
'name': 'test::my_anno2',
'@value': 'retest_my_anno2',
}]
}],
) | )
await self.con.execute( | test_edgeql_migration_describe_annotation_02 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_describe_constraint_01(self):
# Migration that renames a constraint.
await self.migrate('''
abstract constraint my_oneof(one_of: array<anytype>) {
using (contains(one_of, __subject__));
};
type Foo {
property note -> str {
constraint my_oneof(["foo", "bar"]);
}
}
''')
await self.con.execute('''
START MIGRATION TO {
module test {
abstract constraint my_one_of(one_of: array<anytype>) {
using (contains(one_of, __subject__));
};
type Foo {
property note -> str {
constraint my_one_of(["foo", "bar"]);
}
}
};
};
''')
await self.assert_describe_migration({
'confirmed': [],
'complete': False,
'proposed': {
'statements': [{
'text': (
'ALTER ABSTRACT CONSTRAINT test::my_oneof '
'RENAME TO test::my_one_of;'
)
}],
},
})
await self.fast_forward_describe_migration() | )
await self.con.execute( | test_edgeql_migration_describe_constraint_01 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_describe_constraint_02(self):
# Migration that renames a link constraint.
# Honestly I'm not sure if link constraints can really be
# anything other than exclusive?
await self.migrate('''
abstract constraint my_exclusive() extending std::exclusive;
type Foo;
type Bar {
link foo -> Foo {
constraint my_exclusive;
}
}
''')
await self.con.execute('''
START MIGRATION TO {
module test {
abstract constraint myexclusive() extending std::exclusive;
type Foo;
type Bar {
link foo -> Foo {
constraint myexclusive;
}
}
};
};
''')
await self.assert_describe_migration({
'confirmed': [],
'complete': False,
'proposed': {
'statements': [{
'text': (
'ALTER ABSTRACT CONSTRAINT test::my_exclusive '
'RENAME TO test::myexclusive;'
)
}],
},
})
await self.fast_forward_describe_migration() | )
await self.con.execute( | test_edgeql_migration_describe_constraint_02 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_describe_constraint_03(self):
# Migration that renames a object constraint.
await self.migrate('''
abstract constraint my_oneof(one_of: array<anytype>) {
using (contains(one_of, __subject__));
};
type Foo {
property a -> str;
property b -> str;
constraint my_oneof(["foo", "bar"])
ON (__subject__.a++__subject__.b);
}
''')
await self.con.execute('''
START MIGRATION TO {
module test {
abstract constraint my_one_of(one_of: array<anytype>) {
using (contains(one_of, __subject__));
};
type Foo {
property a -> str;
property b -> str;
constraint my_one_of(["foo", "bar"])
ON (__subject__.a++__subject__.b);
}
};
};
''')
await self.assert_describe_migration({
'confirmed': [],
'complete': False,
'proposed': {
'statements': [{
'text': (
'ALTER ABSTRACT CONSTRAINT test::my_oneof '
'RENAME TO test::my_one_of;'
)
}],
},
})
await self.fast_forward_describe_migration() | )
await self.con.execute( | test_edgeql_migration_describe_constraint_03 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_describe_constraint_04(self):
# Migration that creates a constraint.
await self.con.execute('''
START MIGRATION TO {
module test {
abstract constraint my_one_of(one_of: array<anytype>) {
using (contains(one_of, __subject__));
};
scalar type my_str extending str {
constraint my_one_of(['my', 'str']);
};
};
};
''')
await self.con.execute('''
CREATE SCALAR TYPE test::my_str EXTENDING std::str;
''')
await self.assert_describe_migration({
'confirmed': [
'CREATE SCALAR TYPE test::my_str EXTENDING std::str;'
],
'complete': False,
'proposed': {
'statements': [{
'text': (
'CREATE ABSTRACT CONSTRAINT test::my_one_of('
'one_of: array<anytype>) {\n'
' USING (std::contains(one_of, __subject__));\n'
'};'
),
}],
},
})
# Auto-complete migration
await self.fast_forward_describe_migration()
await self.con.query('DECLARE SAVEPOINT migration_01')
await self.assert_query_result(
r"""
SELECT <test::my_str>'my';
""",
['my'],
)
with self.assertRaisesRegex(
edgedb.ConstraintViolationError,
r"invalid my_str"):
await self.con.execute(r"""
SELECT <test::my_str>'nope';
""")
await self.con.query('ROLLBACK TO SAVEPOINT migration_01')
# Migration that drops a constraint.
await self.con.execute('''
START MIGRATION TO {
module test {
scalar type my_str extending str;
};
};
''')
await self.assert_describe_migration({
'confirmed': [],
'complete': False,
'proposed': {
'statements': [{
'text': (
"ALTER SCALAR TYPE test::my_str {\n"
" DROP CONSTRAINT test::my_one_of(['my', 'str']);\n"
"};"
),
}],
},
})
# Auto-complete migration
await self.fast_forward_describe_migration()
await self.assert_query_result(
r"""
SELECT <test::my_str>'my';
""",
['my'],
)
await self.assert_query_result(
r"""
SELECT <test::my_str>'nope';
""",
['nope'],
)
# Test that dropping constraint was clean with a migration
# that re-creates a constraint.
await self.con.execute('''
START MIGRATION TO {
module test {
abstract constraint my_one_of(one_of: array<anytype>) {
using (contains(one_of, __subject__));
};
scalar type my_str extending str {
constraint my_one_of(['my2', 'str2']);
};
};
};
''')
await self.assert_describe_migration({
'confirmed': [],
'complete': False,
'proposed': {
'statements': [{
'text': (
'CREATE ABSTRACT CONSTRAINT '
'test::my_one_of(one_of: array<anytype>) {\n'
' USING (std::contains(one_of, __subject__));\n'
'};'
),
}],
},
})
# Auto-complete migration
await self.fast_forward_describe_migration()
await self.assert_query_result(
r"""
SELECT <test::my_str>'my2';
""",
['my2'],
)
with self.assertRaisesRegex(
edgedb.ConstraintViolationError,
r"invalid my_str"):
await self.con.execute(r"""
SELECT <test::my_str>'my';
""") | )
await self.con.execute( | test_edgeql_migration_describe_constraint_04 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_describe_abs_ptr_01(self):
await self.migrate('''
abstract link abs_link;
''')
await self.con.execute('''
START MIGRATION TO {
module test {
abstract link new_abs_link;
};
};
''')
await self.assert_describe_migration({
'confirmed': [],
'complete': False,
'proposed': {
'statements': [{
'text': (
'ALTER ABSTRACT LINK test::abs_link '
'RENAME TO test::new_abs_link;'
)
}],
},
}) | )
await self.con.execute( | test_edgeql_migration_describe_abs_ptr_01 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_abs_ptr_01(self):
await self.migrate(r"""
type T { multi link following := T; }
""")
await self.migrate(r"""
abstract link abs { property foo: str };
type T { multi link following extending abs -> T; }
""") | )
await self.migrate(r | test_edgeql_migration_abs_ptr_01 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_describe_function_01(self):
await self.migrate('''
function foo(x: str) -> str using (SELECT <str>random());
''')
await self.con.execute('''
START MIGRATION TO {
module test {
function bar(x: str) -> str using (SELECT <str>random());
};
};
''')
await self.assert_describe_migration({
'confirmed': [],
'complete': False,
'proposed': {
'statements': [{
'text': (
'ALTER FUNCTION test::foo(x: std::str) '
'{RENAME TO test::bar;};'
)
}],
},
}) | )
await self.con.execute( | test_edgeql_migration_describe_function_01 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_function_02(self):
await self.migrate('''
type Foo;
function foo(x: Foo) -> int64 {
USING (SELECT 0)
}
''')
await self.migrate('''
type Bar;
function foo(x: Bar) -> int64 {
USING (SELECT 0)
}
''')
await self.con.execute('''
DROP FUNCTION test::foo(x: test::Bar);
''') | )
await self.migrate( | test_edgeql_migration_function_02 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_function_03(self):
await self.migrate('''
type Foo;
function foo(x: Foo) -> int64 {
USING (SELECT 0)
}
''')
await self.migrate('''
type Bar;
function foo2(x: Bar) -> int64 {
USING (SELECT 0)
}
''')
await self.con.execute('''
DROP FUNCTION test::foo2(x: test::Bar);
''') | )
await self.migrate( | test_edgeql_migration_function_03 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_function_04(self):
await self.migrate('''
function foo() -> str USING ('foo');
''')
await self.start_migration('''
function foo() -> str USING ('bar');
''')
await self.interact([
"did you alter function 'test::foo'?"
])
await self.fast_forward_describe_migration()
await self.assert_query_result(
r"""
SELECT test::foo()
""",
["bar"],
) | )
await self.start_migration( | test_edgeql_migration_function_04 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_constraint_01(self):
await self.migrate('''
abstract constraint not_bad {
using (__subject__ != "bad" and __subject__ != "terrible")
}
type Foo {
property foo -> str {
constraint not_bad;
}
}
type Bar extending Foo;
''')
await self.start_migration('''
abstract constraint not_bad {
using (__subject__ != "bad" and __subject__ != "awful")
}
type Foo {
property foo -> str {
constraint not_bad;
}
}
type Bar extending Foo;
''')
await self.interact([
"did you alter abstract constraint 'test::not_bad'?"
])
await self.fast_forward_describe_migration()
async with self.assertRaisesRegexTx(
edgedb.ConstraintViolationError,
"invalid foo",
):
await self.con.execute(r"""
INSERT test::Foo { foo := "awful" };
""") | )
await self.start_migration( | test_edgeql_migration_constraint_01 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_describe_type_rename_01(self):
await self.migrate('''
type Foo;
type Baz {
link l -> Foo;
};
''')
await self.con.execute('''
START MIGRATION TO {
module test {
type Bar;
type Baz {
link l -> Bar;
};
}
};
POPULATE MIGRATION;
''')
await self.assert_describe_migration({
'complete': True,
'confirmed': [
'ALTER TYPE test::Foo RENAME TO test::Bar;'
],
})
await self.fast_forward_describe_migration() | )
await self.con.execute( | test_edgeql_migration_describe_type_rename_01 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_computed_01(self):
await self.migrate(r'''
type Foo {
property val -> str;
property comp := count((
# Use an alias in WITH block in a computable
WITH x := .val
# Use an alias in SELECT in a computable
SELECT y := Bar FILTER x = y.val
))
}
type Bar {
property val -> str;
}
''')
await self.con.execute("""
SET MODULE test;
INSERT Foo {val := 'c'};
INSERT Foo {val := 'd'};
INSERT Bar {val := 'a'};
INSERT Bar {val := 'b'};
INSERT Bar {val := 'c'};
INSERT Bar {val := 'c'};
""")
await self.assert_query_result(
r"""
SELECT Foo {
val,
comp,
} ORDER BY .val;
""",
[{
'val': 'c',
'comp': 2,
}, {
'val': 'd',
'comp': 0,
}],
) | )
await self.con.execute( | test_edgeql_migration_computed_01 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_computed_02(self):
await self.migrate(r'''
type Foo { property foo := '1' };
type Bar extending Foo;
''')
await self.migrate(r'''
type Foo { property foo := 1 };
type Bar extending Foo;
''') | )
await self.migrate(r | test_edgeql_migration_computed_02 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_computed_03(self):
await self.migrate(r'''
type User {
property name -> str;
multi link tweets := Tweet;
}
type Tweet {
property text -> str;
link author -> User;
}
''', module='default')
await self.con.execute("""
INSERT Tweet {
text := 'Hello',
author := (
INSERT User {name := 'Alice'}
)
};
INSERT Tweet {
text := 'Hi',
author := (
INSERT User {name := 'Billie'}
)
};
""")
# Validate our structures
await self.assert_query_result(
r"""
SELECT Tweet {
text,
author: {
name
},
} ORDER BY .text;
""",
[{
'text': 'Hello',
'author': {
'name': 'Alice'
},
}, {
'text': 'Hi',
'author': {
'name': 'Billie'
},
}],
)
await self.assert_query_result(
r"""
SELECT User {
name,
tweets: {
text
} ORDER BY .text,
} ORDER BY .name;
""",
[{
'name': 'Alice',
'tweets': [{
'text': 'Hello'
}, {
'text': 'Hi'
}],
}, {
'name': 'Billie',
'tweets': [{
'text': 'Hello'
}, {
'text': 'Hi'
}],
}],
)
await self.migrate(r'''
type User {
property name -> str;
multi link tweets := User.<author[IS Tweet];
}
type Tweet {
property text -> str;
link author -> User;
}
''', module='default')
await self.assert_query_result(
r"""
SELECT User {
name,
tweets: {
text
} ORDER BY .text,
} ORDER BY .name;
""",
[{
'name': 'Alice',
'tweets': [{
'text': 'Hello'
}],
}, {
'name': 'Billie',
'tweets': [{
'text': 'Hi'
}],
}],
)
await self.migrate(r'''
type User {
property name -> str;
multi link tweets := .<author[IS Tweet];
}
type Tweet {
property text -> str;
link author -> User;
}
''', module='default')
await self.assert_query_result(
r"""
SELECT User {
name,
tweets: {
text
} ORDER BY .text,
} ORDER BY .name;
""",
[{
'name': 'Alice',
'tweets': [{
'text': 'Hello'
}],
}, {
'name': 'Billie',
'tweets': [{
'text': 'Hi'
}],
}],
)
await self.migrate(r'''
type User {
property name -> str;
multi link tweets := (
SELECT Tweet FILTER .author = User
);
}
type Tweet {
property text -> str;
link author -> User;
}
''', module='default')
await self.assert_query_result(
r"""
SELECT User {
name,
tweets: {
text
} ORDER BY .text,
} ORDER BY .name;
""",
[{
'name': 'Alice',
'tweets': [{
'text': 'Hello'
}],
}, {
'name': 'Billie',
'tweets': [{
'text': 'Hi'
}],
}],
)
await self.migrate(r'''
type User {
property name -> str;
multi link tweets := (
WITH U := User
SELECT Tweet FILTER .author IN U
);
}
type Tweet {
property text -> str;
link author -> User;
}
''', module='default')
await self.assert_query_result(
r"""
SELECT User {
name,
tweets: {
text
} ORDER BY .text,
} ORDER BY .name;
""",
[{
'name': 'Alice',
'tweets': [{
'text': 'Hello'
}],
}, {
'name': 'Billie',
'tweets': [{
'text': 'Hi'
}],
}],
)
await self.migrate(r'''
type User {
property name -> str;
multi link tweets := (
WITH U := DETACHED User
SELECT Tweet FILTER .author IN U
);
}
type Tweet {
property text -> str;
link author -> User;
}
''', module='default')
await self.assert_query_result(
r"""
SELECT User {
name,
tweets: {
text
} ORDER BY .text,
} ORDER BY .name;
""",
[{
'name': 'Alice',
'tweets': [{
'text': 'Hello'
}, {
'text': 'Hi'
}],
}, {
'name': 'Billie',
'tweets': [{
'text': 'Hello'
}, {
'text': 'Hi'
}],
}],
)
await self.migrate(r'''
type User {
property name -> str;
multi link tweets := (
WITH U := User
SELECT U.<author[IS Tweet]
);
}
type Tweet {
property text -> str;
link author -> User;
}
''', module='default')
await self.assert_query_result(
r"""
SELECT User {
name,
tweets: {
text
} ORDER BY .text,
} ORDER BY .name;
""",
[{
'name': 'Alice',
'tweets': [{
'text': 'Hello'
}],
}, {
'name': 'Billie',
'tweets': [{
'text': 'Hi'
}],
}],
)
await self.migrate(r'''
type User {
property name -> str;
multi link tweets := (
WITH User := DETACHED User
SELECT User.<author[IS Tweet]
);
}
type Tweet {
property text -> str;
link author -> User;
}
''', module='default')
await self.assert_query_result(
r"""
SELECT User {
name,
tweets: {
text
} ORDER BY .text,
} ORDER BY .name;
""",
[{
'name': 'Alice',
'tweets': [{
'text': 'Hello'
}, {
'text': 'Hi'
}],
}, {
'name': 'Billie',
'tweets': [{
'text': 'Hello'
}, {
'text': 'Hi'
}],
}],
) | , module='default')
await self.con.execute( | test_edgeql_migration_computed_03 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_computed_04(self):
await self.migrate(r'''
type User {
property name -> str;
multi property tweets := Tweet.text;
}
type Tweet {
property text -> str;
link author -> User;
}
''', module='default')
await self.con.execute("""
INSERT Tweet {
text := 'Hello',
author := (
INSERT User {name := 'Alice'}
)
};
INSERT Tweet {
text := 'Hi',
author := (
INSERT User {name := 'Billie'}
)
};
""")
# Validate our structures
await self.assert_query_result(
r"""
SELECT Tweet {
text,
author: {
name
},
} ORDER BY .text;
""",
[{
'text': 'Hello',
'author': {
'name': 'Alice'
},
}, {
'text': 'Hi',
'author': {
'name': 'Billie'
},
}],
)
await self.assert_query_result(
r"""
SELECT User {
name,
tweets,
} ORDER BY .name;
""",
[{
'name': 'Alice',
'tweets': {'Hello', 'Hi'},
}, {
'name': 'Billie',
'tweets': {'Hello', 'Hi'},
}],
)
await self.migrate(r'''
type User {
property name -> str;
multi property tweets := User.<author[IS Tweet].text;
}
type Tweet {
property text -> str;
link author -> User;
}
''', module='default')
await self.assert_query_result(
r"""
SELECT User {
name,
tweets,
} ORDER BY .name;
""",
[{
'name': 'Alice',
'tweets': {'Hello'},
}, {
'name': 'Billie',
'tweets': {'Hi'},
}],
)
await self.migrate(r'''
type User {
property name -> str;
multi property tweets := .<author[IS Tweet].text;
}
type Tweet {
property text -> str;
link author -> User;
}
''', module='default')
await self.assert_query_result(
r"""
SELECT User {
name,
tweets,
} ORDER BY .name;
""",
[{
'name': 'Alice',
'tweets': {'Hello'},
}, {
'name': 'Billie',
'tweets': {'Hi'},
}],
)
await self.migrate(r'''
type User {
property name -> str;
multi property tweets := (
SELECT Tweet FILTER .author = User
).text;
}
type Tweet {
property text -> str;
link author -> User;
}
''', module='default')
await self.assert_query_result(
r"""
SELECT User {
name,
tweets,
} ORDER BY .name;
""",
[{
'name': 'Alice',
'tweets': {'Hello'},
}, {
'name': 'Billie',
'tweets': {'Hi'},
}],
)
await self.migrate(r'''
type User {
property name -> str;
multi property tweets := (
WITH U := User
SELECT Tweet FILTER .author = U
).text;
}
type Tweet {
property text -> str;
link author -> User;
}
''', module='default')
await self.assert_query_result(
r"""
SELECT User {
name,
tweets,
} ORDER BY .name;
""",
[{
'name': 'Alice',
'tweets': {'Hello'},
}, {
'name': 'Billie',
'tweets': {'Hi'},
}],
)
await self.migrate(r'''
type User {
property name -> str;
multi property tweets := (
WITH U := DETACHED User
SELECT Tweet FILTER .author = U
).text;
}
type Tweet {
property text -> str;
link author -> User;
}
''', module='default')
await self.assert_query_result(
r"""
SELECT User {
name,
tweets,
} ORDER BY .name;
""",
[{
'name': 'Alice',
'tweets': {'Hello', 'Hi'},
}, {
'name': 'Billie',
'tweets': {'Hello', 'Hi'},
}],
)
await self.migrate(r'''
type User {
property name -> str;
multi property tweets := (
WITH U := User
SELECT U.<author[IS Tweet].text
);
}
type Tweet {
property text -> str;
link author -> User;
}
''', module='default')
await self.assert_query_result(
r"""
SELECT User {
name,
tweets,
} ORDER BY .name;
""",
[{
'name': 'Alice',
'tweets': {'Hello'},
}, {
'name': 'Billie',
'tweets': {'Hi'},
}],
)
await self.migrate(r'''
type User {
property name -> str;
multi property tweets := (
WITH User := DETACHED User
SELECT User.<author[IS Tweet].text
);
}
type Tweet {
property text -> str;
link author -> User;
}
''', module='default')
await self.assert_query_result(
r"""
SELECT User {
name,
tweets,
} ORDER BY .name;
""",
[{
'name': 'Alice',
'tweets': {'Hello', 'Hi'},
}, {
'name': 'Billie',
'tweets': {'Hello', 'Hi'},
}],
) | , module='default')
await self.con.execute( | test_edgeql_migration_computed_04 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_computed_05(self):
await self.migrate(r'''
type Bar {
multi link foo := Foo;
property name -> str;
};
type Foo {
link bar -> Bar;
property val -> str;
};
''', module='default')
await self.con.execute("""
INSERT Foo {
val := 'foo0',
bar := (
INSERT Bar {name := 'bar0'}
),
};
INSERT Foo {
val := 'foo1',
bar := (
INSERT Bar {name := 'bar1'}
),
};
""")
await self.assert_query_result(
r"""
SELECT Foo {
val,
bar: {
name,
foo: {
val
} ORDER BY .val,
},
} ORDER BY .val;
""",
[{
'val': 'foo0',
'bar': {
'name': 'bar0',
'foo': [{'val': 'foo0'}, {'val': 'foo1'}],
},
}, {
'val': 'foo1',
'bar': {
'name': 'bar1',
'foo': [{'val': 'foo0'}, {'val': 'foo1'}],
},
}],
) | , module='default')
await self.con.execute( | test_edgeql_migration_computed_05 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_computed_06(self):
await self.migrate(r'''
type Bar {
multi property foo := Foo.val;
property name -> str;
};
type Foo {
link bar -> Bar;
property val -> str;
};
''', module='default')
await self.con.execute("""
INSERT Foo {
val := 'foo0',
bar := (
INSERT Bar {name := 'bar0'}
),
};
INSERT Foo {
val := 'foo1',
bar := (
INSERT Bar {name := 'bar1'}
),
};
""")
await self.assert_query_result(
r"""
SELECT Foo {
val,
bar: {
name,
foo,
},
} ORDER BY .val;
""",
[{
'val': 'foo0',
'bar': {
'name': 'bar0',
'foo': {'foo0', 'foo1'},
},
}, {
'val': 'foo1',
'bar': {
'name': 'bar1',
'foo': {'foo0', 'foo1'},
},
}],
) | , module='default')
await self.con.execute( | test_edgeql_migration_computed_06 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_reject_prop_01(self):
await self.migrate('''
type User {
property foo -> str;
};
''')
await self.start_migration('''
type User {
property bar -> str;
};
''')
await self.interact([
("did you rename property 'foo' of object type "
"'test::User' to 'bar'?", "n"),
# XXX: or should this be split up?
"did you alter object type 'test::User'?"
])
await self.fast_forward_describe_migration() | )
await self.start_migration( | test_edgeql_migration_reject_prop_01 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_reject_prop_02(self):
await self.migrate('''
type User {
required property foo -> str;
};
''')
await self.start_migration('''
type User {
property bar -> str;
};
''')
# Initial confidence should *not* be 1.0 here
res = json.loads(await self.con.query_single(
'DESCRIBE CURRENT MIGRATION AS JSON;'))
self.assertLess(res['proposed']['confidence'], 1.0)
await self.interact([
("did you rename property 'foo' of object type 'test::User' to "
"'bar'?", "n"),
# XXX: or should this be split up?
"did you alter object type 'test::User'?"
])
await self.fast_forward_describe_migration() | )
await self.start_migration( | test_edgeql_migration_reject_prop_02 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_reject_prop_03(self):
await self.migrate('''
type User {
required property foo -> str;
};
''')
await self.start_migration('''
type User {
required property bar -> int64;
};
''')
await self.interact([
# Or should this be split into rename and reset optionality?
("did you create property 'bar' of object type 'test::User'?",
"n"),
("did you rename property 'foo' of object type 'test::User' to "
"'bar'?"),
("did you alter the type of property 'bar' of object type "
"'test::User'?",
"y",
"<int64>.bar"),
])
await self.fast_forward_describe_migration() | )
await self.start_migration( | test_edgeql_migration_reject_prop_03 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_reject_prop_04(self):
await self.migrate('''
type Foo;
type Bar;
''')
await self.start_migration('''
type Foo;
type Bar extending Foo;
''')
await self.interact([
("did you alter object type 'test::Bar'?", "n"),
"did you drop object type 'test::Bar'?",
"did you create object type 'test::Bar'?",
])
await self.fast_forward_describe_migration() | )
await self.start_migration( | test_edgeql_migration_reject_prop_04 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_reject_prop_05(self):
await self.migrate('''
scalar type Slug extending str;
abstract type Named {
required property name -> Slug;
};
type User {
required property name -> str;
};
''')
await self.start_migration('''
scalar type Slug extending str;
abstract type Named {
required property name -> Slug;
};
type User extending Named;
''')
await self.interact([
("did you drop property 'name' of object type 'test::User'?", "n"),
], check_complete=False)
await self.fast_forward_describe_migration() | )
await self.start_migration( | test_edgeql_migration_reject_prop_05 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_vector_change_01(self):
await self.migrate('''
using extension pgvector;
module default {
scalar type Embedding extending ext::pgvector::vector<384>;
type Obj {
embeddings: Embedding;
}
}
''', explicit_modules=True)
await self.start_migration('''
using extension pgvector;
module default {
scalar type Embedding extending ext::pgvector::vector<768>;
type Obj {
embeddings: Embedding;
}
}
''', explicit_modules=True)
await self.assert_describe_migration({
'proposed': {
'statements': [{
'text': """
ALTER TYPE default::Obj {DROP PROPERTY embeddings;};
"""
}]
}
})
async with self.assertRaisesRegexTx(
edgedb.SchemaDefinitionError,
r"cannot produce migration because of a dependency cycle",
):
await self.interact([
("did you drop property 'embeddings' of object type "
"'default::Obj'?", "n"),
]) | , explicit_modules=True)
await self.start_migration( | test_edgeql_migration_vector_change_01 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_force_delete_01(self):
await self.migrate('''
type Base;
type Foo;
type Bar { link foo -> Foo; };
''')
await self.start_migration('''
type Base;
type Foo extending Base;
type Bar { link foo -> Foo; };
''')
await self.interact([
("did you alter object type 'test::Foo'?", "n"),
"did you drop link 'foo' of object type 'test::Bar'?"
], check_complete=False)
await self.fast_forward_describe_migration() | )
await self.start_migration( | test_edgeql_migration_force_delete_01 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_force_delete_02(self):
await self.migrate('''
type Base;
type Foo;
type Bar extending Foo;
''')
await self.start_migration('''
type Base;
type Foo extending Base;
type Bar extending Foo;
''')
await self.interact([
("did you alter object type 'test::Foo'?", "n"),
"did you drop object type 'test::Bar'?"
], check_complete=False)
await self.fast_forward_describe_migration() | )
await self.start_migration( | test_edgeql_migration_force_delete_02 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_01(self):
await self.migrate("""
type Base;
""")
await self.con.execute("""
SET MODULE test;
INSERT Base;
""")
# Try altering the schema to a state inconsistent with current
# data.
with self.assertRaisesRegex(
AssertionError,
r"Please specify an expression to populate existing objects "
r"in order to make property 'name' of object type 'test::Base' "
r"required"
):
await self.migrate("""
type Base {
required property name -> str;
}
""")
# Migration without making the property required.
await self.migrate("""
type Base {
property name -> str;
}
""")
await self.assert_query_result(
r"""
SELECT Base {
name
};
""",
[{
'name': None,
}],
)
await self.con.execute("""
UPDATE
Base
SET {
name := 'base_01'
};
""")
await self.assert_query_result(
r"""
SELECT Base {
name
};
""",
[{
'name': 'base_01',
}],
)
# Inherit from the Base, making name required.
await self.migrate("""
type Base {
property name -> str;
}
type Derived extending Base {
overloaded required property name -> str;
}
""")
await self.con.execute("""
INSERT Derived {
name := 'derived_01'
};
""")
await self.assert_query_result(
r"""
SELECT Base.name;
""",
{'base_01', 'derived_01'},
) | )
await self.con.execute( | test_edgeql_migration_eq_01 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_02(self):
await self.migrate(r"""
type Base {
property foo -> str;
}
type Derived extending Base {
overloaded required property foo -> str;
}
""")
await self.con.execute("""
SET MODULE test;
INSERT Base {
foo := 'base_02',
};
INSERT Derived {
foo := 'derived_02',
};
""")
await self.migrate(r"""
type Base {
# rename 'foo'
property foo2 -> str;
}
type Derived extending Base {
overloaded required property foo2 -> str;
}
""")
# the data still persists
await self.assert_query_result(
r"""
SELECT Base {
__type__: {name},
foo2,
} ORDER BY .foo2;
""",
[{
'__type__': {'name': 'test::Base'},
'foo2': 'base_02',
}, {
'__type__': {'name': 'test::Derived'},
'foo2': 'derived_02',
}],
) | )
await self.con.execute( | test_edgeql_migration_eq_02 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_03(self):
await self.migrate(r"""
type Base {
property foo -> str;
}
type Derived extending Base {
overloaded required property foo -> str;
}
""")
await self.con.execute("""
SET MODULE test;
INSERT Base {
foo := 'base_03',
};
INSERT Derived {
foo := 'derived_03',
};
""")
await self.migrate(r"""
type Base;
# drop 'foo'
type Derived extending Base {
# completely different property
property foo2 -> str;
}
""")
await self.assert_query_result(
r"""
SELECT Base {
__type__: {name},
[IS Derived].foo2,
} ORDER BY .foo2;
""",
[{
'__type__': {'name': 'test::Base'},
'foo2': None,
}, {
'__type__': {'name': 'test::Derived'},
'foo2': None,
}],
) | )
await self.con.execute( | test_edgeql_migration_eq_03 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_04(self):
await self.migrate(r"""
type Base {
property foo -> str;
}
type Derived extending Base;
type Further extending Derived {
overloaded required property foo -> str;
}
""")
await self.con.execute("""
SET MODULE test;
INSERT Base {
foo := 'base_04',
};
INSERT Derived {
foo := 'derived_04',
};
INSERT Further {
foo := 'further_04',
};
""")
await self.migrate(r"""
type Base;
# drop 'foo'
type Derived extending Base;
type Further extending Derived {
# completely different property
property foo2 -> str;
};
""")
await self.assert_query_result(
r"""
SELECT Base {
__type__: {name},
[IS Further].foo2,
} ORDER BY .__type__.name;
""",
[{
'__type__': {'name': 'test::Base'},
'foo2': None,
}, {
'__type__': {'name': 'test::Derived'},
'foo2': None,
}, {
'__type__': {'name': 'test::Further'},
'foo2': None,
}],
) | )
await self.con.execute( | test_edgeql_migration_eq_04 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_06(self):
await self.migrate(r"""
type Base {
property foo -> int64;
}
type Derived extending Base {
overloaded required property foo -> int64;
}
""")
await self.con.execute("""
SET MODULE test;
INSERT Base {
foo := 6,
};
""")
await self.assert_query_result(
r"""
SELECT Base {
__type__: {name},
foo,
};
""",
[{
'__type__': {'name': 'test::Base'},
# the value was correctly inserted
'foo': 6,
}],
)
await self.migrate(r"""
type Base {
property foo -> float64;
}
type Derived extending Base {
overloaded required property foo -> float64;
}
""")
await self.assert_query_result(
r"""
SELECT Base {
__type__: {name},
foo,
};
""",
[{
'__type__': {'name': 'test::Base'},
'foo': 6.0,
}],
) | )
await self.con.execute( | test_edgeql_migration_eq_06 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_07(self):
await self.con.execute("""
SET MODULE test;
""")
await self.migrate(r"""
type Child {
required property name -> str {
constraint exclusive;
}
}
type Base {
required property name -> str;
link bar -> Child;
}
""")
await self.con.execute('''
INSERT Child { name := 'c1' };
INSERT Child { name := 'c2' };
INSERT Base {
name := 'b1',
bar := (SELECT Child FILTER .name = 'c1'),
};
INSERT Base {
name := 'b2',
};
''')
await self.assert_query_result(
r"""
SELECT Base {
bar: {
name
}
} ORDER BY .name;
""",
[{
'bar': {
'name': 'c1',
},
}, {
'bar': None,
}],
)
await self.migrate(r"""
type Child {
required property name -> str {
constraint exclusive;
}
}
type Base {
required property name -> str;
required link bar -> Child {
# add a constraint
constraint exclusive;
}
}
""", user_input=[
"SELECT Child FILTER .name = 'c2'"
])
await self.assert_query_result(
r"""
SELECT Base {
bar: {
name
}
} ORDER BY .name;
""",
[{
'bar': {
'name': 'c1',
},
}, {
'bar': {
'name': 'c2',
},
}],
) | )
await self.migrate(r | test_edgeql_migration_eq_07 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_08(self):
await self.migrate(r"""
type Base {
property foo -> str;
}
""")
await self.con.execute(r"""
SET MODULE test;
INSERT Base {
foo := 'very_long_test_str_base_08',
};
""")
# Try altering the schema to a state inconsistent with current
# data.
new_state = r"""
type Base {
property foo -> str {
# add a constraint
constraint max_len_value(10);
}
}
"""
with self.assertRaisesRegex(
edgedb.ConstraintViolationError,
r"foo must be no longer than 10 characters"):
await self.migrate(new_state)
# Fix the data.
await self.con.execute(r"""
UPDATE Base
SET {
foo := 'base_08',
};
""")
# Migrate to same state as before now that the data is fixed.
await self.migrate(new_state)
await self.assert_query_result(
r"""
SELECT Base {
foo,
};
""",
[{
'foo': 'base_08',
}],
) | )
await self.con.execute(r | test_edgeql_migration_eq_08 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_09(self):
await self.migrate(r"""
scalar type constraint_length extending str {
constraint max_len_value(10);
}
type Base {
property foo -> constraint_length;
}
""")
await self.con.execute(r"""
SET MODULE test;
INSERT Base {
foo := 'b09',
};
""")
# Try altering the schema to a state inconsistent with current
# data.
new_state = r"""
scalar type constraint_length extending str {
constraint max_len_value(10);
# add a constraint
constraint min_len_value(5);
}
type Base {
property foo -> constraint_length;
}
"""
with self.assertRaisesRegex(
edgedb.ConstraintViolationError,
r'Existing test::Base\.foo values violate the new constraint'):
await self.migrate(new_state)
# Fix the data.
await self.con.execute(r"""
UPDATE Base
SET {
foo := 'base_09',
};
""")
# Migrate to same state as before now that the data is fixed.
await self.migrate(new_state)
await self.assert_query_result(
r"""
SELECT Base {
foo,
};
""",
[{
'foo': 'base_09',
}],
) | )
await self.con.execute(r | test_edgeql_migration_eq_09 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_11(self):
await self.migrate(r"""
type Base {
property foo -> str;
}
""")
await self.con.execute(r"""
SET MODULE test;
INSERT Base {
foo := 'base_11',
};
""")
await self.migrate(r"""
type Child;
type Base {
# change property to link with same name
link foo -> Child {
# add a constraint
constraint exclusive;
}
}
""")
await self.assert_query_result(
r"""
SELECT Base {
foo,
};
""",
[{
'foo': None,
}],
) | )
await self.con.execute(r | test_edgeql_migration_eq_11 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_12(self):
await self.migrate(r"""
type Child;
type Base {
property foo -> str {
constraint exclusive;
}
link bar -> Child {
constraint exclusive;
}
}
""")
await self.con.execute("""
SET MODULE test;
""")
data = await self.con.query(r"""
SELECT (
INSERT Base {
foo := 'base_12',
bar := (INSERT Child)
})
{
foo,
bar: {id}
};
""")
await self.migrate(r"""
type Child;
type Base {
# drop constraints
property foo -> str;
link bar -> Child;
}
""")
await self.assert_query_result(
r"""
SELECT Base {
foo,
bar: {id}
};
""",
[{
'foo': 'base_12',
'bar': {'id': data[0].bar.id}
}],
) | )
await self.con.execute( | test_edgeql_migration_eq_12 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_13(self):
await self.migrate(r"""
type Child;
type Base {
link bar -> Child;
}
type Derived extending Base {
overloaded required link bar -> Child;
}
""")
await self.con.execute("""
SET MODULE test;
""")
data = await self.con.query(r"""
SELECT (
INSERT Derived {
bar := (INSERT Child)
})
{
bar: {id}
};
""")
await self.migrate(r"""
type Child;
type Base;
# drop 'bar'
type Derived extending Base {
# no longer inherit link 'bar'
link bar -> Child;
}
""")
await self.assert_query_result(
r"""
SELECT Derived {
bar: {id}
};
""",
[{
'bar': {'id': data[0].bar.id}
}],
) | )
await self.con.execute( | test_edgeql_migration_eq_13 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_14a(self):
await self.migrate(r"""
type Base;
type Derived extending Base {
property foo -> str;
}
""")
await self.con.execute(r"""
SET MODULE test;
INSERT Derived {
foo := 'derived_14',
};
""")
await self.migrate(r"""
type Base {
# move the property earlier in the inheritance
property foo -> str;
}
type Derived extending Base {
overloaded property foo -> str {
annotation title := 'overloaded'
}
}
""")
await self.assert_query_result(
r"""
SELECT Derived {
foo,
};
""",
[{
'foo': 'derived_14',
}],
) | )
await self.con.execute(r | test_edgeql_migration_eq_14a | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_14b(self):
# Same as above, except POPULATE and inspect the query
await self.migrate(r"""
type Base;
type Derived extending Base {
property foo -> str;
}
""")
await self.start_migration(r"""
type Base {
# move the property earlier in the inheritance
property foo -> str;
}
type Derived extending Base {
overloaded required property foo -> str;
}
""", populate=True)
await self.assert_describe_migration({
'confirmed': ["""
ALTER TYPE test::Base {
CREATE PROPERTY foo: std::str;
};
""", """
ALTER TYPE test::Derived {
ALTER PROPERTY foo {
SET REQUIRED;
};
};
"""],
'complete': True,
}) | )
await self.start_migration(r | test_edgeql_migration_eq_14b | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_16(self):
await self.migrate(r"""
type Child;
type Base;
type Derived extending Base {
link bar -> Child;
}
""")
await self.con.execute("""
SET MODULE test;
""")
data = await self.con.query(r"""
SELECT (
INSERT Derived {
bar := (INSERT Child),
}
) {
bar: {id}
};
""")
await self.migrate(r"""
type Child;
type Base {
# move the link earlier in the inheritance
link bar -> Child;
}
type Derived extending Base;
""")
await self.assert_query_result(
r"""
SELECT Derived {
bar,
};
""",
[{
'bar': {'id': data[0].bar.id},
}],
)
await self.migrate(
r"""
type Child;
type Base {
link bar -> Child;
}
type Derived extending Base {
# also make the link 'required'
overloaded required link bar -> Child;
}
""",
user_input=[
'.bar',
],
)
await self.assert_query_result(
r"""
SELECT Derived {
bar,
};
""",
[{
'bar': {'id': data[0].bar.id},
}],
) | )
await self.con.execute( | test_edgeql_migration_eq_16 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_18a(self):
await self.migrate(r"""
type Base {
property name := 'computable'
}
""")
await self.con.execute(r"""
SET MODULE test;
INSERT Base;
""")
await self.migrate(r"""
type Base {
# change a property from a computable to regular with a default
property name -> str {
default := 'something'
}
}
""")
# Insert a new object, this one should have a new default name.
await self.con.execute(r"""
INSERT Base;
""")
await self.assert_query_result(
r"""
SELECT Base {
name,
} ORDER BY .name EMPTY LAST;
""",
[{
'name': 'something',
}, {
'name': 'something',
}],
) | )
await self.con.execute(r | test_edgeql_migration_eq_18a | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_18b(self):
await self.migrate(r"""
type Base {
property name := 'computable'
}
""")
await self.con.execute(r"""
SET MODULE test;
INSERT Base;
""")
await self.migrate(r"""
type Base {
# change a property from a computable to regular with a default
property name -> str {
default := <str>count(Object)
}
}
""")
# Insert a new object, this one should have a new default name.
await self.con.execute(r"""
INSERT Base;
""")
await self.assert_query_result(
r"""
SELECT Base {
name,
} ORDER BY .name EMPTY LAST;
""",
[{
'name': str,
}, {
'name': str,
}],
) | )
await self.con.execute(r | test_edgeql_migration_eq_18b | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_18c(self):
await self.migrate(r"""
type Base {
property name := 'computable'
}
""")
await self.con.execute(r"""
SET MODULE test;
INSERT Base;
""")
await self.migrate(r"""
type Base {
# change a property from a computable to regular with a default
required property name -> str {
default := <str>count(Object)
}
}
""")
# Insert a new object, this one should have a new default name.
await self.con.execute(r"""
INSERT Base;
""")
await self.assert_query_result(
r"""
SELECT Base {
name,
} ORDER BY .name EMPTY LAST;
""",
[{
'name': str,
}, {
'name': str,
}],
) | )
await self.con.execute(r | test_edgeql_migration_eq_18c | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_19(self):
await self.migrate(r"""
type Base {
property name -> str
}
""")
await self.con.execute(r"""
SET MODULE test;
INSERT Base {
name := 'base_19'
};
""")
await self.migrate(r"""
type Base {
# change a regular property to a computable
property name := 'computable'
}
""")
await self.assert_query_result(
r"""
SELECT Base {
name,
};
""",
[{
'name': 'computable',
}],
) | )
await self.con.execute(r | test_edgeql_migration_eq_19 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_21(self):
await self.migrate(r"""
type Base {
property foo -> str;
}
""")
await self.con.execute(r"""
SET MODULE test;
INSERT Base {
foo := 'base_21'
};
""")
await self.migrate(r"""
type Base {
property foo -> str;
# add a property
property bar -> int64;
}
""")
await self.con.execute(r"""
UPDATE Base
SET {
bar := 21
};
""")
await self.assert_query_result(
r"""
SELECT Base {
foo,
bar
};
""",
[{
'foo': 'base_21',
'bar': 21,
}],
)
await self.migrate(r"""
type Base {
# make the old property into a computable
property foo := <str>__source__.bar;
property bar -> int64;
}
""")
await self.assert_query_result(
r"""
SELECT Base {
foo,
bar
};
""",
[{
'foo': '21',
'bar': 21,
}],
) | )
await self.con.execute(r | test_edgeql_migration_eq_21 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_22(self):
await self.migrate(r"""
type Base {
property foo -> str;
}
""")
await self.con.execute(r"""
SET MODULE test;
INSERT Base {
foo := 'base_22'
};
""")
await self.migrate(r"""
# rename the type, although this test doesn't ensure that
# renaming actually took place
type NewBase {
property foo -> str;
}
""")
await self.assert_query_result(
r"""
SELECT NewBase {
foo,
};
""",
[{
'foo': 'base_22',
}],
)
await self.migrate(r"""
type NewBase {
property foo -> str;
# add a property
property bar -> int64;
}
""")
await self.con.execute(r"""
UPDATE NewBase
SET {
bar := 22
};
""")
await self.assert_query_result(
r"""
SELECT NewBase {
foo,
bar
};
""",
[{
'foo': 'base_22',
'bar': 22,
}],
)
await self.migrate(r"""
type NewBase {
# drop 'foo'
property bar -> int64;
}
# add a alias to emulate the original
alias Base := (
SELECT NewBase {
foo := <str>.bar
}
);
""")
await self.assert_query_result(
r"""
SELECT Base {
foo,
};
""",
[{
'foo': '22',
}],
) | )
await self.con.execute(r | test_edgeql_migration_eq_22 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_23(self):
await self.migrate(r"""
type Child {
property foo -> str;
}
type Base {
link bar -> Child;
}
alias Alias01 := (
SELECT Base {
child_foo := .bar.foo
}
);
""")
await self.con.execute(r"""
SET MODULE test;
INSERT Base {
bar := (
INSERT Child {
foo := 'child_23'
}
)
};
""")
await self.migrate(r"""
type Child {
property foo -> str;
}
# exchange a type for a alias
alias Base := (
SELECT Child {
# bar is the same as the root object
bar := Child
}
);
alias Alias01 := (
# now this alias refers to another alias
SELECT Base {
child_foo := .bar.foo
}
);
""")
await self.assert_query_result(
r"""
SELECT Alias01 {
child_foo,
};
""",
[{
'child_foo': 'child_23',
}],
) | )
await self.con.execute(r | test_edgeql_migration_eq_23 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_24(self):
await self.migrate(r"""
type Child;
type Base {
link bar -> Child;
}
""")
await self.con.execute("""
SET MODULE test;
""")
data = await self.con.query(r"""
SELECT (
INSERT Base {
bar := (INSERT Child)
}
) {
bar: {id}
}
""")
await self.migrate(r"""
type Child;
type Base {
# increase link cardinality
multi link bar -> Child;
}
""")
await self.assert_query_result(
r"""
SELECT Base {
bar: {id},
};
""",
[{
'bar': [{'id': data[0].bar.id}],
}],
) | )
await self.con.execute( | test_edgeql_migration_eq_24 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_25(self):
await self.migrate(r"""
type Child;
type Base {
multi link bar -> Child;
}
""")
await self.con.execute("""
SET MODULE test;
""")
data = await self.con.query(r"""
SELECT (
INSERT Base {
bar := (INSERT Child)
}
) {
bar: {id}
}
""")
await self.migrate(r"""
type Child;
type Base {
# reduce link cardinality
link bar -> Child;
}
""", user_input=[
'(SELECT .bar LIMIT 1)'
])
await self.assert_query_result(
r"""
SELECT Base {
bar: {id},
};
""",
[{
'bar': {'id': data[0].bar[0].id},
}],
)
await self.migrate(r"""
type Child;
type Base {
link bar -> Child {
# further restrict the link
constraint exclusive
}
}
""")
await self.assert_query_result(
r"""
SELECT Base {
bar: {id},
};
""",
[{
'bar': {'id': data[0].bar[0].id},
}],
) | )
await self.con.execute( | test_edgeql_migration_eq_25 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_26(self):
await self.migrate(r"""
type Child;
type Parent {
link bar -> Child;
}
""")
await self.con.execute(r"""
SET MODULE test;
INSERT Parent {
bar := (INSERT Child)
};
""")
await self.migrate(r"""
type Child;
type Parent {
link bar -> Child;
}
# derive a type
type DerivedParent extending Parent;
""")
await self.assert_query_result(
r"""
SELECT Parent {
type := .__type__.name,
bar_type := .bar.__type__.name
};
""",
[{
'type': 'test::Parent',
'bar_type': 'test::Child',
}],
)
await self.migrate(
r"""
type Child;
type DerivedChild extending Child;
type Parent {
link bar -> Child;
}
type DerivedParent extending Parent;
""",
)
await self.migrate(
r"""
type Child;
type DerivedChild extending Child;
type Parent {
link bar -> Child;
}
# derive a type with a more restrictive link
type DerivedParent extending Parent {
overloaded link bar -> DerivedChild;
}
""",
user_input=[".bar[IS DerivedChild]"],
)
await self.con.execute(r"""
INSERT DerivedParent {
bar := (INSERT DerivedChild)
}
""")
await self.assert_query_result(
r"""
SELECT Parent {
type := .__type__.name,
bar_type := .bar.__type__.name
} ORDER BY .bar_type;
""",
[{
'type': 'test::Parent',
'bar_type': 'test::Child',
}, {
'type': 'test::DerivedParent',
'bar_type': 'test::DerivedChild',
}],
) | )
await self.con.execute(r | test_edgeql_migration_eq_26 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_27(self):
await self.migrate(r"""
abstract type Named {
property name -> str;
}
type Foo extending Named;
type Bar extending Named;
""")
await self.con.execute(r"""
SET MODULE test;
INSERT Foo {
name := 'foo_27',
};
INSERT Bar {
name := 'bar_27',
};
""")
await self.migrate(r"""
abstract type Named {
property name -> str;
}
# the types stop extending named, but retain the property
# 'name'
type Foo {
property name -> str;
};
type Bar {
property name -> str;
};
""")
await self.assert_query_result(
r"""
SELECT Foo.name;
""",
[
'foo_27',
],
)
await self.assert_query_result(
r"""
SELECT Bar.name;
""",
[
'bar_27',
],
)
await self.migrate(r"""
abstract type Named {
property name -> str;
}
type Foo {
property name -> str;
};
type Bar {
# rename 'name' to 'title'
property title -> str;
};
""")
await self.assert_query_result(
r"""
SELECT Foo.name;
""",
[
'foo_27',
],
)
await self.assert_query_result(
r"""
SELECT Bar.title;
""",
[
'bar_27',
],
) | )
await self.con.execute(r | test_edgeql_migration_eq_27 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_29(self):
await self.migrate(r"""
type Child {
property foo -> str;
}
alias Base := (
SELECT Child {
bar := .foo
}
);
""")
await self.con.execute(r"""
SET MODULE test;
INSERT Child {
foo := 'child_29',
};
""")
await self.migrate(r"""
# drop everything
""") | )
await self.con.execute(r | test_edgeql_migration_eq_29 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_30(self):
await self.migrate(r"""
type Foo {
property name -> str;
};
type Bar {
property title -> str;
};
""")
await self.con.execute(r"""
SET MODULE test;
INSERT Foo {
name := 'foo_30',
};
INSERT Bar {
title := 'bar_30',
};
""")
await self.migrate(r"""
type Foo {
property name -> str;
};
type Bar {
# rename 'title' to 'name'
property name -> str;
};
""")
await self.assert_query_result(
r"""
SELECT Foo.name;
""",
[
'foo_30',
],
)
await self.assert_query_result(
r"""
SELECT Bar.name;
""",
[
'bar_30',
],
)
await self.migrate(r"""
# both types have a name, so the name prop is factored out
# into a more basic type.
abstract type Named {
property name -> str;
}
type Foo extending Named;
type Bar extending Named;
""")
await self.assert_query_result(
r"""
SELECT Foo.name;
""",
[
'foo_30',
],
)
await self.assert_query_result(
r"""
SELECT Bar.name;
""",
[
'bar_30',
],
) | )
await self.con.execute(r | test_edgeql_migration_eq_30 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_31(self):
# Issue 727.
#
# Starting with the sample schema (from frontpage) migrate to
# a schema with only type User.
await self.migrate(r"""
# This is an abstract object containing
# text.
abstract type Text {
required property body -> str {
# Maximum length of text is 10000
# characters.
constraint max_len_value(10000);
}
}
type User {
required property name -> str;
}
abstract type Owned {
# By default links are optional.
required link owner -> User;
}
# UniquelyNamed is a an abstract type that
# enforces name uniqueness across all
# instances of its subtype.
abstract type UniquelyNamed {
required property name -> str {
delegated constraint exclusive;
}
}
type Status extending UniquelyNamed;
type Priority extending UniquelyNamed;
# LogEntry is an Owned and a Text,
# so it will have all of their links
# and properties, in particular, the
# "owner" link and the "body" property.
type LogEntry extending Owned, Text {
required property spent_time -> int64;
}
type Comment extending Text, Owned {
required link issue -> Issue;
link parent -> Comment;
}
# issue_num_t is defined as a concrete
# sequence type, used to generate
# sequential issue numbers.
scalar type issue_num_t extending sequence;
type Issue extending Owned, Text {
required property title -> str;
required property number -> issue_num_t {
# The number values are automatically
# generated, and are not supposed to be
# directly writable.
readonly := true;
}
property time_estimate -> int64;
property start_date -> datetime {
# The default value of start_date will be a
# result of the EdgeQL expression above.
default := (SELECT datetime_current());
}
property due_date -> datetime;
required link status -> Status;
link priority -> Priority;
# The watchers link is mapped to User
# type in many-to-many relation.
multi link watchers -> User;
multi link time_spent_log -> LogEntry {
# Exclusive multi-link represents
# a one-to-many relation.
constraint exclusive;
}
multi link related_to -> Issue;
}
""")
await self.con.execute(r"""
SET MODULE test;
INSERT Status {
name := 'Open'
};
INSERT Status {
name := 'Closed'
};
INSERT User {
name := 'cosmophile'
};
""")
await self.migrate(r"""
type User {
required property name -> str;
}
""")
# there's only the User left
await self.assert_query_result(
r"""
SELECT User.name;
""",
[
'cosmophile',
],
) | )
await self.con.execute(r | test_edgeql_migration_eq_31 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_32(self):
# Issue 727.
#
# Starting with a small schema migrate to remove its elements.
# There are non-zero default Objects existing in a fresh blank
# database because of placeholder objects used for GraphQL.
start_objects = await self.con.query_single(r"""
SELECT count(Object);
""")
await self.migrate(r"""
type LogEntry {
required property spent_time -> int64;
}
type Issue {
multi link time_spent_log -> LogEntry {
constraint exclusive;
}
}
""")
await self.con.execute(r"""
SET MODULE test;
INSERT LogEntry {
spent_time := 100
};
INSERT Issue {
time_spent_log := LogEntry
};
""")
await self.migrate(r"""
type LogEntry {
required property spent_time -> int64;
}
""")
# there's only the LogEntry left
await self.assert_query_result(
r"""
SELECT LogEntry.spent_time;
""",
[
100,
],
)
await self.assert_query_result(
r"""
SELECT count(Object);
""",
[
start_objects + 1,
],
)
await self.migrate(r"""
# empty schema
""")
# no more additional objects
await self.assert_query_result(
r"""
SELECT count(Object);
""",
[
start_objects,
],
) | )
await self.migrate(r | test_edgeql_migration_eq_32 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_33(self):
await self.migrate(r"""
type Child;
type Base {
link foo -> Child;
}
""")
await self.con.execute(r"""
SET MODULE test;
INSERT Child;
INSERT Base {
foo := (SELECT Child LIMIT 1)
};
""")
await self.assert_query_result(
r"""
SELECT Base {
foo: {
__type__: {name},
}
};
""",
[{
'foo': {
'__type__': {'name': 'test::Child'},
}
}],
)
await self.migrate(
r"""
type Child;
type Child2;
type Base {
link foo -> Child;
}
""",
)
await self.migrate(
r"""
type Child;
type Child2;
type Base {
# change link type
link foo -> Child2;
}
""",
user_input=[
'.foo[IS Child2]'
],
)
await self.assert_query_result(
r"""
SELECT Base {
foo: {
__type__: {name},
}
};
""",
[{
# the link is empty because the target was changed
'foo': None
}],
)
await self.con.execute(r"""
INSERT Child2;
UPDATE Base
SET {
foo := (SELECT Child2 LIMIT 1)
};
""")
await self.assert_query_result(
r"""
SELECT Base {
foo: {
__type__: {name},
}
};
""",
[{
'foo': {
'__type__': {'name': 'test::Child2'},
}
}],
) | )
await self.con.execute(r | test_edgeql_migration_eq_33 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_34(self):
# this is the reverse of test_edgeql_migration_eq_11
await self.migrate(r"""
type Child;
type Base {
link foo -> Child {
constraint exclusive;
}
}
""")
await self.con.execute(r"""
SET MODULE test;
INSERT Child;
INSERT Base {
foo := (SELECT Child LIMIT 1)
};
""")
await self.assert_query_result(
r"""
SELECT Base {
foo: {
__type__: {name},
}
};
""",
[{
'foo': {
'__type__': {'name': 'test::Child'},
}
}],
)
await self.migrate(r"""
type Base {
# change link to property with same name
property foo -> str;
}
""")
await self.assert_query_result(
r"""
SELECT Base {
foo
};
""",
[{
# the property is empty now
'foo': None
}],
)
await self.con.execute(r"""
UPDATE Base
SET {
foo := 'base_foo_34'
};
""")
await self.assert_query_result(
r"""
SELECT Base {
foo
};
""",
[{
'foo': 'base_foo_34'
}],
) | )
await self.con.execute(r | test_edgeql_migration_eq_34 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_35(self):
await self.migrate(r"""
type Child {
required property name -> str;
}
type Base {
multi link foo := (
SELECT Child FILTER .name = 'computable_35'
)
}
""")
await self.con.execute(r"""
SET MODULE test;
INSERT Child {
name := 'computable_35'
};
INSERT Base;
""")
await self.assert_query_result(
r"""
SELECT Base {
foo: {
name
},
};
""",
[{
'foo': [{
'name': 'computable_35',
}]
}]
)
await self.migrate(r"""
type Child {
required property name -> str;
}
type Base {
# change a link from a computable to regular
multi link foo -> Child;
}
""")
await self.assert_query_result(
r"""
SELECT Base {
foo: {
name
},
};
""",
[{
'foo': []
}]
)
# Make sure that the new 'foo' can be updated.
await self.con.execute(r"""
INSERT Child {
name := 'child_35'
};
UPDATE Base
SET {
foo := (
SELECT Child FILTER .name = 'child_35'
)
};
""")
await self.assert_query_result(
r"""
SELECT Base {
foo: {
name
},
};
""",
[{
'foo': [{
'name': 'child_35'
}]
}]
) | )
await self.con.execute(r | test_edgeql_migration_eq_35 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_36(self):
await self.migrate(r"""
type Child {
required property name -> str;
}
type Base {
multi link foo -> Child;
}
""")
await self.con.execute(r"""
SET MODULE test;
INSERT Child {
name := 'computable_36'
};
INSERT Child {
name := 'child_36'
};
INSERT Base {
foo := (
SELECT Child FILTER .name = 'child_36'
)
};
""")
await self.migrate(r"""
type Child {
required property name -> str;
}
type Base {
# change a regular link to a computable
link foo := (
SELECT Child FILTER .name = 'computable_36'
LIMIT 1
)
}
""")
await self.assert_query_result(
r"""
SELECT Base {
foo: {
name
},
};
""",
[{
'foo': {
'name': 'computable_36'
}
}]
) | )
await self.con.execute(r | test_edgeql_migration_eq_36 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_37(self):
# testing schema alias
await self.migrate(r"""
type Base;
alias BaseAlias := (
SELECT Base {
foo := 'base_alias_37'
}
)
""")
await self.con.execute(r"""
SET MODULE test;
INSERT Base;
""")
await self.assert_query_result(
r"""
SELECT BaseAlias {
foo
};
""",
[{
'foo': 'base_alias_37'
}]
)
await self.migrate(r"""
type Base;
alias BaseAlias := (
SELECT Base {
# "rename" a computable, since the value is given and
# not stored, this is no different from dropping
# original and creating a new property
foo2 := 'base_alias_37'
}
)
""")
await self.assert_query_result(
r"""
SELECT BaseAlias {
foo2
};
""",
[{
'foo2': 'base_alias_37'
}]
)
with self.assertRaisesRegex(
edgedb.InvalidReferenceError,
r"object type 'test::Base' has no link or property 'foo'"):
await self.con.execute(r"""
SELECT BaseAlias {
foo
};
""") | )
await self.con.execute(r | test_edgeql_migration_eq_37 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_38(self):
# testing schema alias
await self.migrate(r"""
type Base;
alias BaseAlias := (
SELECT Base {
foo := 'base_alias_38'
}
)
""")
await self.con.execute(r"""
SET MODULE test;
INSERT Base;
""")
await self.assert_query_result(
r"""
SELECT BaseAlias {
foo
};
""",
[{
'foo': 'base_alias_38'
}]
)
await self.migrate(r"""
type Base;
alias BaseAlias := (
SELECT Base {
# keep the name, but change the type
foo := 38
}
)
""")
await self.assert_query_result(
r"""
SELECT BaseAlias {
foo
};
""",
[{
'foo': 38
}]
) | )
await self.con.execute(r | test_edgeql_migration_eq_38 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_39(self):
# testing schema alias
await self.migrate(r"""
type Base;
type Foo {
property name -> str
}
alias BaseAlias := (
SELECT Base {
foo := (SELECT Foo FILTER .name = 'base_alias_39')
}
)
""")
await self.con.execute(r"""
SET MODULE test;
INSERT Base;
INSERT Foo {name := 'base_alias_39'};
""")
await self.assert_query_result(
r"""
SELECT BaseAlias {
foo: {
name
}
};
""",
[{
'foo': [{
'name': 'base_alias_39'
}]
}]
)
await self.migrate(r"""
type Base;
type Foo {
property name -> str
}
alias BaseAlias := (
SELECT Base {
# "rename" a computable, since the value is given and
# not stored, this is no different from dropping
# original and creating a new multi-link
foo2 := (SELECT Foo FILTER .name = 'base_alias_39')
}
)
""")
await self.assert_query_result(
r"""
SELECT BaseAlias {
foo2: {
name
}
};
""",
[{
'foo2': [{
'name': 'base_alias_39'
}]
}]
)
with self.assertRaisesRegex(
edgedb.InvalidReferenceError,
r"object type 'test::Base' has no link or property 'foo'"):
await self.con.execute(r"""
SELECT BaseAlias {
foo: {
name
}
};
""") | )
await self.con.execute(r | test_edgeql_migration_eq_39 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_40(self):
# testing schema alias
await self.migrate(r"""
type Base;
type Foo {
property name -> str
}
type Bar {
property name -> str
}
alias BaseAlias := (
SELECT Base {
foo := (SELECT Foo FILTER .name = 'foo_40')
}
)
""")
await self.con.execute(r"""
SET MODULE test;
INSERT Base;
INSERT Foo {name := 'foo_40'};
INSERT Bar {name := 'bar_40'};
""")
await self.assert_query_result(
r"""
SELECT BaseAlias {
foo: {
name
}
};
""",
[{
'foo': [{
'name': 'foo_40'
}]
}]
)
await self.migrate(r"""
type Base;
type Foo {
property name -> str
}
type Bar {
property name -> str
}
alias BaseAlias := (
SELECT Base {
# keep the name, but change the type
foo := (SELECT Bar FILTER .name = 'bar_40')
}
)
""")
await self.assert_query_result(
r"""
SELECT BaseAlias {
foo: {
name
}
};
""",
[{
'foo': [{
'name': 'bar_40'
}]
}]
) | )
await self.con.execute(r | test_edgeql_migration_eq_40 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_41(self):
# testing schema alias
await self.migrate(r"""
type Base;
type Foo {
property name -> str
}
alias BaseAlias := (
SELECT Base {
foo := (
SELECT Foo {
@bar := 'foo_bar_alias_41'
}
FILTER .name = 'base_alias_41'
)
}
)
""")
await self.con.execute(r"""
SET MODULE test;
INSERT Base;
INSERT Foo {name := 'base_alias_41'};
""")
await self.assert_query_result(
r"""
SELECT BaseAlias {
foo: {
name,
@bar
}
};
""",
[{
'foo': [{
'name': 'base_alias_41',
'@bar': 'foo_bar_alias_41',
}]
}]
)
await self.migrate(r"""
type Base;
type Foo {
property name -> str
}
alias BaseAlias := (
SELECT Base {
foo := (
SELECT Foo {
# "rename" a computable link property, since
# the value is given and not stored, this is
# no different from dropping original and
# creating a new multi-link
@baz := 'foo_bar_alias_41'
}
FILTER .name = 'base_alias_41'
)
}
)
""")
await self.assert_query_result(
r"""
SELECT BaseAlias {
foo: {
name,
@baz
}
};
""",
[{
'foo': [{
'name': 'base_alias_41',
'@baz': 'foo_bar_alias_41'
}]
}]
)
with self.assertRaisesRegex(
edgedb.InvalidReferenceError,
r"link 'foo' .* has no property 'bar'"):
await self.con.execute(r"""
SELECT BaseAlias {
foo: {
name,
@bar
}
};
""") | )
await self.con.execute(r | test_edgeql_migration_eq_41 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_42(self):
# testing schema alias
await self.migrate(r"""
type Base;
type Foo {
property name -> str
}
alias BaseAlias := (
SELECT Base {
foo := (
SELECT Foo {
@bar := 'foo_bar_alias_42'
}
FILTER .name = 'base_alias_42'
)
}
)
""")
await self.con.execute(r"""
SET MODULE test;
INSERT Base;
INSERT Foo {name := 'base_alias_42'};
""")
await self.assert_query_result(
r"""
SELECT BaseAlias {
foo: {
name,
@bar
}
};
""",
[{
'foo': [{
'name': 'base_alias_42',
'@bar': 'foo_bar_alias_42',
}]
}]
)
await self.migrate(r"""
type Base;
type Foo {
property name -> str
}
alias BaseAlias := (
SELECT Base {
foo := (
SELECT Foo {
# keep the name, but change the type
@bar := 42
}
FILTER .name = 'base_alias_42'
)
}
)
""")
await self.assert_query_result(
r"""
SELECT BaseAlias {
foo: {
name,
@bar
}
};
""",
[{
'foo': [{
'name': 'base_alias_42',
'@bar': 42,
}]
}]
) | )
await self.con.execute(r | test_edgeql_migration_eq_42 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_index_01(self):
await self.migrate('''
type Message {
required property text -> str;
index on (.text);
};
''')
await self.migrate('''
type Message {
required property text -> str;
property ts -> datetime;
index on (.text);
index on (.ts);
};
''')
await self.assert_query_result(
r"""
SELECT count((SELECT schema::ObjectType
FILTER .name = 'test::Message').indexes)
""",
[2],
) | )
await self.migrate( | test_edgeql_migration_index_01 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_rebase_01(self):
await self.migrate(r"""
abstract type C;
abstract type P {
property p -> str;
property p2 -> str;
index on (.p);
};
type Foo extending C {
property foo -> str;
}
""")
await self.migrate(r"""
abstract type C;
abstract type P {
property p -> str;
property p2 -> str;
index on (.p);
};
type Foo extending C, P {
property foo -> str;
}
""") | )
await self.migrate(r | test_edgeql_migration_rebase_01 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_rebase_02(self):
await self.migrate('''
type User;
abstract type Event {
required property createdAt -> datetime {
default := datetime_current();
}
required link user -> User;
}
type Post extending Event {
required property content -> str {
constraint min_len_value(1);
constraint max_len_value(280);
}
}
''')
await self.start_migration('''
type User;
abstract type Event {
required property createdAt -> datetime {
default := datetime_current();
}
required link user -> User;
}
abstract type HasContent {
required property content -> str {
constraint min_len_value(1);
constraint max_len_value(280);
}
}
type Post extending Event, HasContent {
}
type Reply extending Event, HasContent {
required link post -> Post;
}
''')
# N.B.: these prompts are OK but not canonical; if they are
# broken in favor of something better, just fix them.
await self.interact([
"did you create object type 'test::HasContent'?",
"did you alter object type 'test::Post'?",
"did you alter property 'content' of object type 'test::Post'?",
"did you create object type 'test::Reply'?",
]) | )
await self.start_migration( | test_edgeql_migration_rebase_02 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_rebase_03(self):
await self.migrate('''
abstract type Named {
required property name -> str;
};
type Org;
abstract type OrgBound {
required link org -> Org;
};
abstract type OrgUniquelyNamed
extending Named, OrgBound
{
constraint exclusive on ((.name, .org))
}
''')
await self.start_migration('''
abstract type Named {
required property name -> str;
};
type Org;
abstract type Resource;
abstract type OrgBound {
required link org -> Org;
};
abstract type OrgUniquelyNamedResource
extending Named, Resource, OrgBound
{
delegated constraint exclusive on ((.name, .org))
}
''')
# N.B.: these prompts are OK but not canonical; if they are
# broken in favor of something better, just fix them.
await self.interact([
("did you drop object type 'test::OrgUniquelyNamed'?", "n"),
"did you create object type 'test::Resource'?",
"did you rename object type 'test::OrgUniquelyNamed' to "
"'test::OrgUniquelyNamedResource'?",
"did you alter object type 'test::OrgUniquelyNamedResource'?",
]) | )
await self.start_migration( | test_edgeql_migration_rebase_03 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_rename_01(self):
await self.migrate('''
type Foo;
''')
await self.start_migration('''
type Bar {
property asdf -> str;
};
''')
await self.interact([
"did you rename object type 'test::Foo' to 'test::Bar'?",
"did you create property 'asdf' of object type 'test::Bar'?",
]) | )
await self.start_migration( | test_edgeql_migration_rename_01 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_rename_02(self):
await self.migrate('''
type Foo {
property asdf -> str;
};
type Bar extending Foo {
overloaded property asdf -> str;
};
''')
await self.start_migration('''
type Foo {
property womp -> str;
};
type Bar extending Foo {
overloaded property womp -> str {
annotation title := "foo";
};
};
''')
await self.interact([
"did you rename property 'asdf' of object type 'test::Foo' to "
"'womp'?",
"did you create annotation 'std::title' of property 'womp'?",
]) | )
await self.start_migration( | test_edgeql_migration_rename_02 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_rename_03(self):
await self.migrate('''
abstract constraint Asdf { using (__subject__ < 10) };
type Foo {
property x -> int64 {
constraint Asdf;
}
}
type Bar extending Foo;
''')
await self.start_migration('''
abstract constraint Womp { using (__subject__ < 10) };
type Foo {
property x -> int64 {
constraint Womp;
}
}
type Bar extending Foo;
''')
await self.interact([
"did you rename abstract constraint 'test::Asdf' to "
"'test::Womp'?",
]) | )
await self.start_migration( | test_edgeql_migration_rename_03 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_function_01(self):
await self.migrate(r"""
function hello01(a: int64) -> str
using edgeql $$
SELECT 'hello' ++ <str>a
$$
""")
await self.con.execute("""
SET MODULE test;
""")
await self.assert_query_result(
r"""SELECT hello01(1);""",
['hello1'],
)
# add an extra parameter with a default (so it can be omitted
# in principle)
await self.migrate(r"""
function hello01(a: int64, b: int64=42) -> str
using edgeql $$
SELECT 'hello' ++ <str>(a + b)
$$
""")
await self.assert_query_result(
r"""SELECT hello01(1);""",
['hello43'],
)
await self.assert_query_result(
r"""SELECT hello01(1, 2);""",
['hello3'],
) | )
await self.con.execute( | test_edgeql_migration_eq_function_01 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_function_02(self):
await self.migrate(r"""
function hello02(a: int64) -> str
using edgeql $$
SELECT 'hello' ++ <str>a
$$
""")
await self.con.execute("""
SET MODULE test;
""")
await self.assert_query_result(
r"""SELECT hello02(1);""",
['hello1'],
)
# add an extra parameter with a default (so it can be omitted
# in principle)
await self.migrate(r"""
function hello02(a: int64, b: OPTIONAL int64=42) -> str
using edgeql $$
SELECT 'hello' ++ <str>(a + (b ?? -1))
$$
""")
await self.assert_query_result(
r"""SELECT hello02(1);""",
['hello43'],
)
await self.assert_query_result(
r"""SELECT hello02(1, 2);""",
['hello3'],
)
await self.assert_query_result(
r"""SELECT hello02(1, <int64>{});""",
['hello0'],
) | )
await self.con.execute( | test_edgeql_migration_eq_function_02 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_function_03(self):
await self.migrate(r"""
function hello03(a: int64) -> str
using edgeql $$
SELECT 'hello' ++ <str>a
$$
""")
await self.con.execute("""
SET MODULE test;
""")
await self.assert_query_result(
r"""SELECT hello03(1);""",
['hello1'],
)
# add an extra parameter with a default (so it can be omitted
# in principle)
await self.migrate(r"""
function hello03(a: int64, NAMED ONLY b: int64=42) -> str
using edgeql $$
SELECT 'hello' ++ <str>(a + b)
$$
""")
await self.assert_query_result(
r"""SELECT hello03(1);""",
['hello43'],
)
await self.assert_query_result(
r"""SELECT hello03(1, b := 2);""",
['hello3'],
) | )
await self.con.execute( | test_edgeql_migration_eq_function_03 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_function_04(self):
await self.migrate(r"""
function hello04(a: int64) -> str
using edgeql $$
SELECT 'hello' ++ <str>a
$$
""")
await self.con.execute("""
SET MODULE test;
""")
await self.assert_query_result(
r"""SELECT hello04(1);""",
['hello1'],
)
# same parameters, different return type
await self.migrate(r"""
function hello04(a: int64) -> int64
using edgeql $$
SELECT -a
$$
""")
await self.assert_query_result(
r"""SELECT hello04(1);""",
[-1],
) | )
await self.con.execute( | test_edgeql_migration_eq_function_04 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_function_05(self):
await self.migrate(r"""
function hello05(a: int64) -> str
using edgeql $$
SELECT <str>a
$$
""")
await self.con.execute("""
SET MODULE test;
""")
await self.assert_query_result(
r"""SELECT hello05(1);""",
['1'],
)
# same parameters, different return type (array)
await self.migrate(r"""
function hello05(a: int64) -> array<int64>
using edgeql $$
SELECT [a]
$$
""")
await self.assert_query_result(
r"""SELECT hello05(1);""",
[[1]],
) | )
await self.con.execute( | test_edgeql_migration_eq_function_05 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_function_06(self):
await self.migrate(r"""
function hello06(a: int64) -> str
using edgeql $$
SELECT <str>a
$$;
type Base {
property foo -> int64 {
# use the function in default value computation
default := len(hello06(2) ++ hello06(123))
}
}
""")
await self.con.execute(r"""
SET MODULE test;
INSERT Base;
""")
await self.assert_query_result(
r"""SELECT Base.foo;""",
{4},
)
# same parameters, different return type (array)
await self.migrate(r"""
function hello06(a: int64) -> array<int64>
using edgeql $$
SELECT [a]
$$;
type Base {
property foo -> int64 {
# use the function in default value computation
default := len(hello06(2) ++ hello06(123))
}
}
""")
await self.con.execute(r"""
INSERT Base;
""")
await self.assert_query_result(
r"""SELECT Base.foo;""",
{4, 2},
) | )
await self.con.execute(r | test_edgeql_migration_eq_function_06 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_function_07(self):
await self.migrate(r"""
function hello07(a: int64) -> str
using edgeql $$
SELECT <str>a
$$;
type Base {
# use the function in computable value
property foo := len(hello07(2) ++ hello07(123))
}
""")
await self.con.execute(r"""
SET MODULE test;
INSERT Base;
""")
await self.assert_query_result(
r"""SELECT Base.foo;""",
{4},
)
# same parameters, different return type (array)
await self.migrate(r"""
function hello07(a: int64) -> array<int64>
using edgeql $$
SELECT [a]
$$;
type Base {
# use the function in computable value
property foo := len(hello07(2) ++ hello07(123))
}
""")
await self.assert_query_result(
r"""SELECT Base.foo;""",
{2},
) | )
await self.con.execute(r | test_edgeql_migration_eq_function_07 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_function_08(self):
await self.migrate(r"""
function hello08(a: int64) -> str
using edgeql $$
SELECT <str>a
$$;
# use the function in a alias directly
alias foo := len(hello08(2) ++ hello08(123));
""")
await self.con.execute("""
SET MODULE test;
""")
await self.assert_query_result(
r"""SELECT foo;""",
{4},
)
# same parameters, different return type (array)
await self.migrate(r"""
function hello08(a: int64) -> array<int64>
using edgeql $$
SELECT [a]
$$;
# use the function in a alias directly
alias foo := len(hello08(2) ++ hello08(123));
""")
await self.assert_query_result(
r"""SELECT foo;""",
{2},
) | )
await self.con.execute( | test_edgeql_migration_eq_function_08 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_function_09(self):
await self.migrate(r"""
function hello09(a: int64) -> str
using edgeql $$
SELECT <str>a
$$;
type Base;
# use the function in a alias directly
alias BaseAlias := (
SELECT Base {
foo := len(hello09(2) ++ hello09(123))
}
);
""")
await self.con.execute(r"""
SET MODULE test;
INSERT Base;
""")
await self.assert_query_result(
r"""SELECT BaseAlias.foo;""",
{4},
)
# same parameters, different return type (array)
await self.migrate(r"""
function hello09(a: int64) -> array<int64>
using edgeql $$
SELECT [a]
$$;
type Base;
# use the function in a alias directly
alias BaseAlias := (
SELECT Base {
foo := len(hello09(2) ++ hello09(123))
}
);
""")
await self.assert_query_result(
r"""SELECT BaseAlias.foo;""",
{2},
) | )
await self.con.execute(r | test_edgeql_migration_eq_function_09 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_function_10(self):
await self.migrate(r"""
function hello10(a: int64) -> str
using edgeql $$
SELECT <str>a
$$;
type Base {
required property foo -> int64 {
# use the function in a constraint expression
constraint expression on (len(hello10(__subject__)) < 2)
}
}
""")
await self.con.execute(r"""
SET MODULE test;
""")
with self.assertRaisesRegex(
edgedb.ConstraintViolationError,
r'invalid foo'):
async with self.con.transaction():
await self.con.execute(r"""
INSERT Base {foo := 42};
""")
# same parameters, different return type (array)
await self.migrate(r"""
function hello10(a: int64) -> array<int64>
using edgeql $$
SELECT [a]
$$;
type Base {
required property foo -> int64 {
# use the function in a constraint expression
constraint expression on (len(hello10(__subject__)) < 2)
}
}
""")
# no problem with the constraint now
await self.con.execute(r"""
INSERT Base {foo := 42};
""") | )
await self.con.execute(r | test_edgeql_migration_eq_function_10 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_function_11(self):
await self.migrate(r"""
function hello11(a: int64) -> str
using edgeql $$
SELECT 'hello' ++ <str>a
$$
""")
await self.con.execute("""
SET MODULE test;
""")
await self.assert_query_result(
r"""SELECT hello11(1);""",
['hello1'],
)
await self.migrate(r"""
# replace the function with a new one by the same name
function hello11(a: str) -> str
using edgeql $$
SELECT 'hello' ++ a
$$
""")
await self.assert_query_result(
r"""SELECT hello11(' world');""",
['hello world'],
)
# make sure that the old one is gone
with self.assertRaisesRegex(
edgedb.QueryError,
r'function "hello11\(arg0: std::int64\)" does not exist'):
await self.con.execute(
r"""SELECT hello11(1);"""
) | )
await self.con.execute( | test_edgeql_migration_eq_function_11 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_function_12(self):
await self.migrate(r"""
function hello12(a: int64) -> str
using edgeql $$
SELECT 'hello' ++ <str>a
$$;
""")
await self.con.execute("""
SET MODULE test;
""")
await self.assert_query_result(
r"""SELECT hello12(1);""",
['hello1'],
)
await self.migrate(r"""
function hello12(a: int64) -> str
using edgeql $$
SELECT 'hello' ++ <str>a
$$;
# make the function polymorphic
function hello12(a: str) -> str
using edgeql $$
SELECT 'hello' ++ a
$$;
""")
await self.assert_query_result(
r"""SELECT hello12(' world');""",
['hello world'],
)
# make sure that the old one still works
await self.assert_query_result(
r"""SELECT hello12(1);""",
['hello1'],
) | )
await self.con.execute( | test_edgeql_migration_eq_function_12 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
async def test_edgeql_migration_eq_function_13(self):
# this is the inverse of test_edgeql_migration_eq_function_12
await self.migrate(r"""
# start with a polymorphic function
function hello13(a: int64) -> str
using edgeql $$
SELECT 'hello' ++ <str>a
$$;
function hello13(a: str) -> str
using edgeql $$
SELECT 'hello' ++ a
$$;
""")
await self.con.execute("""
SET MODULE test;
""")
await self.assert_query_result(
r"""SELECT hello13(' world');""",
['hello world'],
)
await self.assert_query_result(
r"""SELECT hello13(1);""",
['hello1'],
)
await self.migrate(r"""
# remove one of the 2 versions
function hello13(a: int64) -> str
using edgeql $$
SELECT 'hello' ++ <str>a
$$;
""")
await self.assert_query_result(
r"""SELECT hello13(1);""",
['hello1'],
)
# make sure that the other one is gone
with self.assertRaisesRegex(
edgedb.QueryError,
r'function "hello13\(arg0: std::str\)" does not exist'):
await self.con.execute(
r"""SELECT hello13(' world');"""
) | )
await self.con.execute( | test_edgeql_migration_eq_function_13 | python | geldata/gel | tests/test_edgeql_data_migration.py | https://github.com/geldata/gel/blob/master/tests/test_edgeql_data_migration.py | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.