From cb9215504c0131facc8ed1b22746d3dc53e628b9 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 25 Sep 2019 17:42:51 -0400 Subject: Unify generation between Core and ORM query generation is to be enhanced to include caching functionality, so ensure that Query and all generative in Core (e.g. select, DML etc) are using the same generations system. Additionally, deprecate Select.append methods and state Select methods independently of their append versions. Mutability of expression objects is a special case only when generating new objects during a visit. Fixes: #4637 Change-Id: I3dfac00d5e0f710c833b236f7a0913e1ca24dde4 --- lib/sqlalchemy/sql/base.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'lib/sqlalchemy/sql/base.py') diff --git a/lib/sqlalchemy/sql/base.py b/lib/sqlalchemy/sql/base.py index da384bdab..7e9199bfa 100644 --- a/lib/sqlalchemy/sql/base.py +++ b/lib/sqlalchemy/sql/base.py @@ -43,13 +43,18 @@ def _from_objects(*elements): return itertools.chain(*[element._from_objects for element in elements]) -@util.decorator -def _generative(fn, *args, **kw): - """Mark a method as generative.""" +def _generative(fn): + @util.decorator + def _generative(fn, *args, **kw): + """Mark a method as generative.""" - self = args[0]._generate() - fn(self, *args[1:], **kw) - return self + self = args[0]._generate() + fn(self, *args[1:], **kw) + return self + + decorated = _generative(fn) + decorated.non_generative = fn + return decorated def _clone(element, **kw): -- cgit v1.2.1