diff options
author | Federico Caselli <cfederico87@gmail.com> | 2020-09-02 23:46:06 +0200 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-09-08 17:13:48 -0400 |
commit | e8600608669d90c4a6385b312d271aed63eb5854 (patch) | |
tree | ef984a01c536b2c81d2283b3ca5d9f4395f41dd0 /test/sql/test_from_linter.py | |
parent | 0d56a62f721ee6c91d8a8b6a407b959c9215b3b6 (diff) | |
download | sqlalchemy-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 'test/sql/test_from_linter.py')
-rw-r--r-- | test/sql/test_from_linter.py | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/test/sql/test_from_linter.py b/test/sql/test_from_linter.py index 416f89de3..6afe41aac 100644 --- a/test/sql/test_from_linter.py +++ b/test/sql/test_from_linter.py @@ -33,7 +33,7 @@ class TestFindUnmatchingFroms(fixtures.TablesTest): def test_everything_is_connected(self): query = ( - select([self.a]) + select(self.a) .select_from(self.a.join(self.b, self.a.c.col_a == self.b.c.col_b)) .select_from(self.c) .select_from(self.d) @@ -49,7 +49,7 @@ class TestFindUnmatchingFroms(fixtures.TablesTest): assert not froms def test_plain_cartesian(self): - query = select([self.a]).where(self.b.c.col_b == 5) + query = select(self.a).where(self.b.c.col_b == 5) froms, start = find_unmatching_froms(query, self.a) assert start == self.a assert froms == {self.b} @@ -59,20 +59,20 @@ class TestFindUnmatchingFroms(fixtures.TablesTest): assert froms == {self.a} def test_count_non_eq_comparison_operators(self): - query = select([self.a]).where(self.a.c.col_a > self.b.c.col_b) + query = select(self.a).where(self.a.c.col_a > self.b.c.col_b) froms, start = find_unmatching_froms(query, self.a) is_(start, None) is_(froms, None) def test_dont_count_non_comparison_operators(self): - query = select([self.a]).where(self.a.c.col_a + self.b.c.col_b == 5) + query = select(self.a).where(self.a.c.col_a + self.b.c.col_b == 5) froms, start = find_unmatching_froms(query, self.a) assert start == self.a assert froms == {self.b} def test_disconnect_between_ab_cd(self): query = ( - select([self.a]) + select(self.a) .select_from(self.a.join(self.b, self.a.c.col_a == self.b.c.col_b)) .select_from(self.c) .select_from(self.d) @@ -90,7 +90,7 @@ class TestFindUnmatchingFroms(fixtures.TablesTest): def test_c_and_d_both_disconnected(self): query = ( - select([self.a]) + select(self.a) .select_from(self.a.join(self.b, self.a.c.col_a == self.b.c.col_b)) .where(self.c.c.col_c == 5) .where(self.d.c.col_d == 10) @@ -110,7 +110,7 @@ class TestFindUnmatchingFroms(fixtures.TablesTest): def test_now_connected(self): query = ( - select([self.a]) + select(self.a) .select_from(self.a.join(self.b, self.a.c.col_a == self.b.c.col_b)) .select_from(self.c.join(self.d, self.c.c.col_c == self.d.c.col_d)) .where(self.c.c.col_c == self.b.c.col_b) @@ -126,9 +126,9 @@ class TestFindUnmatchingFroms(fixtures.TablesTest): def test_disconnected_subquery(self): subq = ( - select([self.a]).where(self.a.c.col_a == self.b.c.col_b).subquery() + select(self.a).where(self.a.c.col_a == self.b.c.col_b).subquery() ) - stmt = select([self.c]).select_from(subq) + stmt = select(self.c).select_from(subq) froms, start = find_unmatching_froms(stmt, self.c) assert start == self.c @@ -140,10 +140,10 @@ class TestFindUnmatchingFroms(fixtures.TablesTest): def test_now_connect_it(self): subq = ( - select([self.a]).where(self.a.c.col_a == self.b.c.col_b).subquery() + select(self.a).where(self.a.c.col_a == self.b.c.col_b).subquery() ) stmt = ( - select([self.c]) + select(self.c) .select_from(subq) .where(self.c.c.col_c == subq.c.col_a) ) @@ -156,7 +156,7 @@ class TestFindUnmatchingFroms(fixtures.TablesTest): assert not froms def test_right_nested_join_without_issue(self): - query = select([self.a]).select_from( + query = select(self.a).select_from( self.a.join( self.b.join(self.c, self.b.c.col_b == self.c.c.col_c), self.a.c.col_a == self.b.c.col_b, @@ -174,13 +174,13 @@ class TestFindUnmatchingFroms(fixtures.TablesTest): # actually a join condition. this essentially allows a cartesian # product to be added explicitly. - query = select([self.a]).select_from(self.a.join(self.b, true())) + query = select(self.a).select_from(self.a.join(self.b, true())) froms, start = find_unmatching_froms(query) assert not froms def test_right_nested_join_with_an_issue(self): query = ( - select([self.a]) + select(self.a) .select_from( self.a.join( self.b.join(self.c, self.b.c.col_b == self.c.c.col_c), @@ -200,7 +200,7 @@ class TestFindUnmatchingFroms(fixtures.TablesTest): assert froms == {self.a, self.b, self.c} def test_no_froms(self): - query = select([1]) + query = select(1) froms, start = find_unmatching_froms(query) assert not froms @@ -223,12 +223,12 @@ class TestLinter(fixtures.TablesTest): def test_does_not_modify_query(self): with self.bind.connect() as conn: - [result] = conn.execute(select([1])).fetchone() + [result] = conn.execute(select(1)).fetchone() assert result == 1 def test_warn_simple(self): a, b = self.tables("table_a", "table_b") - query = select([a.c.col_a]).where(b.c.col_b == 5) + query = select(a.c.col_a).where(b.c.col_b == 5) with expect_warnings( r"SELECT statement has a cartesian product between FROM " @@ -242,7 +242,7 @@ class TestLinter(fixtures.TablesTest): a, b = self.tables("table_a", "table_b") b_alias = b.alias() - query = select([a.c.col_a]).where(b_alias.c.col_b == 5) + query = select(a.c.col_a).where(b_alias.c.col_b == 5) with expect_warnings( r"SELECT statement has a cartesian product between FROM " @@ -255,8 +255,8 @@ class TestLinter(fixtures.TablesTest): def test_warn_anon_cte(self): a, b = self.tables("table_a", "table_b") - b_cte = select([b]).cte() - query = select([a.c.col_a]).where(b_cte.c.col_b == 5) + b_cte = select(b).cte() + query = select(a.c.col_a).where(b_cte.c.col_b == 5) with expect_warnings( r"SELECT statement has a cartesian product between " @@ -271,7 +271,7 @@ class TestLinter(fixtures.TablesTest): eng = engines.testing_engine(options={"enable_from_linting": False}) eng.pool = self.bind.pool # needed for SQLite a, b = self.tables("table_a", "table_b") - query = select([a.c.col_a]).where(b.c.col_b == 5) + query = select(a.c.col_a).where(b.c.col_b == 5) with eng.connect() as conn: conn.execute(query) |