diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-03-06 16:04:46 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-03-10 16:55:03 -0400 |
| commit | 693938dd6fb2f3ee3e031aed4c62355ac97f3ceb (patch) | |
| tree | 94701d7df1b7274151800efd6ca996e1f4203916 /lib/sqlalchemy/engine/base.py | |
| parent | 851fb8f5a661c66ee76308181118369c8c4df9e0 (diff) | |
| download | sqlalchemy-693938dd6fb2f3ee3e031aed4c62355ac97f3ceb.tar.gz | |
Rework select(), CompoundSelect() in terms of CompileState
Continuation of I408e0b8be91fddd77cf279da97f55020871f75a9
- add an options() method to the base Generative construct.
this will be where ORM options can go
- Change Null, False_, True_ to be singletons, so that
we aren't instantiating them and having to use isinstance.
The previous issue with this was that they would produce dupe
labels in SELECT statements. Apply the duplicate column
logic, newly added in 1.4, to these objects as well as to
non-apply-labels SELECT statements in general as a means of
improving this.
- create a revised system for generating ClauseList compilation
constructs that simplfies up front creation to not actually
use ClauseList; a simple tuple is rendered by the compiler
using the same constrcution rules as what are used for
ClauseList but without creating the actual object. Apply
to Select, CompoundSelect, revise Update, Delete
- Select, CompoundSelect get an initial CompileState
implementation. All methods used only within compilation
are moved here
- refine update/insert/delete compile state to not require
an outside boolean
- refine and simplify Select._copy_internals
- rework bind(), which is going away, to not use some
of the internal traversal stuff
- remove "autocommit", "for_update" parameters from Select,
references #4643
- remove "autocommit" parameter from TextClause ,
references #4643
- add deprecation warnings for statement.execute(),
engine.execute(), statement.scalar(), engine.scalar().
Fixes: #5193
Change-Id: I04ca0152b046fd42c5054ba10f37e43fc6e5a57b
Diffstat (limited to 'lib/sqlalchemy/engine/base.py')
| -rw-r--r-- | lib/sqlalchemy/engine/base.py | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py index 3a0cfbbe9..598b43e7b 100644 --- a/lib/sqlalchemy/engine/base.py +++ b/lib/sqlalchemy/engine/base.py @@ -102,14 +102,6 @@ class Connection(Connectable): self.__transaction = None self.__savepoint_seq = 0 self.should_close_with_result = close_with_result - if close_with_result: - util.warn_deprecated_20( - '"Connectionless" execution, which refers to running ' - "SQL commands using the Engine.execute() (or " - "some_statement.execute()) method without " - "calling .connect() or .begin() to get a Connection, is " - "deprecated and will be removed SQLAlchemy 2.0" - ) self.__invalid = False self.__can_reconnect = True @@ -894,12 +886,13 @@ class Connection(Connectable): """ if self.__branch_from: - util.warn_deprecated( + util.warn_deprecated_20( "The .close() method on a so-called 'branched' connection is " "deprecated as of 1.4, as are 'branched' connections overall, " "and will be removed in a future release. If this is a " "default-handling function, don't close the connection." ) + try: del self.__connection except AttributeError: @@ -2243,6 +2236,13 @@ class Engine(Connectable, log.Identified): with self.connect() as conn: conn._run_ddl_visitor(visitorcallable, element, **kwargs) + @util.deprecated_20( + ":meth:`.Engine.execute`", + alternative="All statement execution in SQLAlchemy 2.0 is performed " + "by the :meth:`.Connection.execute` method of :class:`.Connection`, " + "or in the ORM by the :meth:`.Session.execute` method of " + ":class:`.Session`.", + ) def execute(self, statement, *multiparams, **params): """Executes the given construct and returns a :class:`.ResultProxy`. @@ -2261,6 +2261,14 @@ class Engine(Connectable, log.Identified): connection = self.connect(close_with_result=True) return connection.execute(statement, *multiparams, **params) + @util.deprecated_20( + ":meth:`.Engine.scalar`", + alternative="All statement execution in SQLAlchemy 2.0 is performed " + "by the :meth:`.Connection.execute` method of :class:`.Connection`, " + "or in the ORM by the :meth:`.Session.execute` method of " + ":class:`.Session`; the :meth:`.Result.scalar` method can then be " + "used to return a scalar result.", + ) def scalar(self, statement, *multiparams, **params): return self.execute(statement, *multiparams, **params).scalar() |
