Skip to content

Commit 165ac3e

Browse files
committed
Codegen: define and propagate synth property flag
1 parent 242d263 commit 165ac3e

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

misc/codegen/generators/qlgen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def get_ql_property(cls: schema.Class, prop: schema.Property, prev_child: str =
111111
is_predicate=prop.is_predicate,
112112
is_unordered=prop.is_unordered,
113113
description=prop.description,
114-
synth=bool(cls.ipa),
114+
synth=bool(cls.ipa) or prop.synth,
115115
)
116116
if prop.is_single:
117117
args.update(

misc/codegen/lib/schema.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class Kind(Enum):
3434
pragmas: List[str] = field(default_factory=list)
3535
doc: Optional[str] = None
3636
description: List[str] = field(default_factory=list)
37+
synth: bool = False
3738

3839
@property
3940
def is_single(self) -> bool:

misc/codegen/test/test_qlgen.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -891,5 +891,19 @@ def test_stub_on_class_with_ipa_on_arguments(generate_classes):
891891
}
892892

893893

894+
def test_synth_property(generate_classes):
895+
assert generate_classes([
896+
schema.Class("MyObject", properties=[
897+
schema.SingleProperty("foo", "bar", synth=True)]),
898+
]) == {
899+
"MyObject.qll": (a_ql_stub(name="MyObject", base_import=gen_import_prefix + "MyObject"),
900+
a_ql_class(name="MyObject", final=True,
901+
properties=[
902+
ql.Property(singular="Foo", type="bar", tablename="my_objects", synth=True,
903+
tableparams=["this", "result"], doc="foo of this my object"),
904+
])),
905+
}
906+
907+
894908
if __name__ == '__main__':
895909
sys.exit(pytest.main([__file__] + sys.argv[1:]))

0 commit comments

Comments
 (0)