diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-12-01 17:24:27 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-05-24 11:54:08 -0400 |
commit | dce8c7a125cb99fad62c76cd145752d5afefae36 (patch) | |
tree | 352dfa2c38005207ca64f45170bbba2c0f8c927e /lib/sqlalchemy/sql/annotation.py | |
parent | 1502b5b3e4e4b93021eb927a6623f288ef006ba6 (diff) | |
download | sqlalchemy-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/sql/annotation.py')
-rw-r--r-- | lib/sqlalchemy/sql/annotation.py | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/sqlalchemy/sql/annotation.py b/lib/sqlalchemy/sql/annotation.py index 891b8ae09..71d05f38f 100644 --- a/lib/sqlalchemy/sql/annotation.py +++ b/lib/sqlalchemy/sql/annotation.py @@ -31,7 +31,10 @@ class SupportsAnnotations(object): if isinstance(value, HasCacheKey) else value, ) - for key, value in self._annotations.items() + for key, value in [ + (key, self._annotations[key]) + for key in sorted(self._annotations) + ] ), ) @@ -51,6 +54,7 @@ class SupportsCloneAnnotations(SupportsAnnotations): new = self._clone() new._annotations = new._annotations.union(values) new.__dict__.pop("_annotations_cache_key", None) + new.__dict__.pop("_generate_cache_key", None) return new def _with_annotations(self, values): @@ -61,6 +65,7 @@ class SupportsCloneAnnotations(SupportsAnnotations): new = self._clone() new._annotations = util.immutabledict(values) new.__dict__.pop("_annotations_cache_key", None) + new.__dict__.pop("_generate_cache_key", None) return new def _deannotate(self, values=None, clone=False): @@ -76,7 +81,7 @@ class SupportsCloneAnnotations(SupportsAnnotations): # clone is used when we are also copying # the expression for a deep deannotation new = self._clone() - new._annotations = {} + new._annotations = util.immutabledict() new.__dict__.pop("_annotations_cache_key", None) return new else: @@ -156,6 +161,7 @@ class Annotated(object): def __init__(self, element, values): self.__dict__ = element.__dict__.copy() self.__dict__.pop("_annotations_cache_key", None) + self.__dict__.pop("_generate_cache_key", None) self.__element = element self._annotations = values self._hash = hash(element) @@ -169,6 +175,7 @@ class Annotated(object): clone = self.__class__.__new__(self.__class__) clone.__dict__ = self.__dict__.copy() clone.__dict__.pop("_annotations_cache_key", None) + clone.__dict__.pop("_generate_cache_key", None) clone._annotations = values return clone @@ -211,6 +218,13 @@ class Annotated(object): else: return hash(other) == hash(self) + @property + def entity_namespace(self): + if "entity_namespace" in self._annotations: + return self._annotations["entity_namespace"].entity_namespace + else: + return self.__element.entity_namespace + # hard-generate Annotated subclasses. this technique # is used instead of on-the-fly types (i.e. type.__new__()) |