@@ -19,42 +19,42 @@ def dbtype(typename):
1919def cls_to_dbscheme (cls : schema .Class ):
2020 """ Yield all dbscheme entities needed to model class `cls` """
2121 if cls .derived :
22- yield DbUnion (dbtype (cls .name ), (dbtype (c ) for c in cls .derived ))
22+ yield Union (dbtype (cls .name ), (dbtype (c ) for c in cls .derived ))
2323 # output a table specific to a class only if it is a leaf class or it has 1-to-1 properties
2424 # Leaf classes need a table to bind the `@` ids
2525 # 1-to-1 properties are added to a class specific table
2626 # in other cases, separate tables are used for the properties, and a class specific table is unneeded
2727 if not cls .derived or any (f .is_single for f in cls .properties ):
2828 binding = not cls .derived
29- keyset = DbKeySet (["id" ]) if cls .derived else None
30- yield DbTable (
29+ keyset = KeySet (["id" ]) if cls .derived else None
30+ yield Table (
3131 keyset = keyset ,
3232 name = inflection .tableize (cls .name ),
3333 columns = [
34- DbColumn ("id" , type = dbtype (cls .name ), binding = binding ),
34+ Column ("id" , type = dbtype (cls .name ), binding = binding ),
3535 ] + [
36- DbColumn (f .name , dbtype (f .type )) for f in cls .properties if f .is_single
36+ Column (f .name , dbtype (f .type )) for f in cls .properties if f .is_single
3737 ]
3838 )
3939 # use property-specific tables for 1-to-many and 1-to-at-most-1 properties
4040 for f in cls .properties :
4141 if f .is_optional :
42- yield DbTable (
43- keyset = DbKeySet (["id" ]),
42+ yield Table (
43+ keyset = KeySet (["id" ]),
4444 name = inflection .tableize (f"{ cls .name } _{ f .name } " ),
4545 columns = [
46- DbColumn ("id" , type = dbtype (cls .name )),
47- DbColumn (f .name , dbtype (f .type )),
46+ Column ("id" , type = dbtype (cls .name )),
47+ Column (f .name , dbtype (f .type )),
4848 ],
4949 )
5050 elif f .is_repeated :
51- yield DbTable (
52- keyset = DbKeySet (["id" , "index" ]),
51+ yield Table (
52+ keyset = KeySet (["id" , "index" ]),
5353 name = inflection .tableize (f"{ cls .name } _{ f .name } " ),
5454 columns = [
55- DbColumn ("id" , type = dbtype (cls .name )),
56- DbColumn ("index" , type = "int" ),
57- DbColumn (inflection .singularize (f .name ), dbtype (f .type )),
55+ Column ("id" , type = dbtype (cls .name )),
56+ Column ("index" , type = "int" ),
57+ Column (inflection .singularize (f .name ), dbtype (f .type )),
5858 ]
5959 )
6060
@@ -68,7 +68,7 @@ def get_includes(data: schema.Schema, include_dir: pathlib.Path):
6868 for inc in data .includes :
6969 inc = include_dir / inc
7070 with open (inc ) as inclusion :
71- includes .append (DbSchemeInclude (src = inc .relative_to (paths .swift_dir ), data = inclusion .read ()))
71+ includes .append (SchemeInclude (src = inc .relative_to (paths .swift_dir ), data = inclusion .read ()))
7272 return includes
7373
7474
@@ -78,7 +78,7 @@ def generate(opts, renderer):
7878
7979 data = schema .load (input )
8080
81- dbscheme = DbScheme (src = input .relative_to (paths .swift_dir ),
81+ dbscheme = Scheme (src = input .relative_to (paths .swift_dir ),
8282 includes = get_includes (data , include_dir = input .parent ),
8383 declarations = get_declarations (data ))
8484
0 commit comments