summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/dynamic.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2019-12-01 17:24:27 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2020-05-24 11:54:08 -0400
commitdce8c7a125cb99fad62c76cd145752d5afefae36 (patch)
tree352dfa2c38005207ca64f45170bbba2c0f8c927e /lib/sqlalchemy/orm/dynamic.py
parent1502b5b3e4e4b93021eb927a6623f288ef006ba6 (diff)
downloadsqlalchemy-dce8c7a125cb99fad62c76cd145752d5afefae36.tar.gz
Unify Query and select() , move all processing to compile phase
Convert Query to do virtually all compile state computation in the _compile_context() phase, and organize it all such that a plain select() construct may also be used as the source of information in order to generate ORM query state. This makes it such that Query is not needed except for its additional methods like from_self() which are all to be deprecated. The construction of ORM state will occur beyond the caching boundary when the new execution model is integrated. future select() gains a working join() and filter_by() method. as we continue to rebase and merge each commit in the steps, callcounts continue to bump around. will have to look at the final result when it's all in. References: #5159 References: #4705 References: #4639 References: #4871 References: #5010 Change-Id: I19e05b3424b07114cce6c439b05198ac47f7ac10
Diffstat (limited to 'lib/sqlalchemy/orm/dynamic.py')
-rw-r--r--lib/sqlalchemy/orm/dynamic.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/lib/sqlalchemy/orm/dynamic.py b/lib/sqlalchemy/orm/dynamic.py
index 2a3ef54dd..adc976e32 100644
--- a/lib/sqlalchemy/orm/dynamic.py
+++ b/lib/sqlalchemy/orm/dynamic.py
@@ -279,10 +279,21 @@ class AppenderMixin(object):
# doesn't fail, and secondary is then in _from_obj[1].
self._from_obj = (prop.mapper.selectable, prop.secondary)
- self._criterion = prop._with_parent(instance, alias_secondary=False)
+ self._where_criteria += (
+ prop._with_parent(instance, alias_secondary=False),
+ )
if self.attr.order_by:
- self._order_by = self.attr.order_by
+
+ if (
+ self._order_by_clauses is False
+ or self._order_by_clauses is None
+ ):
+ self._order_by_clauses = tuple(self.attr.order_by)
+ else:
+ self._order_by_clauses = self._order_by_clauses + tuple(
+ self.attr.order_by
+ )
def session(self):
sess = object_session(self.instance)
@@ -354,9 +365,9 @@ class AppenderMixin(object):
else:
query = sess.query(self.attr.target_mapper)
- query._criterion = self._criterion
+ query._where_criteria = self._where_criteria
query._from_obj = self._from_obj
- query._order_by = self._order_by
+ query._order_by_clauses = self._order_by_clauses
return query