summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing/suite/test_results.py
diff options
context:
space:
mode:
authorFederico Caselli <cfederico87@gmail.com>2020-09-02 23:46:06 +0200
committerMike Bayer <mike_mp@zzzcomputing.com>2020-09-08 17:13:48 -0400
commite8600608669d90c4a6385b312d271aed63eb5854 (patch)
treeef984a01c536b2c81d2283b3ca5d9f4395f41dd0 /lib/sqlalchemy/testing/suite/test_results.py
parent0d56a62f721ee6c91d8a8b6a407b959c9215b3b6 (diff)
downloadsqlalchemy-e8600608669d90c4a6385b312d271aed63eb5854.tar.gz
Update select usage to use the new 1.4 format
This change includes mainly that the bracketed use within select() is moved to positional, and keyword arguments are removed from calls to the select() function. it does not yet fully address other issues such as keyword arguments passed to the table.select(). Additionally, allows False / None to both be considered as "disable" for all of select.correlate(), select.correlate_except(), query.correlate(), which establishes consistency with passing of ``False`` for the legact select(correlate=False) argument. Change-Id: Ie6c6e6abfbd3d75d4c8de504c0cf0159e6999108
Diffstat (limited to 'lib/sqlalchemy/testing/suite/test_results.py')
-rw-r--r--lib/sqlalchemy/testing/suite/test_results.py26
1 files changed, 12 insertions, 14 deletions
diff --git a/lib/sqlalchemy/testing/suite/test_results.py b/lib/sqlalchemy/testing/suite/test_results.py
index e6f6068c8..6d28a207e 100644
--- a/lib/sqlalchemy/testing/suite/test_results.py
+++ b/lib/sqlalchemy/testing/suite/test_results.py
@@ -87,10 +87,8 @@ class RowFetchTest(fixtures.TablesTest):
def test_row_with_dupe_names(self, connection):
result = connection.execute(
select(
- [
- self.tables.plain_pk.c.data,
- self.tables.plain_pk.c.data.label("data"),
- ]
+ self.tables.plain_pk.c.data,
+ self.tables.plain_pk.c.data.label("data"),
).order_by(self.tables.plain_pk.c.id)
)
row = result.first()
@@ -106,8 +104,8 @@ class RowFetchTest(fixtures.TablesTest):
"""
datetable = self.tables.has_dates
- s = select([datetable.alias("x").c.today]).scalar_subquery()
- s2 = select([datetable.c.id, s.label("somelabel")])
+ s = select(datetable.alias("x").c.today).scalar_subquery()
+ s2 = select(datetable.c.id, s.label("somelabel"))
row = connection.execute(s2).first()
eq_(row.somelabel, datetime.datetime(2006, 5, 12, 12, 0, 0))
@@ -256,21 +254,21 @@ class ServerSideCursorsTest(
@testing.combinations(
("global_string", True, "select 1", True),
("global_text", True, text("select 1"), True),
- ("global_expr", True, select([1]), True),
+ ("global_expr", True, select(1), True),
("global_off_explicit", False, text("select 1"), False),
(
"stmt_option",
False,
- select([1]).execution_options(stream_results=True),
+ select(1).execution_options(stream_results=True),
True,
),
(
"stmt_option_disabled",
True,
- select([1]).execution_options(stream_results=False),
+ select(1).execution_options(stream_results=False),
False,
),
- ("for_update_expr", True, select([1]).with_for_update(), True),
+ ("for_update_expr", True, select(1).with_for_update(), True),
("for_update_string", True, "SELECT 1 FOR UPDATE", True),
("text_no_ss", False, text("select 42"), False),
(
@@ -308,7 +306,7 @@ class ServerSideCursorsTest(
def test_stmt_enabled_conn_option_disabled(self):
engine = self._fixture(False)
- s = select([1]).execution_options(stream_results=True)
+ s = select(1).execution_options(stream_results=True)
# not this one
result = (
@@ -318,7 +316,7 @@ class ServerSideCursorsTest(
def test_aliases_and_ss(self):
engine = self._fixture(False)
- s1 = select([1]).execution_options(stream_results=True).alias()
+ s1 = select(1).execution_options(stream_results=True).alias()
with engine.begin() as conn:
result = conn.execute(s1)
assert self._is_server_side(result.cursor)
@@ -326,7 +324,7 @@ class ServerSideCursorsTest(
# s1's options shouldn't affect s2 when s2 is used as a
# from_obj.
- s2 = select([1], from_obj=s1)
+ s2 = select(1).select_from(s1)
with engine.begin() as conn:
result = conn.execute(s2)
assert not self._is_server_side(result.cursor)
@@ -368,7 +366,7 @@ class ServerSideCursorsTest(
connection.execute(test_table.delete())
eq_(
connection.scalar(
- select([func.count("*")]).select_from(test_table)
+ select(func.count("*")).select_from(test_table)
),
0,
)