зеркало из https://github.com/github/codeql.git
Codegen: implement `set` in dbschemegen
This commit is contained in:
Родитель
bba5d9dbd6
Коммит
eef140c3fc
|
@ -64,7 +64,16 @@ def cls_to_dbscheme(cls: schema.Class, lookup: typing.Dict[str, schema.Class], a
|
|||
)
|
||||
# use property-specific tables for 1-to-many and 1-to-at-most-1 properties
|
||||
for f in cls.properties:
|
||||
if f.is_repeated:
|
||||
if f.is_unordered:
|
||||
yield Table(
|
||||
name=inflection.tableize(f"{cls.name}_{f.name}"),
|
||||
columns=[
|
||||
Column("id", type=dbtype(cls.name)),
|
||||
Column(inflection.singularize(f.name), dbtype(f.type, add_or_none_except)),
|
||||
],
|
||||
dir=dir,
|
||||
)
|
||||
elif f.is_repeated:
|
||||
yield Table(
|
||||
keyset=KeySet(["id", "index"]),
|
||||
name=inflection.tableize(f"{cls.name}_{f.name}"),
|
||||
|
|
|
@ -168,6 +168,32 @@ def test_final_class_with_repeated_field(generate, property_cls, dir_param):
|
|||
)
|
||||
|
||||
|
||||
def test_final_class_with_repeated_unordered_field(generate, dir_param):
|
||||
assert generate([
|
||||
schema.Class("Object", group=dir_param.input, properties=[
|
||||
schema.RepeatedUnorderedProperty("foo", "bar"),
|
||||
]),
|
||||
]) == dbscheme.Scheme(
|
||||
src=schema_file.name,
|
||||
includes=[],
|
||||
declarations=[
|
||||
dbscheme.Table(
|
||||
name="objects",
|
||||
columns=[
|
||||
dbscheme.Column('id', '@object', binding=True),
|
||||
], dir=dir_param.expected,
|
||||
),
|
||||
dbscheme.Table(
|
||||
name="object_foos",
|
||||
columns=[
|
||||
dbscheme.Column('id', '@object'),
|
||||
dbscheme.Column('foo', 'bar'),
|
||||
], dir=dir_param.expected,
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
def test_final_class_with_predicate_field(generate, dir_param):
|
||||
assert generate([
|
||||
schema.Class("Object", group=dir_param.input, properties=[
|
||||
|
|
Загрузка…
Ссылка в новой задаче