@@ -1013,5 +1013,38 @@ def test_hideable_property(generate_classes):
10131013 }
10141014
10151015
1016+ def test_property_with_custom_db_table_name (generate_classes ):
1017+ assert generate_classes ([
1018+ schema .Class ("Obj" , properties = [
1019+ schema .OptionalProperty ("x" , "a" , pragmas = {"ql_db_table_name" : "foo" }),
1020+ schema .RepeatedProperty ("y" , "b" , pragmas = {"ql_db_table_name" : "bar" }),
1021+ schema .RepeatedOptionalProperty ("z" , "c" , pragmas = {"ql_db_table_name" : "baz" }),
1022+ schema .PredicateProperty ("p" , pragmas = {"ql_db_table_name" : "hello" }),
1023+ schema .RepeatedUnorderedProperty ("q" , "d" , pragmas = {"ql_db_table_name" : "world" }),
1024+ ]),
1025+ ]) == {
1026+ "Obj.qll" : (a_ql_class_public (name = "Obj" ),
1027+ a_ql_stub (name = "Obj" ),
1028+ a_ql_class (name = "Obj" , final = True , properties = [
1029+ ql .Property (singular = "X" , type = "a" , tablename = "foo" ,
1030+ tableparams = ["this" , "result" ],
1031+ is_optional = True , doc = "x of this obj" ),
1032+ ql .Property (singular = "Y" , plural = "Ys" , type = "b" , tablename = "bar" ,
1033+ tableparams = ["this" , "index" , "result" ],
1034+ doc = "y of this obj" , doc_plural = "ys of this obj" ),
1035+ ql .Property (singular = "Z" , plural = "Zs" , type = "c" , tablename = "baz" ,
1036+ tableparams = ["this" , "index" , "result" ],
1037+ is_optional = True , doc = "z of this obj" , doc_plural = "zs of this obj" ),
1038+ ql .Property (singular = "p" , type = "predicate" , tablename = "hello" ,
1039+ tableparams = ["this" ], is_predicate = True ,
1040+ doc = "this obj p" ),
1041+ ql .Property (singular = "Q" , plural = "Qs" , type = "d" , tablename = "world" ,
1042+ tableparams = ["this" , "result" ], is_unordered = True ,
1043+ doc = "q of this obj" , doc_plural = "qs of this obj" ),
1044+ ],
1045+ imports = [stub_import_prefix + "Obj" ])),
1046+ }
1047+
1048+
10161049if __name__ == '__main__' :
10171050 sys .exit (pytest .main ([__file__ ] + sys .argv [1 :]))
0 commit comments