Skip to content

Commit 80a6b52

Browse files
committed
Enable reflecting of ext types.
Reflect any types appearing in the extensions. We still hide built-in modules like `cfg`, `sys`, and `schema` from reflection to ORM. This also means types derived from these or links to them. Also clean up generated imports.
1 parent 616882c commit 80a6b52

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

gel/orm/introspection.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@
5050
and
5151
not .internal
5252
and
53-
not re_test('^(std|cfg|sys|schema)::', .name);
53+
not .from_alias
54+
and
55+
not re_test('^(std|cfg|sys|schema)::', .name)
56+
and
57+
not any(re_test('^(cfg|sys|schema)::', .ancestors.name));
5458
'''
5559

5660
MODULE_QUERY = '''

gel/orm/sqla.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,8 @@ def init_module(self, mod, modules):
124124
try:
125125
self.out = f
126126
self.write(MODELS_STUB)
127-
relimport = '.' * len(dirpath)
128-
self.write(f'from {relimport}._sqlabase import Base')
129-
self.write(f'from {relimport}._tables import *')
127+
self.write(f'from {self.basemodule}._sqlabase import Base')
128+
self.write(f'from {self.basemodule}._tables import *')
130129
yield f
131130
finally:
132131
self.out = None
@@ -201,11 +200,11 @@ def render_models(self, spec):
201200
self.render_link_table(rec)
202201

203202
for mod, maps in modules.items():
204-
with self.init_module(mod, modules):
205-
if not maps:
206-
# skip apparently empty modules
207-
continue
203+
if not maps:
204+
# skip apparently empty modules
205+
continue
208206

207+
with self.init_module(mod, modules):
209208
link_objects = sorted(
210209
maps.get('link_objects', {}).values(),
211210
key=lambda x: x['name'],

0 commit comments

Comments
 (0)