sqlobjects 2.0.1__py3-none-any.whl → 2.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sqlobjects/__init__.py +1 -1
- sqlobjects/_compat.py +61 -0
- sqlobjects/cascade.py +22 -31
- sqlobjects/contrib/asgi.py +5 -3
- sqlobjects/database/manager.py +44 -30
- sqlobjects/expressions/aggregate.py +144 -83
- sqlobjects/expressions/scalar.py +5 -9
- sqlobjects/fields/__init__.py +2 -0
- sqlobjects/fields/core.py +5 -4
- sqlobjects/fields/proxies.py +78 -30
- sqlobjects/fields/relations/descriptors.py +4 -2
- sqlobjects/fields/relations/prefetch.py +62 -63
- sqlobjects/fields/relations/utils.py +50 -11
- sqlobjects/internal/results.py +1 -1
- sqlobjects/metadata.py +110 -37
- sqlobjects/mixins.py +24 -5
- sqlobjects/model.py +45 -72
- sqlobjects/objects/bulk.py +159 -245
- sqlobjects/objects/core.py +62 -58
- sqlobjects/objects/upsert.py +85 -8
- sqlobjects/queries/builder.py +77 -145
- sqlobjects/queries/dialect.py +4 -4
- sqlobjects/queries/executor.py +105 -209
- sqlobjects/queryset.py +64 -45
- sqlobjects/session.py +342 -38
- sqlobjects/signals.py +60 -33
- sqlobjects/sql_logging.py +107 -11
- sqlobjects/utils/naming.py +17 -1
- {sqlobjects-2.0.1.data → sqlobjects-2.1.1.data}/data/share/sqlobjects/rules/01-database-session-guide.md +54 -7
- {sqlobjects-2.0.1.data → sqlobjects-2.1.1.data}/data/share/sqlobjects/rules/02-model-definition-guide.md +25 -0
- {sqlobjects-2.0.1.data → sqlobjects-2.1.1.data}/data/share/sqlobjects/rules/03-query-operations-guide.md +47 -13
- {sqlobjects-2.0.1.data → sqlobjects-2.1.1.data}/data/share/sqlobjects/rules/04-crud-operations-guide.md +1 -1
- {sqlobjects-2.0.1.data → sqlobjects-2.1.1.data}/data/share/sqlobjects/rules/05-relationships-guide.md +48 -23
- {sqlobjects-2.0.1.data → sqlobjects-2.1.1.data}/data/share/sqlobjects/rules/06-validation-signals-guide.md +47 -12
- {sqlobjects-2.0.1.data → sqlobjects-2.1.1.data}/data/share/sqlobjects/rules/07-performance-guide.md +3 -3
- {sqlobjects-2.0.1.dist-info → sqlobjects-2.1.1.dist-info}/METADATA +17 -8
- sqlobjects-2.1.1.dist-info/RECORD +76 -0
- {sqlobjects-2.0.1.dist-info → sqlobjects-2.1.1.dist-info}/WHEEL +1 -1
- sqlobjects-2.0.1.dist-info/RECORD +0 -75
- {sqlobjects-2.0.1.data → sqlobjects-2.1.1.data}/data/share/sqlobjects/rules/README.md +0 -0
- {sqlobjects-2.0.1.dist-info → sqlobjects-2.1.1.dist-info}/entry_points.txt +0 -0
- {sqlobjects-2.0.1.dist-info → sqlobjects-2.1.1.dist-info}/licenses/LICENSE +0 -0
- {sqlobjects-2.0.1.dist-info → sqlobjects-2.1.1.dist-info}/top_level.txt +0 -0
sqlobjects/fields/proxies.py
CHANGED
|
@@ -15,12 +15,13 @@ from typing import TYPE_CHECKING, Any, Generic, TypeVar
|
|
|
15
15
|
|
|
16
16
|
from sqlalchemy import join, select
|
|
17
17
|
|
|
18
|
-
from ..exceptions import DeferredFieldError
|
|
18
|
+
from ..exceptions import DeferredFieldError, PrimaryKeyError, QueryError
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
if TYPE_CHECKING:
|
|
22
22
|
from ..mixins import DeferredLoadingMixin
|
|
23
23
|
from ..model import ObjectModel
|
|
24
|
+
from ..queryset import QuerySet
|
|
24
25
|
from .relations.descriptors import RelationshipDescriptor
|
|
25
26
|
|
|
26
27
|
|
|
@@ -379,40 +380,87 @@ class ManyToManyRelation(RelatedCollection[T]):
|
|
|
379
380
|
return f"ManyToManyRelation(field='{self.property.name}')"
|
|
380
381
|
|
|
381
382
|
|
|
382
|
-
class RelatedQuerySet(BaseRelated[T]):
|
|
383
|
-
"""
|
|
383
|
+
class RelatedQuerySet(BaseRelated[list[T]]):
|
|
384
|
+
"""Build fresh, parent-scoped queries for lazy='dynamic' collections."""
|
|
384
385
|
|
|
385
|
-
def
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
def _get_queryset(self) -> Any:
|
|
393
|
-
"""Lazy initialize QuerySet."""
|
|
394
|
-
if not self._initialized:
|
|
395
|
-
# QuerySet will be implemented in Layer 5
|
|
396
|
-
self._queryset = None
|
|
397
|
-
self._initialized = True
|
|
398
|
-
return self._queryset
|
|
386
|
+
def _reference_value(self, field: str) -> Any:
|
|
387
|
+
value = getattr(self.instance, field)
|
|
388
|
+
if isinstance(value, DeferredObject):
|
|
389
|
+
raise DeferredFieldError(
|
|
390
|
+
f"Load relationship key '{field}' before querying dynamic relationship '{self.property.name}'"
|
|
391
|
+
)
|
|
392
|
+
return value
|
|
399
393
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
self._cached_value = self._get_queryset()
|
|
403
|
-
self._loaded = True
|
|
394
|
+
def _get_queryset(self) -> "QuerySet[T]":
|
|
395
|
+
from ..queryset import QuerySet
|
|
404
396
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
397
|
+
if self.property.primaryjoin is not None or self.property.secondaryjoin is not None:
|
|
398
|
+
raise QueryError("Dynamic relationships do not support custom join conditions")
|
|
399
|
+
info = self._get_relationship_info()
|
|
400
|
+
if not info or info["type"] not in {"reverse_fk", "many_to_many"}:
|
|
401
|
+
raise QueryError(f"Dynamic relationship '{self.property.name}' requires a resolved collection relationship")
|
|
402
|
+
if not self.instance._has_primary_key_values():
|
|
403
|
+
raise PrimaryKeyError("A dynamic relationship requires a parent with complete primary key values")
|
|
404
|
+
|
|
405
|
+
model = info["related_model"]
|
|
406
|
+
table = model.get_table()
|
|
407
|
+
queryset = QuerySet(table, model, self.instance._state_manager.get_bound_session())
|
|
408
|
+
ordering = self.property.order_by
|
|
409
|
+
if ordering is not None:
|
|
410
|
+
queryset = queryset.order_by(*([ordering] if isinstance(ordering, str) else ordering))
|
|
411
|
+
|
|
412
|
+
if info["type"] == "many_to_many":
|
|
413
|
+
value = self._reference_value(info["left_ref_field"])
|
|
414
|
+
if value is None:
|
|
415
|
+
return queryset.none()
|
|
416
|
+
through = self.instance.__class__.__registry__.tables[info["through_table"]]
|
|
417
|
+
# Membership avoids duplicate target rows, even if the association
|
|
418
|
+
# table permits repeated links to the same target.
|
|
419
|
+
members = select(through.c[info["right_field"]]).where(through.c[info["left_field"]] == value)
|
|
420
|
+
return queryset.filter(table.c[info["right_ref_field"]].in_(members))
|
|
421
|
+
|
|
422
|
+
conditions = []
|
|
423
|
+
for foreign_key, reference in zip(info["foreign_key_fields"], info["ref_fields"], strict=True):
|
|
424
|
+
value = self._reference_value(reference)
|
|
425
|
+
if value is None:
|
|
426
|
+
return queryset.none()
|
|
427
|
+
conditions.append(table.c[foreign_key] == value)
|
|
428
|
+
if not conditions:
|
|
429
|
+
raise QueryError(f"Dynamic relationship '{self.property.name}' has no foreign key mapping")
|
|
430
|
+
return queryset.filter(*conditions)
|
|
431
|
+
|
|
432
|
+
async def fetch(self) -> list[T]:
|
|
433
|
+
"""Read the current related rows without caching a materialized list."""
|
|
434
|
+
return await self._get_queryset().all()
|
|
409
435
|
|
|
410
436
|
def __getattr__(self, name: str) -> Any:
|
|
411
|
-
"""Proxy
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
437
|
+
"""Proxy public QuerySet methods.
|
|
438
|
+
|
|
439
|
+
Unknown and private names raise AttributeError so ``hasattr()``,
|
|
440
|
+
``getattr(obj, name, default)``, ``copy``/``pickle`` protocol lookups and
|
|
441
|
+
``to_dict(safe_access=True)`` keep working; only real QuerySet methods
|
|
442
|
+
build a parent-scoped query, which requires a saved parent.
|
|
443
|
+
"""
|
|
444
|
+
from ..queryset import QuerySet
|
|
445
|
+
|
|
446
|
+
if name.startswith("_") or not hasattr(QuerySet, name):
|
|
447
|
+
raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'")
|
|
448
|
+
return getattr(self._get_queryset(), name)
|
|
449
|
+
|
|
450
|
+
def __getitem__(self, key) -> "QuerySet[T]":
|
|
451
|
+
return self._get_queryset()[key]
|
|
452
|
+
|
|
453
|
+
def __aiter__(self):
|
|
454
|
+
return self._get_queryset().iterator()
|
|
455
|
+
|
|
456
|
+
def __iter__(self):
|
|
457
|
+
raise TypeError("Use async iteration or await relation.fetch() for a dynamic relationship")
|
|
458
|
+
|
|
459
|
+
def __len__(self):
|
|
460
|
+
raise TypeError("Use await relation.count() for a dynamic relationship")
|
|
461
|
+
|
|
462
|
+
def __bool__(self):
|
|
463
|
+
raise TypeError("Use await relation.exists() for a dynamic relationship")
|
|
416
464
|
|
|
417
465
|
def __str__(self):
|
|
418
466
|
return f"<RelatedQuerySet: {self.property.name}>"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import TYPE_CHECKING, Generic, TypeVar, overload
|
|
1
|
+
from typing import TYPE_CHECKING, Generic, TypeVar, cast, overload
|
|
2
2
|
|
|
3
3
|
from ...cascade import OnDelete
|
|
4
4
|
|
|
@@ -144,7 +144,9 @@ class RelationshipDescriptor(Generic[T]):
|
|
|
144
144
|
)
|
|
145
145
|
|
|
146
146
|
if self.property.lazy == "dynamic":
|
|
147
|
-
|
|
147
|
+
# T describes the collection here; RelatedQuerySet's parameter is
|
|
148
|
+
# its element type, determined by the resolved relationship.
|
|
149
|
+
return cast("BaseRelated[T]", RelatedQuerySet(instance, self))
|
|
148
150
|
elif self.property.lazy == "noload":
|
|
149
151
|
return NoLoadRelation(instance, self)
|
|
150
152
|
elif self.property.lazy == "raise":
|
|
@@ -9,54 +9,45 @@ class PrefetchHandler:
|
|
|
9
9
|
def __init__(self, session):
|
|
10
10
|
self.session = session
|
|
11
11
|
|
|
12
|
-
async def handle_prefetch_relationships(self, instances, prefetch_relationships):
|
|
13
|
-
if not instances
|
|
12
|
+
async def handle_prefetch_relationships(self, instances, prefetch_relationships, configs=None):
|
|
13
|
+
if not instances:
|
|
14
14
|
return instances
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
for path in sorted(prefetch_relationships):
|
|
16
|
+
name, _, remainder = path.partition("__")
|
|
17
|
+
info = RelationshipAnalyzer.analyze_relationship(instances[0].__class__, name)
|
|
18
|
+
if not info:
|
|
19
|
+
raise ValueError(f"Invalid relationship '{name}'")
|
|
20
|
+
custom = (configs or {}).get(path) if not remainder else None
|
|
21
|
+
await self._prefetch_single_relationship(instances, name, info, custom)
|
|
22
|
+
if remainder:
|
|
23
|
+
related = []
|
|
24
|
+
for instance in instances:
|
|
25
|
+
value = instance._state_manager.get_object_cache().get(name)
|
|
26
|
+
related.extend(value if isinstance(value, list) else [value] if value is not None else [])
|
|
27
|
+
await self.handle_prefetch_relationships(
|
|
28
|
+
related, {remainder}, {remainder: configs[path]} if configs and path in configs else None
|
|
29
|
+
)
|
|
21
30
|
return instances
|
|
22
31
|
|
|
23
|
-
async def _prefetch_single_relationship(self, instances, relationship_name, relationship_info):
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
relationship_name,
|
|
40
|
-
info["related_model"],
|
|
41
|
-
info["ref_fields"],
|
|
42
|
-
info["foreign_key_fields"],
|
|
43
|
-
None,
|
|
44
|
-
)
|
|
45
|
-
elif rel_type == "many_to_one":
|
|
46
|
-
info = relationship_info
|
|
47
|
-
await self._prefetch_by_fields(
|
|
48
|
-
instances,
|
|
49
|
-
relationship_name,
|
|
50
|
-
info["related_model"],
|
|
51
|
-
info["foreign_key_fields"],
|
|
52
|
-
info["ref_fields"],
|
|
53
|
-
None,
|
|
54
|
-
)
|
|
55
|
-
elif rel_type == "many_to_many":
|
|
56
|
-
await self._prefetch_many_to_many(instances, relationship_name, relationship_info)
|
|
32
|
+
async def _prefetch_single_relationship(self, instances, relationship_name, relationship_info, queryset=None):
|
|
33
|
+
info = relationship_info
|
|
34
|
+
if queryset is not None and queryset._model_class is not info["related_model"]:
|
|
35
|
+
raise ValueError(f"Prefetch queryset model does not match relationship '{relationship_name}'")
|
|
36
|
+
if info["type"] == "many_to_many":
|
|
37
|
+
await self._prefetch_many_to_many(instances, relationship_name, info, queryset)
|
|
38
|
+
return
|
|
39
|
+
local, remote = (
|
|
40
|
+
(info["foreign_key_fields"], info["ref_fields"])
|
|
41
|
+
if info["type"] == "many_to_one"
|
|
42
|
+
else (info["ref_fields"], info["foreign_key_fields"])
|
|
43
|
+
)
|
|
44
|
+
empty = [] if info["type"] == "reverse_fk" else None
|
|
45
|
+
await self._prefetch_by_fields(
|
|
46
|
+
instances, relationship_name, info["related_model"], local, remote, empty, queryset
|
|
47
|
+
)
|
|
57
48
|
|
|
58
49
|
async def _prefetch_by_fields(
|
|
59
|
-
self, instances, relationship_name, related_model, lookup_fields, group_fields, empty
|
|
50
|
+
self, instances, relationship_name, related_model, lookup_fields, group_fields, empty, queryset=None
|
|
60
51
|
):
|
|
61
52
|
"""Unified prefetch for FK-based relationships."""
|
|
62
53
|
composite = len(lookup_fields) > 1
|
|
@@ -74,13 +65,21 @@ class PrefetchHandler:
|
|
|
74
65
|
inst._update_cache(relationship_name, [] if isinstance(empty, list) else empty)
|
|
75
66
|
return
|
|
76
67
|
|
|
68
|
+
qs = related_model.objects.using(self.session) if queryset is None else queryset
|
|
69
|
+
if queryset is not None and queryset._db_or_session is None:
|
|
70
|
+
qs = queryset.using(self.session)
|
|
71
|
+
if queryset is not None and (
|
|
72
|
+
queryset._builder.limits is not None or queryset._builder.offset_value is not None
|
|
73
|
+
):
|
|
74
|
+
raise ValueError(
|
|
75
|
+
"Sliced prefetch querysets are not supported; a global limit would truncate related collections"
|
|
76
|
+
)
|
|
77
|
+
if queryset is not None and queryset._builder.selected_fields:
|
|
78
|
+
qs = qs.only(*group_fields)
|
|
77
79
|
if composite:
|
|
78
|
-
|
|
79
|
-
qs = related_model.objects.using(self.session).filter(tuple_(*cols).in_(lookup_values))
|
|
80
|
+
qs = qs.filter(tuple_(*(getattr(related_model, f) for f in group_fields)).in_(lookup_values))
|
|
80
81
|
else:
|
|
81
|
-
qs =
|
|
82
|
-
getattr(related_model, group_fields[0]).in_(lookup_values)
|
|
83
|
-
)
|
|
82
|
+
qs = qs.filter(getattr(related_model, group_fields[0]).in_(lookup_values))
|
|
84
83
|
related_objects = await qs.all()
|
|
85
84
|
|
|
86
85
|
if isinstance(empty, list):
|
|
@@ -94,7 +93,7 @@ class PrefetchHandler:
|
|
|
94
93
|
for inst in instances:
|
|
95
94
|
inst._update_cache(relationship_name, related_map.get(make_key(inst, lookup_fields)))
|
|
96
95
|
|
|
97
|
-
async def _prefetch_many_to_many(self, instances, relationship_name, relationship_info):
|
|
96
|
+
async def _prefetch_many_to_many(self, instances, relationship_name, relationship_info, queryset=None):
|
|
98
97
|
"""Prefetch many-to-many via through table."""
|
|
99
98
|
related_model = relationship_info["related_model"]
|
|
100
99
|
through_table = relationship_info["through_table"]
|
|
@@ -111,27 +110,27 @@ class PrefetchHandler:
|
|
|
111
110
|
inst._update_cache(relationship_name, [])
|
|
112
111
|
return
|
|
113
112
|
|
|
114
|
-
|
|
115
|
-
if not through_model:
|
|
116
|
-
return
|
|
113
|
+
from sqlalchemy import select
|
|
117
114
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
.
|
|
121
|
-
.all()
|
|
115
|
+
table = instances[0].__class__.__registry__.tables[through_table]
|
|
116
|
+
result = await self.session.execute(
|
|
117
|
+
select(table.c[left_field], table.c[right_field]).where(table.c[left_field].in_(instance_values))
|
|
122
118
|
)
|
|
123
|
-
|
|
119
|
+
through_objects = result.fetchall()
|
|
124
120
|
related_values = [getattr(obj, right_field) for obj in through_objects]
|
|
125
121
|
if not related_values:
|
|
126
122
|
for inst in instances:
|
|
127
123
|
inst._update_cache(relationship_name, [])
|
|
128
124
|
return
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
.
|
|
134
|
-
|
|
125
|
+
qs = related_model.objects.using(self.session) if queryset is None else queryset
|
|
126
|
+
if queryset is not None:
|
|
127
|
+
if queryset._builder.limits is not None or queryset._builder.offset_value is not None:
|
|
128
|
+
raise ValueError("Sliced prefetch querysets are not supported")
|
|
129
|
+
if queryset._db_or_session is None:
|
|
130
|
+
qs = qs.using(self.session)
|
|
131
|
+
if queryset._builder.selected_fields:
|
|
132
|
+
qs = qs.only(right_ref_field)
|
|
133
|
+
related_objects = await qs.filter(getattr(related_model, right_ref_field).in_(related_values)).all()
|
|
135
134
|
|
|
136
135
|
related_map = {getattr(obj, right_ref_field): obj for obj in related_objects}
|
|
137
136
|
|
|
@@ -172,18 +172,31 @@ class RelationshipAnalyzer:
|
|
|
172
172
|
@staticmethod
|
|
173
173
|
@lru_cache(maxsize=256)
|
|
174
174
|
def analyze_relationship(model_class, relationship_name):
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
175
|
+
if hasattr(model_class, relationship_name):
|
|
176
|
+
field_attr = getattr(model_class, relationship_name)
|
|
177
|
+
if hasattr(field_attr, "property"):
|
|
178
|
+
return RelationshipAnalyzer._extract_relationship_info(model_class, field_attr.property)
|
|
179
|
+
# Preserve the conventional author_id -> author shortcut, using its actual
|
|
180
|
+
# foreign-key target rather than guessing a model or referenced column.
|
|
181
|
+
table = model_class.get_table()
|
|
182
|
+
column = table.c.get(f"{relationship_name}_id")
|
|
183
|
+
if column is not None and len(column.foreign_keys) == 1:
|
|
184
|
+
foreign_key = next(iter(column.foreign_keys))
|
|
185
|
+
related_model = model_class.__registry__.get_model_by_table(foreign_key.column.table.name)
|
|
186
|
+
if related_model is not None:
|
|
187
|
+
return {
|
|
188
|
+
"type": "many_to_one",
|
|
189
|
+
"related_model": related_model,
|
|
190
|
+
"foreign_key_fields": [column.name],
|
|
191
|
+
"ref_fields": [foreign_key.column.name],
|
|
192
|
+
}
|
|
193
|
+
return None
|
|
183
194
|
|
|
184
195
|
@staticmethod
|
|
185
196
|
def _extract_relationship_info(model_class, prop):
|
|
186
|
-
related_model =
|
|
197
|
+
related_model = (
|
|
198
|
+
model_class.__registry__.get_model(prop.argument) if isinstance(prop.argument, str) else prop.argument
|
|
199
|
+
)
|
|
187
200
|
if not related_model:
|
|
188
201
|
return None
|
|
189
202
|
|
|
@@ -191,7 +204,31 @@ class RelationshipAnalyzer:
|
|
|
191
204
|
if prop.secondary:
|
|
192
205
|
m2m_def = getattr(prop, "m2m_definition", None)
|
|
193
206
|
if not m2m_def:
|
|
194
|
-
|
|
207
|
+
through = model_class.__registry__.tables.get(prop.secondary)
|
|
208
|
+
if through is None:
|
|
209
|
+
raise ValueError(f"Unknown association table '{prop.secondary}'")
|
|
210
|
+
|
|
211
|
+
def referencing(table):
|
|
212
|
+
return [
|
|
213
|
+
(col.name, fk.column.name)
|
|
214
|
+
for col in through.c
|
|
215
|
+
for fk in col.foreign_keys
|
|
216
|
+
if fk.column.table is table
|
|
217
|
+
]
|
|
218
|
+
|
|
219
|
+
left = referencing(model_class.get_table())
|
|
220
|
+
right = referencing(related_model.get_table())
|
|
221
|
+
if len(left) != 1 or len(right) != 1:
|
|
222
|
+
raise ValueError("Ambiguous association table; supply an explicit M2MTable definition")
|
|
223
|
+
m2m_def = M2MTable(
|
|
224
|
+
prop.secondary,
|
|
225
|
+
model_class.__name__,
|
|
226
|
+
related_model.__name__,
|
|
227
|
+
left[0][0],
|
|
228
|
+
right[0][0],
|
|
229
|
+
left[0][1],
|
|
230
|
+
right[0][1],
|
|
231
|
+
)
|
|
195
232
|
return {
|
|
196
233
|
"type": "many_to_many",
|
|
197
234
|
"related_model": related_model,
|
|
@@ -314,7 +351,9 @@ class RelationshipAnalyzer:
|
|
|
314
351
|
for subclass in ObjectModel.__subclasses__():
|
|
315
352
|
if hasattr(subclass, "__registry__"):
|
|
316
353
|
try:
|
|
317
|
-
|
|
354
|
+
model = subclass.__registry__.get_model(argument)
|
|
355
|
+
if model is not None:
|
|
356
|
+
return model
|
|
318
357
|
except Exception:
|
|
319
358
|
continue
|
|
320
359
|
|
sqlobjects/internal/results.py
CHANGED