summaryrefslogtreecommitdiff
path: root/test/sql/test_selectable.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 /test/sql/test_selectable.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 'test/sql/test_selectable.py')
-rw-r--r--test/sql/test_selectable.py482
1 files changed, 226 insertions, 256 deletions
diff --git a/test/sql/test_selectable.py b/test/sql/test_selectable.py
index d53ee3385..55875632a 100644
--- a/test/sql/test_selectable.py
+++ b/test/sql/test_selectable.py
@@ -88,11 +88,9 @@ class SelectableTest(
# same column three times
s = select(
- [
- table1.c.col1.label("c2"),
- table1.c.col1,
- table1.c.col1.label("c1"),
- ]
+ table1.c.col1.label("c2"),
+ table1.c.col1,
+ table1.c.col1.label("c1"),
).subquery()
# this tests the same thing as
@@ -104,10 +102,10 @@ class SelectableTest(
assert s.corresponding_column(s.c.c1) is s.c.c1
def test_labeled_select_twice(self):
- scalar_select = select([table1.c.col1]).label("foo")
+ scalar_select = select(table1.c.col1).label("foo")
- s1 = select([scalar_select])
- s2 = select([scalar_select, scalar_select])
+ s1 = select(scalar_select)
+ s2 = select(scalar_select, scalar_select)
eq_(
s1.selected_columns.foo.proxy_set,
@@ -130,10 +128,10 @@ class SelectableTest(
)
def test_labeled_subquery_twice(self):
- scalar_select = select([table1.c.col1]).label("foo")
+ scalar_select = select(table1.c.col1).label("foo")
- s1 = select([scalar_select]).subquery()
- s2 = select([scalar_select, scalar_select]).subquery()
+ s1 = select(scalar_select).subquery()
+ s2 = select(scalar_select, scalar_select).subquery()
eq_(
s1.c.foo.proxy_set,
@@ -148,10 +146,10 @@ class SelectableTest(
assert s2.corresponding_column(scalar_select) is s2.c.foo
def test_labels_name_w_separate_key(self):
- label = select([table1.c.col1]).label("foo")
+ label = select(table1.c.col1).label("foo")
label.key = "bar"
- s1 = select([label])
+ s1 = select(label)
assert s1.corresponding_column(label) is s1.selected_columns.bar
# renders as foo
@@ -160,10 +158,10 @@ class SelectableTest(
)
def test_labels_anon_w_separate_key(self):
- label = select([table1.c.col1]).label(None)
+ label = select(table1.c.col1).label(None)
label.key = "bar"
- s1 = select([label])
+ s1 = select(label)
# .bar is there
assert s1.corresponding_column(label) is s1.selected_columns.bar
@@ -174,14 +172,14 @@ class SelectableTest(
)
def test_labels_anon_w_separate_key_subquery(self):
- label = select([table1.c.col1]).label(None)
+ label = select(table1.c.col1).label(None)
label.key = label._key_label = "bar"
- s1 = select([label])
+ s1 = select(label)
subq = s1.subquery()
- s2 = select([subq]).where(subq.c.bar > 5)
+ s2 = select(subq).where(subq.c.bar > 5)
self.assert_compile(
s2,
"SELECT anon_2.anon_1 FROM (SELECT (SELECT table1.col1 "
@@ -191,14 +189,14 @@ class SelectableTest(
)
def test_labels_anon_generate_binds_subquery(self):
- label = select([table1.c.col1]).label(None)
+ label = select(table1.c.col1).label(None)
label.key = label._key_label = "bar"
- s1 = select([label])
+ s1 = select(label)
subq = s1.subquery()
- s2 = select([subq]).where(subq.c[0] > 5)
+ s2 = select(subq).where(subq.c[0] > 5)
self.assert_compile(
s2,
"SELECT anon_2.anon_1 FROM (SELECT (SELECT table1.col1 "
@@ -208,20 +206,20 @@ class SelectableTest(
)
def test_select_label_grouped_still_corresponds(self):
- label = select([table1.c.col1]).label("foo")
+ label = select(table1.c.col1).label("foo")
label2 = label.self_group()
- s1 = select([label])
- s2 = select([label2])
+ s1 = select(label)
+ s2 = select(label2)
assert s1.corresponding_column(label) is s1.selected_columns.foo
assert s2.corresponding_column(label) is s2.selected_columns.foo
def test_subquery_label_grouped_still_corresponds(self):
- label = select([table1.c.col1]).label("foo")
+ label = select(table1.c.col1).label("foo")
label2 = label.self_group()
- s1 = select([label]).subquery()
- s2 = select([label2]).subquery()
+ s1 = select(label).subquery()
+ s2 = select(label2).subquery()
assert s1.corresponding_column(label) is s1.c.foo
assert s2.corresponding_column(label) is s2.c.foo
@@ -230,20 +228,20 @@ class SelectableTest(
# of the proxy set to get the right result
l1, l2 = table1.c.col1.label("foo"), table1.c.col1.label("bar")
- sel = select([l1, l2])
+ sel = select(l1, l2)
sel2 = sel.alias()
assert sel2.corresponding_column(l1) is sel2.c.foo
assert sel2.corresponding_column(l2) is sel2.c.bar
- sel2 = select([table1.c.col1.label("foo"), table1.c.col2.label("bar")])
+ sel2 = select(table1.c.col1.label("foo"), table1.c.col2.label("bar"))
sel3 = sel.union(sel2).alias()
assert sel3.corresponding_column(l1) is sel3.c.foo
assert sel3.corresponding_column(l2) is sel3.c.bar
def test_keyed_gen(self):
- s = select([keyed])
+ s = select(keyed)
eq_(s.selected_columns.colx.key, "colx")
eq_(s.selected_columns.colx.name, "x")
@@ -267,7 +265,7 @@ class SelectableTest(
assert sel2.corresponding_column(keyed.c.z) is sel2.c.z
def test_keyed_label_gen(self):
- s = select([keyed]).apply_labels()
+ s = select(keyed).apply_labels()
assert (
s.selected_columns.corresponding_column(keyed.c.colx)
@@ -301,20 +299,20 @@ class SelectableTest(
def test_clone_c_proxy_key_upper(self):
c = Column("foo", Integer, key="bar")
t = Table("t", MetaData(), c)
- s = select([t])._clone()
+ s = select(t)._clone()
assert c in s.selected_columns.bar.proxy_set
- s = select([t]).subquery()._clone()
+ s = select(t).subquery()._clone()
assert c in s.c.bar.proxy_set
def test_clone_c_proxy_key_lower(self):
c = column("foo")
c.key = "bar"
t = table("t", c)
- s = select([t])._clone()
+ s = select(t)._clone()
assert c in s.selected_columns.bar.proxy_set
- s = select([t]).subquery()._clone()
+ s = select(t).subquery()._clone()
assert c in s.c.bar.proxy_set
def test_no_error_on_unsupported_expr_key(self):
@@ -327,14 +325,14 @@ class SelectableTest(
expr = BinaryExpression(t.c.x, t.c.y, myop)
- s = select([t, expr])
+ s = select(t, expr)
# anon_label, e.g. a truncated_label, is used here because
# the expr has no name, no key, and myop() can't create a
# string, so this is the last resort
eq_(s.selected_columns.keys(), ["x", "y", expr.anon_label])
- s = select([t, expr]).subquery()
+ s = select(t, expr).subquery()
eq_(s.c.keys(), ["x", "y", expr.anon_label])
def test_cloned_intersection(self):
@@ -380,7 +378,7 @@ class SelectableTest(
assert s.corresponding_column(a1.c.col1) is s.c.a1_col1
def test_join_against_self(self):
- jj = select([table1.c.col1.label("bar_col1")]).subquery()
+ jj = select(table1.c.col1.label("bar_col1")).subquery()
jjj = join(table1, jj, table1.c.col1 == jj.c.bar_col1)
# test column directly against itself
@@ -403,7 +401,7 @@ class SelectableTest(
assert j2.corresponding_column(table1.c.col1) is j2.c.table1_col1
def test_clone_append_column(self):
- sel = select([literal_column("1").label("a")])
+ sel = select(literal_column("1").label("a"))
eq_(list(sel.selected_columns.keys()), ["a"])
cloned = visitors.ReplacingCloningVisitor().traverse(sel)
cloned.add_columns.non_generative(
@@ -414,7 +412,7 @@ class SelectableTest(
def test_clone_col_list_changes_then_proxy(self):
t = table("t", column("q"), column("p"))
- stmt = select([t.c.q]).subquery()
+ stmt = select(t.c.q).subquery()
def add_column(stmt):
stmt.add_columns.non_generative(stmt, t.c.p)
@@ -425,7 +423,7 @@ class SelectableTest(
def test_clone_col_list_changes_then_schema_proxy(self):
t = Table("t", MetaData(), Column("q", Integer), Column("p", Integer))
- stmt = select([t.c.q]).subquery()
+ stmt = select(t.c.q).subquery()
def add_column(stmt):
stmt.add_columns.non_generative(stmt, t.c.p)
@@ -437,13 +435,13 @@ class SelectableTest(
def test_append_column_after_visitor_replace(self):
# test for a supported idiom that matches the deprecated / removed
# replace_selectable method
- basesel = select([literal_column("1").label("a")])
+ basesel = select(literal_column("1").label("a"))
tojoin = select(
- [literal_column("1").label("a"), literal_column("2").label("b")]
+ literal_column("1").label("a"), literal_column("2").label("b")
)
basefrom = basesel.alias("basefrom")
joinfrom = tojoin.alias("joinfrom")
- sel = select([basefrom.c.a])
+ sel = select(basefrom.c.a)
replace_from = basefrom.join(joinfrom, basefrom.c.a == joinfrom.c.a)
@@ -470,7 +468,7 @@ class SelectableTest(
# test that corresponding column digs across
# clone boundaries with anonymous labeled elements
col = func.count().label("foo")
- sel = select([col]).subquery()
+ sel = select(col).subquery()
sel2 = visitors.ReplacingCloningVisitor().traverse(sel)
assert sel2.corresponding_column(col) is sel2.c.foo
@@ -490,7 +488,7 @@ class SelectableTest(
class MyType(TypeDecorator):
impl = Integer
- stmt = select([type_coerce(column("x"), MyType).label("foo")])
+ stmt = select(type_coerce(column("x"), MyType).label("foo"))
subq = stmt.subquery()
stmt2 = subq.select()
subq2 = stmt2.subquery()
@@ -553,14 +551,14 @@ class SelectableTest(
j2 = t4.join(j, onclause=t4.c.d == t2.c.b)
- stmt = select([t1, t2, t3, t4]).select_from(j2)
+ stmt = select(t1, t2, t3, t4).select_from(j2)
self.assert_compile(
stmt,
"SELECT t1.a, t2.b, t3.c, t4.d FROM t3, "
"t4 JOIN (t1 JOIN t2 ON t1.a = t3.c) ON t4.d = t2.b",
)
- stmt = select([t1]).select_from(t3).select_from(j2)
+ stmt = select(t1).select_from(t3).select_from(j2)
self.assert_compile(
stmt,
"SELECT t1.a FROM t3, t4 JOIN (t1 JOIN t2 ON t1.a = t3.c) "
@@ -572,7 +570,7 @@ class SelectableTest(
# not quite a use case yet but this is expected to become
# prominent w/ PostgreSQL's tuple functions
- stmt = select([table1.c.col1, table1.c.col2])
+ stmt = select(table1.c.col1, table1.c.col2)
a = stmt.alias("a")
# TODO: this case is crazy, sending SELECT or FROMCLAUSE has to
@@ -580,7 +578,7 @@ class SelectableTest(
# statements go into functions in PG. seems likely select statement,
# but not alias, subquery or other FROM object
self.assert_compile(
- select([func.foo(a)]),
+ select(func.foo(a)),
"SELECT foo(SELECT table1.col1, table1.col2 FROM table1) "
"AS foo_1 FROM "
"(SELECT table1.col1 AS col1, table1.col2 AS col2 FROM table1) "
@@ -594,22 +592,18 @@ class SelectableTest(
# its underlying Selects matches to that same Table
u = select(
- [
- table1.c.col1,
- table1.c.col2,
- table1.c.col3,
- table1.c.colx,
- null().label("coly"),
- ]
+ table1.c.col1,
+ table1.c.col2,
+ table1.c.col3,
+ table1.c.colx,
+ null().label("coly"),
).union(
select(
- [
- table2.c.col1,
- table2.c.col2,
- table2.c.col3,
- null().label("colx"),
- table2.c.coly,
- ]
+ table2.c.col1,
+ table2.c.col2,
+ table2.c.col3,
+ null().label("colx"),
+ table2.c.coly,
)
)
s1 = table1.select(use_labels=True)
@@ -648,10 +642,10 @@ class SelectableTest(
# conflicting column correspondence should be resolved based on
# the order of the select()s in the union
- s1 = select([table1.c.col1, table1.c.col2])
- s2 = select([table1.c.col2, table1.c.col1])
- s3 = select([table1.c.col3, table1.c.colx])
- s4 = select([table1.c.colx, table1.c.col3])
+ s1 = select(table1.c.col1, table1.c.col2)
+ s2 = select(table1.c.col2, table1.c.col1)
+ s3 = select(table1.c.col3, table1.c.colx)
+ s4 = select(table1.c.colx, table1.c.col3)
u1 = union(s1, s2).subquery()
assert u1.corresponding_column(table1.c.col1) is u1.c.col1
@@ -664,8 +658,8 @@ class SelectableTest(
assert u1.corresponding_column(table1.c.col3) is u1.c.col1
def test_proxy_set_pollution(self):
- s1 = select([table1.c.col1, table1.c.col2])
- s2 = select([table1.c.col2, table1.c.col1])
+ s1 = select(table1.c.col1, table1.c.col2)
+ s2 = select(table1.c.col2, table1.c.col1)
for c in s1.selected_columns:
c.proxy_set
@@ -677,10 +671,10 @@ class SelectableTest(
def test_singular_union(self):
u = union(
- select([table1.c.col1, table1.c.col2, table1.c.col3]),
- select([table1.c.col1, table1.c.col2, table1.c.col3]),
+ select(table1.c.col1, table1.c.col2, table1.c.col3),
+ select(table1.c.col1, table1.c.col2, table1.c.col3),
)
- u = union(select([table1.c.col1, table1.c.col2, table1.c.col3]))
+ u = union(select(table1.c.col1, table1.c.col2, table1.c.col3))
assert u.selected_columns.col1 is not None
assert u.selected_columns.col2 is not None
assert u.selected_columns.col3 is not None
@@ -691,23 +685,19 @@ class SelectableTest(
u = (
select(
- [
- table1.c.col1,
- table1.c.col2,
- table1.c.col3,
- table1.c.colx,
- null().label("coly"),
- ]
+ table1.c.col1,
+ table1.c.col2,
+ table1.c.col3,
+ table1.c.colx,
+ null().label("coly"),
)
.union(
select(
- [
- table2.c.col1,
- table2.c.col2,
- table2.c.col3,
- null().label("colx"),
- table2.c.coly,
- ]
+ table2.c.col1,
+ table2.c.col2,
+ table2.c.col3,
+ null().label("colx"),
+ table2.c.coly,
)
)
.alias("analias")
@@ -720,8 +710,8 @@ class SelectableTest(
assert s2.corresponding_column(u.c.coly) is s2.c.table2_coly
def test_union_of_alias(self):
- s1 = select([table1.c.col1, table1.c.col2])
- s2 = select([table1.c.col1, table1.c.col2]).alias()
+ s1 = select(table1.c.col1, table1.c.col2)
+ s2 = select(table1.c.col1, table1.c.col2).alias()
# previously this worked
assert_raises_message(
@@ -734,7 +724,7 @@ class SelectableTest(
)
def test_union_of_text(self):
- s1 = select([table1.c.col1, table1.c.col2])
+ s1 = select(table1.c.col1, table1.c.col2)
s2 = text("select col1, col2 from foo").columns(
column("col1"), column("col2")
)
@@ -748,8 +738,8 @@ class SelectableTest(
assert u2.corresponding_column(s2.selected_columns.col1) is u2.c.col1
def test_foo(self):
- s1 = select([table1.c.col1, table1.c.col2])
- s2 = select([table1.c.col2, table1.c.col1])
+ s1 = select(table1.c.col1, table1.c.col2)
+ s2 = select(table1.c.col2, table1.c.col1)
u1 = union(s1, s2).subquery()
assert u1.corresponding_column(table1.c.col2) is u1.c.col2
@@ -765,16 +755,16 @@ class SelectableTest(
)
# table1_new = table1
- s1 = select([table1_new.c.col1, table1_new.c.col2])
- s2 = select([table1_new.c.col2, table1_new.c.col1])
+ s1 = select(table1_new.c.col1, table1_new.c.col2)
+ s2 = select(table1_new.c.col2, table1_new.c.col1)
u1 = union(s1, s2).subquery()
# TODO: failing due to proxy_set not correct
assert u1.corresponding_column(table1_new.c.col2) is u1.c.col2
def test_union_alias_dupe_keys(self):
- s1 = select([table1.c.col1, table1.c.col2, table2.c.col1])
- s2 = select([table2.c.col1, table2.c.col2, table2.c.col3])
+ s1 = select(table1.c.col1, table1.c.col2, table2.c.col1)
+ s2 = select(table2.c.col1, table2.c.col2, table2.c.col3)
u1 = union(s1, s2).subquery()
assert (
@@ -818,13 +808,13 @@ class SelectableTest(
assert u1.corresponding_column(table2.c.col3) is u1.c._all_columns[2]
def test_union_alias_dupe_keys_disambiguates_in_subq_compile_one(self):
- s1 = select([table1.c.col1, table1.c.col2, table2.c.col1]).limit(1)
- s2 = select([table2.c.col1, table2.c.col2, table2.c.col3]).limit(1)
+ s1 = select(table1.c.col1, table1.c.col2, table2.c.col1).limit(1)
+ s2 = select(table2.c.col1, table2.c.col2, table2.c.col3).limit(1)
u1 = union(s1, s2).subquery()
eq_(u1.c.keys(), ["col1", "col2", "col1_1"])
- stmt = select([u1])
+ stmt = select(u1)
eq_(stmt.selected_columns.keys(), ["col1", "col2", "col1_1"])
@@ -850,7 +840,7 @@ class SelectableTest(
eq_(u1.c.keys(), ["a_id", "b_id", "b_aid"])
- stmt = select([u1])
+ stmt = select(u1)
eq_(stmt.selected_columns.keys(), ["a_id", "b_id", "b_aid"])
@@ -866,8 +856,8 @@ class SelectableTest(
)
def test_union_alias_dupe_keys_grouped(self):
- s1 = select([table1.c.col1, table1.c.col2, table2.c.col1]).limit(1)
- s2 = select([table2.c.col1, table2.c.col2, table2.c.col3]).limit(1)
+ s1 = select(table1.c.col1, table1.c.col2, table2.c.col1).limit(1)
+ s2 = select(table2.c.col1, table2.c.col2, table2.c.col3).limit(1)
u1 = union(s1, s2).subquery()
assert (
@@ -916,28 +906,24 @@ class SelectableTest(
u = (
select(
- [
- table1.c.col1,
- table1.c.col2,
- table1.c.col3,
- table1.c.colx,
- null().label("coly"),
- ]
+ table1.c.col1,
+ table1.c.col2,
+ table1.c.col3,
+ table1.c.colx,
+ null().label("coly"),
)
.union(
select(
- [
- table2.c.col1,
- table2.c.col2,
- table2.c.col3,
- null().label("colx"),
- table2.c.coly,
- ]
+ table2.c.col1,
+ table2.c.col2,
+ table2.c.col3,
+ null().label("colx"),
+ table2.c.coly,
)
)
.alias("analias")
)
- s = select([u]).subquery()
+ s = select(u).subquery()
s1 = table1.select(use_labels=True).subquery()
s2 = table2.select(use_labels=True).subquery()
assert s.corresponding_column(s1.c.table1_col2) is s.c.col2
@@ -949,23 +935,19 @@ class SelectableTest(
u = (
select(
- [
- table1.c.col1,
- table1.c.col2,
- table1.c.col3,
- table1.c.colx,
- null().label("coly"),
- ]
+ table1.c.col1,
+ table1.c.col2,
+ table1.c.col3,
+ table1.c.colx,
+ null().label("coly"),
)
.union(
select(
- [
- table2.c.col1,
- table2.c.col2,
- table2.c.col3,
- null().label("colx"),
- table2.c.coly,
- ]
+ table2.c.col1,
+ table2.c.col2,
+ table2.c.col3,
+ null().label("colx"),
+ table2.c.coly,
)
)
.alias("analias")
@@ -998,7 +980,7 @@ class SelectableTest(
self.assert_(criterion.compare(j.onclause))
def test_scalar_cloned_comparator(self):
- sel = select([table1.c.col1]).scalar_subquery()
+ sel = select(table1.c.col1).scalar_subquery()
sel == table1.c.col1
sel2 = visitors.ReplacingCloningVisitor().traverse(sel)
@@ -1008,32 +990,30 @@ class SelectableTest(
def test_column_labels(self):
a = select(
- [
- table1.c.col1.label("acol1"),
- table1.c.col2.label("acol2"),
- table1.c.col3.label("acol3"),
- ]
+ table1.c.col1.label("acol1"),
+ table1.c.col2.label("acol2"),
+ table1.c.col3.label("acol3"),
).subquery()
j = join(a, table2)
criterion = a.c.acol1 == table2.c.col2
self.assert_(criterion.compare(j.onclause))
def test_labeled_select_corresponding(self):
- l1 = select([func.max(table1.c.col1)]).label("foo")
+ l1 = select(func.max(table1.c.col1)).label("foo")
- s = select([l1])
+ s = select(l1)
eq_(s.corresponding_column(l1), s.selected_columns.foo)
- s = select([table1.c.col1, l1])
+ s = select(table1.c.col1, l1)
eq_(s.corresponding_column(l1), s.selected_columns.foo)
def test_labeled_subquery_corresponding(self):
- l1 = select([func.max(table1.c.col1)]).label("foo")
- s = select([l1]).subquery()
+ l1 = select(func.max(table1.c.col1)).label("foo")
+ s = select(l1).subquery()
eq_(s.corresponding_column(l1), s.c.foo)
- s = select([table1.c.col1, l1]).subquery()
+ s = select(table1.c.col1, l1).subquery()
eq_(s.corresponding_column(l1), s.c.foo)
def test_select_alias_labels(self):
@@ -1047,11 +1027,11 @@ class SelectableTest(
metadata = MetaData()
a = Table("a", metadata, Column("id", Integer, primary_key=True))
- j2 = select([a.c.id.label("aid")]).alias("bar")
+ j2 = select(a.c.id.label("aid")).alias("bar")
j3 = a.join(j2, j2.c.aid == a.c.id)
- j4 = select([j3]).alias("foo")
+ j4 = select(j3).alias("foo")
assert j4.corresponding_column(j2.c.aid) is j4.c.aid
assert j4.corresponding_column(a.c.id) is j4.c.id
@@ -1070,8 +1050,8 @@ class SelectableTest(
def test_multi_label_chain_naming_col(self):
# See [ticket:2167] for this one.
l1 = table1.c.col1.label("a")
- l2 = select([l1]).label("b")
- s = select([l2]).subquery()
+ l2 = select(l1).label("b")
+ s = select(l2).subquery()
assert s.c.b is not None
self.assert_compile(
s.select(),
@@ -1079,7 +1059,7 @@ class SelectableTest(
"(SELECT (SELECT table1.col1 AS a FROM table1) AS b) AS anon_1",
)
- s2 = select([s.element.label("c")]).subquery()
+ s2 = select(s.element.label("c")).subquery()
self.assert_compile(
s2.select(),
"SELECT anon_1.c FROM (SELECT (SELECT ("
@@ -1093,7 +1073,7 @@ class SelectableTest(
# style to the select, eliminating the self-referential call unless
# the select already had labeling applied
- s = select([t]).apply_labels()
+ s = select(t).apply_labels()
with testing.expect_deprecated("The SelectBase.c"):
s.where.non_generative(s, s.c.t_x > 5)
@@ -1107,7 +1087,7 @@ class SelectableTest(
def test_unusual_column_elements_text(self):
"""test that .c excludes text()."""
- s = select([table1.c.col1, text("foo")]).subquery()
+ s = select(table1.c.col1, text("foo")).subquery()
eq_(list(s.c), [s.c.col1])
def test_unusual_column_elements_clauselist(self):
@@ -1116,7 +1096,7 @@ class SelectableTest(
from sqlalchemy.sql.expression import ClauseList
s = select(
- [table1.c.col1, ClauseList(table1.c.col2, table1.c.col3)]
+ table1.c.col1, ClauseList(table1.c.col2, table1.c.col3)
).subquery()
eq_(list(s.c), [s.c.col1, s.c.col2, s.c.col3])
@@ -1124,56 +1104,56 @@ class SelectableTest(
"""test that BooleanClauseList is placed as single element in .c."""
c2 = and_(table1.c.col2 == 5, table1.c.col3 == 4)
- s = select([table1.c.col1, c2]).subquery()
+ s = select(table1.c.col1, c2).subquery()
eq_(list(s.c), [s.c.col1, s.corresponding_column(c2)])
def test_from_list_deferred_constructor(self):
c1 = Column("c1", Integer)
c2 = Column("c2", Integer)
- select([c1])
+ select(c1)
t = Table("t", MetaData(), c1, c2)
eq_(c1._from_objects, [t])
eq_(c2._from_objects, [t])
- self.assert_compile(select([c1]), "SELECT t.c1 FROM t")
- self.assert_compile(select([c2]), "SELECT t.c2 FROM t")
+ self.assert_compile(select(c1), "SELECT t.c1 FROM t")
+ self.assert_compile(select(c2), "SELECT t.c2 FROM t")
def test_from_list_deferred_whereclause(self):
c1 = Column("c1", Integer)
c2 = Column("c2", Integer)
- select([c1]).where(c1 == 5)
+ select(c1).where(c1 == 5)
t = Table("t", MetaData(), c1, c2)
eq_(c1._from_objects, [t])
eq_(c2._from_objects, [t])
- self.assert_compile(select([c1]), "SELECT t.c1 FROM t")
- self.assert_compile(select([c2]), "SELECT t.c2 FROM t")
+ self.assert_compile(select(c1), "SELECT t.c1 FROM t")
+ self.assert_compile(select(c2), "SELECT t.c2 FROM t")
def test_from_list_deferred_fromlist(self):
m = MetaData()
t1 = Table("t1", m, Column("x", Integer))
c1 = Column("c1", Integer)
- select([c1]).where(c1 == 5).select_from(t1)
+ select(c1).where(c1 == 5).select_from(t1)
t2 = Table("t2", MetaData(), c1)
eq_(c1._from_objects, [t2])
- self.assert_compile(select([c1]), "SELECT t2.c1 FROM t2")
+ self.assert_compile(select(c1), "SELECT t2.c1 FROM t2")
def test_from_list_deferred_cloning(self):
c1 = Column("c1", Integer)
c2 = Column("c2", Integer)
- s = select([c1])
- s2 = select([c2])
+ s = select(c1)
+ s2 = select(c2)
s3 = sql_util.ClauseAdapter(s).traverse(s2)
Table("t", MetaData(), c1, c2)
@@ -1183,7 +1163,7 @@ class SelectableTest(
def test_from_list_with_columns(self):
table1 = table("t1", column("a"))
table2 = table("t2", column("b"))
- s1 = select([table1.c.a, table2.c.b])
+ s1 = select(table1.c.a, table2.c.b)
self.assert_compile(s1, "SELECT t1.a, t2.b FROM t1, t2")
s2 = s1.with_only_columns([table2.c.b])
self.assert_compile(s2, "SELECT t2.b FROM t2")
@@ -1195,7 +1175,7 @@ class SelectableTest(
def test_from_list_against_existing_one(self):
c1 = Column("c1", Integer)
- s = select([c1])
+ s = select(c1)
# force a compile.
self.assert_compile(s, "SELECT c1")
@@ -1208,7 +1188,7 @@ class SelectableTest(
c1 = Column("c1", Integer)
c2 = Column("c2", Integer)
- s = select([c1])
+ s = select(c1)
# force a compile.
eq_(str(s), "SELECT c1")
@@ -1219,8 +1199,8 @@ class SelectableTest(
eq_(c2._from_objects, [t])
self.assert_compile(s, "SELECT t.c1 FROM t")
- self.assert_compile(select([c1]), "SELECT t.c1 FROM t")
- self.assert_compile(select([c2]), "SELECT t.c2 FROM t")
+ self.assert_compile(select(c1), "SELECT t.c1 FROM t")
+ self.assert_compile(select(c2), "SELECT t.c2 FROM t")
def test_label_gen_resets_on_table(self):
c1 = Column("c1", Integer)
@@ -1243,13 +1223,13 @@ class SelectableTest(
def test_whereclause_adapted(self):
table1 = table("t1", column("a"))
- s1 = select([table1]).subquery()
+ s1 = select(table1).subquery()
- s2 = select([s1]).where(s1.c.a == 5)
+ s2 = select(s1).where(s1.c.a == 5)
assert s2._whereclause.left.table is s1
- ta = select([table1]).subquery()
+ ta = select(table1).subquery()
s3 = sql_util.ClauseAdapter(ta).traverse(s2)
@@ -1297,7 +1277,7 @@ class RefreshForNewColTest(fixtures.TestBase):
def test_select_samename_init(self):
a = table("a", column("x"))
b = table("b", column("y"))
- s = select([a, b]).apply_labels()
+ s = select(a, b).apply_labels()
s.selected_columns
q = column("x")
b.append_column(q)
@@ -1307,7 +1287,7 @@ class RefreshForNewColTest(fixtures.TestBase):
def test_alias_alias_samename_init(self):
a = table("a", column("x"))
b = table("b", column("y"))
- s1 = select([a, b]).apply_labels().alias()
+ s1 = select(a, b).apply_labels().alias()
s2 = s1.alias()
s1.c
@@ -1326,7 +1306,7 @@ class RefreshForNewColTest(fixtures.TestBase):
def test_aliased_select_samename_uninit(self):
a = table("a", column("x"))
b = table("b", column("y"))
- s = select([a, b]).apply_labels().alias()
+ s = select(a, b).apply_labels().alias()
q = column("x")
b.append_column(q)
s._refresh_for_new_column(q)
@@ -1335,7 +1315,7 @@ class RefreshForNewColTest(fixtures.TestBase):
def test_aliased_select_samename_init(self):
a = table("a", column("x"))
b = table("b", column("y"))
- s = select([a, b]).apply_labels().alias()
+ s = select(a, b).apply_labels().alias()
s.c
q = column("x")
b.append_column(q)
@@ -1346,7 +1326,7 @@ class RefreshForNewColTest(fixtures.TestBase):
a = table("a", column("x"))
b = table("b", column("y"))
c = table("c", column("z"))
- s = select([a, b]).apply_labels().alias()
+ s = select(a, b).apply_labels().alias()
s.c
q = column("x")
c.append_column(q)
@@ -1355,7 +1335,7 @@ class RefreshForNewColTest(fixtures.TestBase):
def test_aliased_select_no_cols_clause(self):
a = table("a", column("x"))
- s = select([a.c.x]).apply_labels().alias()
+ s = select(a.c.x).apply_labels().alias()
s.c
q = column("q")
a.append_column(q)
@@ -1364,8 +1344,8 @@ class RefreshForNewColTest(fixtures.TestBase):
def test_union_uninit(self):
a = table("a", column("x"))
- s1 = select([a])
- s2 = select([a])
+ s1 = select(a)
+ s2 = select(a)
s3 = s1.union(s2)
q = column("q")
a.append_column(q)
@@ -1374,8 +1354,8 @@ class RefreshForNewColTest(fixtures.TestBase):
def test_union_init(self):
a = table("a", column("x"))
- s1 = select([a])
- s2 = select([a])
+ s1 = select(a)
+ s2 = select(a)
s3 = s1.union(s2)
s3.selected_columns
q = column("q")
@@ -1453,29 +1433,29 @@ class AnonLabelTest(fixtures.TestBase):
c1 = column("x")
assert c1.label(None) is not c1
- eq_(str(select([c1.label(None)])), "SELECT x AS x_1")
+ eq_(str(select(c1.label(None))), "SELECT x AS x_1")
def test_anon_labels_literal_column(self):
c1 = literal_column("x")
assert c1.label(None) is not c1
- eq_(str(select([c1.label(None)])), "SELECT x AS x_1")
+ eq_(str(select(c1.label(None))), "SELECT x AS x_1")
def test_anon_labels_func(self):
c1 = func.count("*")
assert c1.label(None) is not c1
- eq_(str(select([c1])), "SELECT count(:count_2) AS count_1")
- select([c1]).compile()
+ eq_(str(select(c1)), "SELECT count(:count_2) AS count_1")
+ select(c1).compile()
- eq_(str(select([c1.label(None)])), "SELECT count(:count_2) AS count_1")
+ eq_(str(select(c1.label(None))), "SELECT count(:count_2) AS count_1")
def test_named_labels_named_column(self):
c1 = column("x")
- eq_(str(select([c1.label("y")])), "SELECT x AS y")
+ eq_(str(select(c1.label("y"))), "SELECT x AS y")
def test_named_labels_literal_column(self):
c1 = literal_column("x")
- eq_(str(select([c1.label("y")])), "SELECT x AS y")
+ eq_(str(select(c1.label("y"))), "SELECT x AS y")
class JoinAliasingTest(fixtures.TestBase, AssertsCompiledSQL):
@@ -1544,7 +1524,7 @@ class JoinAliasingTest(fixtures.TestBase, AssertsCompiledSQL):
j1 = a.join(b, a.c.a == b.c.b)
j2 = c.join(d, c.c.c == d.c.d)
self.assert_compile(
- select([j1.join(j2, b.c.b == c.c.c).alias()]),
+ select(j1.join(j2, b.c.b == c.c.c).alias()),
"SELECT anon_1.a_a, anon_1.b_b, anon_1.c_c, anon_1.d_d "
"FROM (SELECT a.a AS a_a, b.b AS b_b, c.c AS c_c, d.d AS d_d "
"FROM a JOIN b ON a.a = b.b "
@@ -2013,7 +1993,7 @@ class ReduceTest(fixtures.TestBase, AssertsExecutionResults):
Column("manager_name", String(50)),
)
s = (
- select([engineers, managers])
+ select(engineers, managers)
.where(engineers.c.engineer_name == managers.c.manager_name)
.subquery()
)
@@ -2038,7 +2018,7 @@ class ReduceTest(fixtures.TestBase, AssertsExecutionResults):
Column("z", Integer, ForeignKey("t1.x")),
Column("q", Integer),
)
- s1 = select([t1, t2])
+ s1 = select(t1, t2)
s2 = s1.reduce_columns(only_synonyms=False)
eq_(set(s2.selected_columns), set([t1.c.x, t1.c.y, t2.c.q]))
@@ -2059,7 +2039,7 @@ class ReduceTest(fixtures.TestBase, AssertsExecutionResults):
Column("x", Integer, ForeignKey("t1.x")),
Column("q", Integer, ForeignKey("t1.y")),
)
- s1 = select([t1, t2])
+ s1 = select(t1, t2)
s1 = s1.reduce_columns(only_synonyms=True)
eq_(
set(s1.selected_columns),
@@ -2083,16 +2063,16 @@ class ReduceTest(fixtures.TestBase, AssertsExecutionResults):
)
# test that the first appearance in the columns clause
# wins - t1 is first, t1.c.x wins
- s1 = select([t1]).subquery()
- s2 = select([t1, s1]).where(t1.c.x == s1.c.x).where(s1.c.y == t1.c.z)
+ s1 = select(t1).subquery()
+ s2 = select(t1, s1).where(t1.c.x == s1.c.x).where(s1.c.y == t1.c.z)
eq_(
set(s2.reduce_columns().selected_columns),
set([t1.c.x, t1.c.y, t1.c.z, s1.c.y, s1.c.z]),
)
# reverse order, s1.c.x wins
- s1 = select([t1]).subquery()
- s2 = select([s1, t1]).where(t1.c.x == s1.c.x).where(s1.c.y == t1.c.z)
+ s1 = select(t1).subquery()
+ s2 = select(s1, t1).where(t1.c.x == s1.c.x).where(s1.c.y == t1.c.z)
eq_(
set(s2.reduce_columns().selected_columns),
set([s1.c.x, t1.c.y, t1.c.z, s1.c.y, s1.c.z]),
@@ -2229,22 +2209,18 @@ class ReduceTest(fixtures.TestBase, AssertsExecutionResults):
pjoin = union(
select(
- [
- page_table.c.id,
- magazine_page_table.c.page_id,
- classified_page_table.c.magazine_page_id,
- ]
+ page_table.c.id,
+ magazine_page_table.c.page_id,
+ classified_page_table.c.magazine_page_id,
).select_from(
page_table.join(magazine_page_table).join(
classified_page_table
)
),
select(
- [
- page_table.c.id,
- magazine_page_table.c.page_id,
- cast(null(), Integer).label("magazine_page_id"),
- ]
+ page_table.c.id,
+ magazine_page_table.c.page_id,
+ cast(null(), Integer).label("magazine_page_id"),
).select_from(page_table.join(magazine_page_table)),
).alias("pjoin")
eq_(
@@ -2265,18 +2241,14 @@ class ReduceTest(fixtures.TestBase, AssertsExecutionResults):
pjoin = union(
select(
- [
- page_table.c.id,
- magazine_page_table.c.page_id,
- cast(null(), Integer).label("magazine_page_id"),
- ]
+ page_table.c.id,
+ magazine_page_table.c.page_id,
+ cast(null(), Integer).label("magazine_page_id"),
).select_from(page_table.join(magazine_page_table)),
select(
- [
- page_table.c.id,
- magazine_page_table.c.page_id,
- classified_page_table.c.magazine_page_id,
- ]
+ page_table.c.id,
+ magazine_page_table.c.page_id,
+ classified_page_table.c.magazine_page_id,
).select_from(
page_table.join(magazine_page_table).join(
classified_page_table
@@ -2352,10 +2324,10 @@ class DerivedTest(fixtures.TestBase, AssertsExecutionResults):
assert t1.select().is_derived_from(t1)
assert not t2.select().is_derived_from(t1)
- assert select([t1, t2]).is_derived_from(t1)
+ assert select(t1, t2).is_derived_from(t1)
assert t1.select().alias("foo").is_derived_from(t1)
- assert select([t1, t2]).alias("foo").is_derived_from(t1)
+ assert select(t1, t2).alias("foo").is_derived_from(t1)
assert not t2.select().alias("foo").is_derived_from(t1)
@@ -2385,7 +2357,7 @@ class AnnotationsTest(fixtures.TestBase):
c1 = Column("foo", Integer)
- stmt = select([c1]).alias()
+ stmt = select(c1).alias()
proxy = stmt.c.foo
proxy.proxy_set
@@ -2406,7 +2378,7 @@ class AnnotationsTest(fixtures.TestBase):
c1 = Column("foo", Integer)
- stmt = select([c1]).alias()
+ stmt = select(c1).alias()
proxy = stmt.c.foo
c1.proxy_set
@@ -2462,7 +2434,7 @@ class AnnotationsTest(fixtures.TestBase):
assert isinstance(s1.c.foo, Column)
annot_1 = t1.c.foo._annotate({})
- s2 = select([annot_1]).subquery()
+ s2 = select(annot_1).subquery()
assert isinstance(s2.c.foo, Column)
annot_2 = s1._annotate({})
assert isinstance(annot_2.c.foo, Column)
@@ -2496,7 +2468,7 @@ class AnnotationsTest(fixtures.TestBase):
def test_annotated_corresponding_column(self):
table1 = table("table1", column("col1"))
- s1 = select([table1.c.col1]).subquery()
+ s1 = select(table1.c.col1).subquery()
t1 = s1._annotate({})
t2 = s1
@@ -2507,7 +2479,7 @@ class AnnotationsTest(fixtures.TestBase):
assert t1.c is t2.c
assert t1.c.col1 is t2.c.col1
- inner = select([s1]).subquery()
+ inner = select(s1).subquery()
assert (
inner.corresponding_column(t2.c.col1, require_embedded=False)
@@ -2555,7 +2527,7 @@ class AnnotationsTest(fixtures.TestBase):
def test_annotate_aliased(self):
t1 = table("t1", column("c1"))
- s = select([(t1.c.c1 + 3).label("bat")])
+ s = select((t1.c.c1 + 3).label("bat"))
a = s.alias()
a = sql_util._deep_annotate(a, {"foo": "bar"})
eq_(a._annotations["foo"], "bar")
@@ -2614,11 +2586,9 @@ class AnnotationsTest(fixtures.TestBase):
table1 = table("table1", column("col1"), column("col2"))
subq = (
- select([table1])
- .where(table1.c.col1 == bindparam("foo"))
- .subquery()
+ select(table1).where(table1.c.col1 == bindparam("foo")).subquery()
)
- stmt = select([subq])
+ stmt = select(subq)
s2 = sql_util._deep_annotate(stmt, {"_orm_adapt": True})
s3 = sql_util._deep_deannotate(s2)
@@ -2654,7 +2624,7 @@ class AnnotationsTest(fixtures.TestBase):
table1 = table("table1", column("x"))
table2 = table("table2", column("y"))
a1 = table1.alias()
- s = select([a1.c.x]).select_from(a1.join(table2, a1.c.x == table2.c.y))
+ s = select(a1.c.x).select_from(a1.join(table2, a1.c.x == table2.c.y))
for sel in (
sql_util._deep_deannotate(s),
visitors.cloned_traverse(s, {}, {}),
@@ -2687,8 +2657,8 @@ class AnnotationsTest(fixtures.TestBase):
"""
t1 = table("table1", column("col1"), column("col2"))
- s = select([t1.c.col1._annotate({"foo": "bar"})])
- s2 = select([t1.c.col1._annotate({"bat": "hoho"})])
+ s = select(t1.c.col1._annotate({"foo": "bar"}))
+ s2 = select(t1.c.col1._annotate({"bat": "hoho"}))
s3 = s.union(s2)
sel = sql_util._deep_annotate(s3, {"new": "thing"})
@@ -2740,9 +2710,9 @@ class AnnotationsTest(fixtures.TestBase):
table1 = table("table1", column("x"))
table2 = table("table2", column("y"))
a1 = table1.alias()
- s = select([a1.c.x]).select_from(a1.join(table2, a1.c.x == table2.c.y))
+ s = select(a1.c.x).select_from(a1.join(table2, a1.c.x == table2.c.y))
- assert_s = select([select([s.subquery()]).subquery()])
+ assert_s = select([select(s.subquery()).subquery()])
for fn in (
sql_util._deep_deannotate,
lambda s: sql_util._deep_annotate(s, {"foo": "bar"}),
@@ -2750,7 +2720,7 @@ class AnnotationsTest(fixtures.TestBase):
lambda s: visitors.replacement_traverse(s, {}, lambda x: None),
):
- sel = fn(select([fn(select([fn(s.subquery())]).subquery())]))
+ sel = fn(select([fn(select(fn(s.subquery())).subquery())]))
eq_(str(assert_s), str(sel))
def test_bind_unique_test(self):
@@ -2832,7 +2802,7 @@ class WithLabelsTest(fixtures.TestBase):
m = MetaData()
t1 = Table("t1", m, Column("x", Integer))
t2 = Table("t2", m, Column("x", Integer))
- return select([t1, t2])
+ return select(t1, t2)
def test_names_overlap_nolabel(self):
sel = self._names_overlap()
@@ -2850,7 +2820,7 @@ class WithLabelsTest(fixtures.TestBase):
m = MetaData()
t1 = Table("t1", m, Column("x", Integer, key="a"))
t2 = Table("t2", m, Column("x", Integer, key="b"))
- return select([t1, t2])
+ return select(t1, t2)
def test_names_overlap_keys_dont_nolabel(self):
sel = self._names_overlap_keys_dont()
@@ -2869,7 +2839,7 @@ class WithLabelsTest(fixtures.TestBase):
m = MetaData()
t1 = Table("t", m, Column("x_id", Integer))
t2 = Table("t_x", m, Column("id", Integer))
- return select([t1, t2])
+ return select(t1, t2)
def test_labels_overlap_nolabel(self):
sel = self._labels_overlap()
@@ -2894,7 +2864,7 @@ class WithLabelsTest(fixtures.TestBase):
m = MetaData()
t1 = Table("t", m, Column("x_id", Integer, key="a"))
t2 = Table("t_x", m, Column("id", Integer, key="b"))
- return select([t1, t2])
+ return select(t1, t2)
def test_labels_overlap_keylabels_dont_nolabel(self):
sel = self._labels_overlap_keylabels_dont()
@@ -2912,7 +2882,7 @@ class WithLabelsTest(fixtures.TestBase):
m = MetaData()
t1 = Table("t", m, Column("a", Integer, key="x_id"))
t2 = Table("t_x", m, Column("b", Integer, key="id"))
- return select([t1, t2])
+ return select(t1, t2)
def test_keylabels_overlap_labels_dont_nolabel(self):
sel = self._keylabels_overlap_labels_dont()
@@ -2935,7 +2905,7 @@ class WithLabelsTest(fixtures.TestBase):
m = MetaData()
t1 = Table("t", m, Column("x_id", Integer, key="x_a"))
t2 = Table("t_x", m, Column("id", Integer, key="a"))
- return select([t1, t2])
+ return select(t1, t2)
def test_keylabels_overlap_labels_overlap_nolabel(self):
sel = self._keylabels_overlap_labels_overlap()
@@ -2963,7 +2933,7 @@ class WithLabelsTest(fixtures.TestBase):
m = MetaData()
t1 = Table("t1", m, Column("a", Integer, key="x"))
t2 = Table("t2", m, Column("b", Integer, key="x"))
- return select([t1, t2])
+ return select(t1, t2)
def test_keys_overlap_names_dont_nolabel(self):
sel = self._keys_overlap_names_dont()
@@ -2993,7 +2963,7 @@ class ResultMapTest(fixtures.TestBase):
def test_select_label_alt_name(self):
t = self._fixture()
l1, l2 = t.c.x.label("a"), t.c.y.label("b")
- s = select([l1, l2])
+ s = select(l1, l2)
mapping = self._mapping(s)
assert l1 in mapping
@@ -3002,7 +2972,7 @@ class ResultMapTest(fixtures.TestBase):
def test_select_alias_label_alt_name(self):
t = self._fixture()
l1, l2 = t.c.x.label("a"), t.c.y.label("b")
- s = select([l1, l2]).alias()
+ s = select(l1, l2).alias()
mapping = self._mapping(s)
assert l1 in mapping
@@ -3011,7 +2981,7 @@ class ResultMapTest(fixtures.TestBase):
def test_select_alias_column(self):
t = self._fixture()
x, y = t.c.x, t.c.y
- s = select([x, y]).alias()
+ s = select(x, y).alias()
mapping = self._mapping(s)
assert t.c.x in mapping
@@ -3019,7 +2989,7 @@ class ResultMapTest(fixtures.TestBase):
def test_select_alias_column_apply_labels(self):
t = self._fixture()
x, y = t.c.x, t.c.y
- s = select([x, y]).apply_labels().alias()
+ s = select(x, y).apply_labels().alias()
mapping = self._mapping(s)
assert t.c.x in mapping
@@ -3028,7 +2998,7 @@ class ResultMapTest(fixtures.TestBase):
x = t.c.x
ta = t.alias()
- s = select([ta.c.x, ta.c.y])
+ s = select(ta.c.x, ta.c.y)
mapping = self._mapping(s)
assert x not in mapping
@@ -3039,7 +3009,7 @@ class ResultMapTest(fixtures.TestBase):
ta = t.alias()
l1, l2 = ta.c.x.label("a"), ta.c.y.label("b")
- s = select([l1, l2])
+ s = select(l1, l2)
mapping = self._mapping(s)
assert x not in mapping
assert l1 in mapping
@@ -3061,7 +3031,7 @@ class ResultMapTest(fixtures.TestBase):
eq_(
[
type(entry[-1])
- for entry in select([expr]).compile()._result_columns
+ for entry in select(expr).compile()._result_columns
],
[Boolean],
)
@@ -3072,7 +3042,7 @@ class ResultMapTest(fixtures.TestBase):
eq_(
[
type(entry[-1])
- for entry in select([expr]).compile()._result_columns
+ for entry in select(expr).compile()._result_columns
],
[Boolean],
)
@@ -3083,15 +3053,15 @@ class ResultMapTest(fixtures.TestBase):
eq_(
[
type(entry[-1])
- for entry in select([expr]).compile()._result_columns
+ for entry in select(expr).compile()._result_columns
],
[Boolean],
)
def test_column_subquery_plain(self):
t = self._fixture()
- s1 = select([t.c.x]).where(t.c.x > 5).scalar_subquery()
- s2 = select([s1])
+ s1 = select(t.c.x).where(t.c.x > 5).scalar_subquery()
+ s2 = select(s1)
mapping = self._mapping(s2)
assert t.c.x not in mapping
assert s1 in mapping
@@ -3114,7 +3084,7 @@ class ForUpdateTest(fixtures.TestBase, AssertsCompiledSQL):
def test_basic_clone(self):
t = table("t", column("c"))
- s = select([t]).with_for_update(read=True, of=t.c.c)
+ s = select(t).with_for_update(read=True, of=t.c.c)
s2 = visitors.ReplacingCloningVisitor().traverse(s)
assert s2._for_update_arg is not s._for_update_arg
eq_(s2._for_update_arg.read, True)
@@ -3125,7 +3095,7 @@ class ForUpdateTest(fixtures.TestBase, AssertsCompiledSQL):
def test_adapt(self):
t = table("t", column("c"))
- s = select([t]).with_for_update(read=True, of=t.c.c)
+ s = select(t).with_for_update(read=True, of=t.c.c)
a = t.alias()
s2 = sql_util.ClauseAdapter(a).traverse(s)
eq_(s2._for_update_arg.of, [a.c.c])
@@ -3151,14 +3121,14 @@ class AliasTest(fixtures.TestBase, AssertsCompiledSQL):
def test_get_children_preserves_multiple_nesting(self):
t = table("t", column("c"))
- stmt = select([t])
+ stmt = select(t)
a1 = stmt.alias()
a2 = a1.alias()
eq_(set(a2.get_children(column_collections=False)), {a1})
def test_correspondence_multiple_nesting(self):
t = table("t", column("c"))
- stmt = select([t])
+ stmt = select(t)
a1 = stmt.alias()
a2 = a1.alias()
@@ -3166,7 +3136,7 @@ class AliasTest(fixtures.TestBase, AssertsCompiledSQL):
def test_copy_internals_multiple_nesting(self):
t = table("t", column("c"))
- stmt = select([t])
+ stmt = select(t)
a1 = stmt.alias()
a2 = a1.alias()