summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/persistence.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2020-06-26 16:15:19 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2020-07-08 11:05:11 -0400
commit91f376692d472a5bf0c4b4033816250ec1ce3ab6 (patch)
tree31f7f72cbe981eb73ed0ba11808d4fb5ae6b7d51 /lib/sqlalchemy/orm/persistence.py
parent3dc9a4a2392d033f9d1bd79dd6b6ecea6281a61c (diff)
downloadsqlalchemy-91f376692d472a5bf0c4b4033816250ec1ce3ab6.tar.gz
Add future=True to create_engine/Session; unify select()
Several weeks of using the future_select() construct has led to the proposal there be just one select() construct again which features the new join() method, and otherwise accepts both the 1.x and 2.x argument styles. This would make migration simpler and reduce confusion. However, confusion may be increased by the fact that select().join() is different Current thinking is we may be better off with a few hard behavioral changes to old and relatively unknown APIs rather than trying to play both sides within two extremely similar but subtly different APIs. At the moment, the .join() thing seems to be the only behavioral change that occurs without the user taking any explicit steps. Session.execute() will still behave the old way as we are adding a future flag. This change also adds the "future" flag to Session() and session.execute(), so that interpretation of the incoming statement, as well as that the new style result is returned, does not occur for existing applications unless they add the use of this flag. The change in general is moving the "removed in 2.0" system further along where we want the test suite to fully pass even if the SQLALCHEMY_WARN_20 flag is set. Get many tests to pass when SQLALCHEMY_WARN_20 is set; this should be ongoing after this patch merges. Improve the RemovedIn20 warning; these are all deprecated "since" 1.4, so ensure that's what the messages read. Make sure the inforamtion link is on all warnings. Add deprecation warnings for parameters present and add warnings to all FromClause.select() types of methods. Fixes: #5379 Fixes: #5284 Change-Id: I765a0b912b3dcd0e995426427d8bb7997cbffd51 References: #5159
Diffstat (limited to 'lib/sqlalchemy/orm/persistence.py')
-rw-r--r--lib/sqlalchemy/orm/persistence.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/sqlalchemy/orm/persistence.py b/lib/sqlalchemy/orm/persistence.py
index cbe7bde33..0cc16b96e 100644
--- a/lib/sqlalchemy/orm/persistence.py
+++ b/lib/sqlalchemy/orm/persistence.py
@@ -29,17 +29,17 @@ from .. import future
from .. import sql
from .. import util
from ..engine import result as _result
-from ..future import select as future_select
from ..sql import coercions
from ..sql import expression
from ..sql import operators
from ..sql import roles
+from ..sql import select
+from ..sql.base import _entity_namespace_key
from ..sql.base import CompileState
from ..sql.base import Options
from ..sql.dml import DeleteDMLState
from ..sql.dml import UpdateDMLState
from ..sql.elements import BooleanClauseList
-from ..sql.util import _entity_namespace_key
def _bulk_insert(
@@ -887,7 +887,7 @@ def _emit_update_statements(
)
)
- stmt = table.update(clauses)
+ stmt = table.update().where(clauses)
return stmt
cached_stmt = base_mapper._memo(("update", table), update_stmt)
@@ -1280,7 +1280,7 @@ def _emit_post_update_statements(
)
)
- stmt = table.update(clauses)
+ stmt = table.update().where(clauses)
if mapper.version_id_col is not None:
stmt = stmt.return_defaults(mapper.version_id_col)
@@ -1394,7 +1394,7 @@ def _emit_delete_statements(
)
)
- return table.delete(clauses)
+ return table.delete().where(clauses)
statement = base_mapper._memo(("delete", table), delete_stmt)
for connection, recs in groupby(delete, lambda rec: rec[1]): # connection
@@ -1940,7 +1940,7 @@ class BulkUDCompileState(CompileState):
for k, v in iterator:
if mapper:
if isinstance(k, util.string_types):
- desc = sql.util._entity_namespace_key(mapper, k)
+ desc = _entity_namespace_key(mapper, k)
values.extend(desc._bulk_update_tuples(v))
elif "entity_namespace" in k._annotations:
k_anno = k._annotations
@@ -1989,7 +1989,7 @@ class BulkUDCompileState(CompileState):
):
mapper = update_options._subject_mapper
- select_stmt = future_select(
+ select_stmt = select(
*(mapper.primary_key + (mapper.select_identity_token,))
)
select_stmt._where_criteria = statement._where_criteria
@@ -2007,6 +2007,7 @@ class BulkUDCompileState(CompileState):
execution_options,
bind_arguments,
_add_event=skip_for_full_returning,
+ future=True,
)
matched_rows = result.fetchall()