diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-09-06 12:45:53 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-09-06 13:17:24 -0400 |
commit | fc48050e5d0c56fc5a6cd85679859e71961c59eb (patch) | |
tree | 78ade9f3586e12239023b2aa95510c653a004dd4 /lib/sqlalchemy/sql/selectable.py | |
parent | 5c39ef565bb63e4412c3c3d0e87330373c8926ce (diff) | |
download | sqlalchemy-fc48050e5d0c56fc5a6cd85679859e71961c59eb.tar.gz |
Adjustments to _copy_internals()
We are looking to build a generalization of copy_internals(),
so move out any special logic from these methods. Re-implement
and clarify rationale for the Alias doesnt copy a TableClause rule as
part of the adaption
traversal, establish that we forgot to build out comparison and cache
key for CTE, remove incomplete _copy_internals() from GenerativeSelect
(it doesn't handle the order_by_clause or group_by_clause, so is incomplete)
Change-Id: I95039f042503171aade4ba0fabc9b1598e3c49cf
Diffstat (limited to 'lib/sqlalchemy/sql/selectable.py')
-rw-r--r-- | lib/sqlalchemy/sql/selectable.py | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/lib/sqlalchemy/sql/selectable.py b/lib/sqlalchemy/sql/selectable.py index 97c49f8fc..00d3826b2 100644 --- a/lib/sqlalchemy/sql/selectable.py +++ b/lib/sqlalchemy/sql/selectable.py @@ -1247,13 +1247,10 @@ class AliasedReturnsRows(FromClause): self.element._generate_fromclause_column_proxies(self) def _copy_internals(self, clone=_clone, **kw): - # don't apply anything to an aliased Table - # for now. May want to drive this from - # the given **kw. - if isinstance(self.element, TableClause): - return - self._reset_exported() - self.element = clone(self.element, **kw) + element = clone(self.element, **kw) + if element is not self.element: + self._reset_exported() + self.element = element def get_children(self, column_collections=True, **kw): if column_collections: @@ -1509,6 +1506,9 @@ class CTE(Generative, HasSuffixes, AliasedReturnsRows): [clone(elem, **kw) for elem in self._restates] ) + def _cache_key(self, *arg, **kw): + raise NotImplementedError("TODO") + def alias(self, name=None, flat=False): """Return an :class:`.Alias` of this :class:`.CTE`. @@ -2738,10 +2738,7 @@ class GenerativeSelect(SelectBase): raise NotImplementedError() def _copy_internals(self, clone=_clone, **kw): - if self._limit_clause is not None: - self._limit_clause = clone(self._limit_clause, **kw) - if self._offset_clause is not None: - self._offset_clause = clone(self._offset_clause, **kw) + raise NotImplementedError() class CompoundSelect(GenerativeSelect): @@ -2987,12 +2984,13 @@ class CompoundSelect(GenerativeSelect): return self.selects[0].selected_columns def _copy_internals(self, clone=_clone, **kw): - super(CompoundSelect, self)._copy_internals(clone, **kw) self._reset_memoizations() self.selects = [clone(s, **kw) for s in self.selects] if hasattr(self, "_col_map"): del self._col_map for attr in ( + "_limit_clause", + "_offset_clause", "_order_by_clause", "_group_by_clause", "_for_update_arg", @@ -3568,7 +3566,6 @@ class Select(HasPrefixes, HasSuffixes, GenerativeSelect): return False def _copy_internals(self, clone=_clone, **kw): - super(Select, self)._copy_internals(clone, **kw) # Select() object has been cloned and probably adapted by the # given clone function. Apply the cloning function to internal @@ -3614,6 +3611,8 @@ class Select(HasPrefixes, HasSuffixes, GenerativeSelect): # present here. self._raw_columns = [clone(c, **kw) for c in self._raw_columns] for attr in ( + "_limit_clause", + "_offset_clause", "_whereclause", "_having", "_order_by_clause", |