summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects
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/dialects
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/dialects')
-rw-r--r--lib/sqlalchemy/dialects/mssql/base.py66
1 files changed, 37 insertions, 29 deletions
diff --git a/lib/sqlalchemy/dialects/mssql/base.py b/lib/sqlalchemy/dialects/mssql/base.py
index 4b211bde7..06ea80b9e 100644
--- a/lib/sqlalchemy/dialects/mssql/base.py
+++ b/lib/sqlalchemy/dialects/mssql/base.py
@@ -2612,7 +2612,7 @@ class MSDialect(default.DefaultDialect):
def has_table(self, connection, tablename, dbname, owner, schema):
tables = ischema.tables
- s = sql.select([tables.c.table_name]).where(
+ s = sql.select(tables.c.table_name).where(
sql.and_(
tables.c.table_type == "BASE TABLE",
tables.c.table_name == tablename,
@@ -2630,7 +2630,7 @@ class MSDialect(default.DefaultDialect):
def has_sequence(self, connection, sequencename, dbname, owner, schema):
sequences = ischema.sequences
- s = sql.select([sequences.c.sequence_name]).where(
+ s = sql.select(sequences.c.sequence_name).where(
sequences.c.sequence_name == sequencename
)
@@ -2646,7 +2646,7 @@ class MSDialect(default.DefaultDialect):
def get_sequence_names(self, connection, dbname, owner, schema, **kw):
sequences = ischema.sequences
- s = sql.select([sequences.c.sequence_name])
+ s = sql.select(sequences.c.sequence_name)
if owner:
s = s.where(sequences.c.sequence_schema == owner)
@@ -2668,7 +2668,7 @@ class MSDialect(default.DefaultDialect):
def get_table_names(self, connection, dbname, owner, schema, **kw):
tables = ischema.tables
s = (
- sql.select([tables.c.table_name])
+ sql.select(tables.c.table_name)
.where(
sql.and_(
tables.c.table_schema == owner,
@@ -2684,12 +2684,15 @@ class MSDialect(default.DefaultDialect):
@_db_plus_owner_listing
def get_view_names(self, connection, dbname, owner, schema, **kw):
tables = ischema.tables
- s = sql.select(
- [tables.c.table_name],
- sql.and_(
- tables.c.table_schema == owner, tables.c.table_type == "VIEW"
- ),
- order_by=[tables.c.table_name],
+ s = (
+ sql.select(tables.c.table_name)
+ .where(
+ sql.and_(
+ tables.c.table_schema == owner,
+ tables.c.table_type == "VIEW",
+ )
+ )
+ .order_by(tables.c.table_name)
)
view_names = [r[0] for r in connection.execute(s)]
return view_names
@@ -2807,11 +2810,13 @@ class MSDialect(default.DefaultDialect):
computed_cols.c.definition, NVARCHAR(4000)
)
- s = sql.select(
- [columns, computed_definition, computed_cols.c.is_persisted],
- whereclause,
- from_obj=join,
- order_by=[columns.c.ordinal_position],
+ s = (
+ sql.select(
+ columns, computed_definition, computed_cols.c.is_persisted
+ )
+ .where(whereclause)
+ .select_from(join)
+ .order_by(columns.c.ordinal_position)
)
c = connection.execution_options(future_result=True).execute(s)
@@ -2930,7 +2935,8 @@ class MSDialect(default.DefaultDialect):
# Primary key constraints
s = sql.select(
- [C.c.column_name, TC.c.constraint_type, C.c.constraint_name],
+ C.c.column_name, TC.c.constraint_type, C.c.constraint_name
+ ).where(
sql.and_(
TC.c.constraint_name == C.c.constraint_name,
TC.c.table_schema == C.c.table_schema,
@@ -2957,8 +2963,8 @@ class MSDialect(default.DefaultDialect):
R = ischema.key_constraints.alias("R")
# Foreign key constraints
- s = sql.select(
- [
+ s = (
+ sql.select(
C.c.column_name,
R.c.table_schema,
R.c.table_name,
@@ -2967,17 +2973,19 @@ class MSDialect(default.DefaultDialect):
RR.c.match_option,
RR.c.update_rule,
RR.c.delete_rule,
- ],
- sql.and_(
- C.c.table_name == tablename,
- C.c.table_schema == owner,
- RR.c.constraint_schema == C.c.table_schema,
- C.c.constraint_name == RR.c.constraint_name,
- R.c.constraint_name == RR.c.unique_constraint_name,
- R.c.constraint_schema == RR.c.unique_constraint_schema,
- C.c.ordinal_position == R.c.ordinal_position,
- ),
- order_by=[RR.c.constraint_name, R.c.ordinal_position],
+ )
+ .where(
+ sql.and_(
+ C.c.table_name == tablename,
+ C.c.table_schema == owner,
+ RR.c.constraint_schema == C.c.table_schema,
+ C.c.constraint_name == RR.c.constraint_name,
+ R.c.constraint_name == RR.c.unique_constraint_name,
+ R.c.constraint_schema == RR.c.unique_constraint_schema,
+ C.c.ordinal_position == R.c.ordinal_position,
+ )
+ )
+ .order_by(RR.c.constraint_name, R.c.ordinal_position)
)
# group rows by constraint ID, to handle multi-column FKs