summaryrefslogtreecommitdiff
path: root/test/sql
diff options
context:
space:
mode:
Diffstat (limited to 'test/sql')
-rw-r--r--test/sql/test_operators.py42
-rw-r--r--test/sql/test_query.py22
-rw-r--r--test/sql/test_resultset.py18
-rw-r--r--test/sql/test_selectable.py6
4 files changed, 52 insertions, 36 deletions
diff --git a/test/sql/test_operators.py b/test/sql/test_operators.py
index 43d9133a7..b2ba7ae73 100644
--- a/test/sql/test_operators.py
+++ b/test/sql/test_operators.py
@@ -1355,13 +1355,15 @@ class OperatorPrecedenceTest(fixtures.TestBase, testing.AssertsCompiledSQL):
def test_operator_precedence_1(self):
self.assert_compile(
- self.table2.select((self.table2.c.field == 5) == None), # noqa
+ self.table2.select().where(
+ (self.table2.c.field == 5) == None
+ ), # noqa
"SELECT op.field FROM op WHERE (op.field = :field_1) IS NULL",
)
def test_operator_precedence_2(self):
self.assert_compile(
- self.table2.select(
+ self.table2.select().where(
(self.table2.c.field + 5) == self.table2.c.field
),
"SELECT op.field FROM op WHERE op.field + :field_1 = op.field",
@@ -1369,33 +1371,33 @@ class OperatorPrecedenceTest(fixtures.TestBase, testing.AssertsCompiledSQL):
def test_operator_precedence_3(self):
self.assert_compile(
- self.table2.select((self.table2.c.field + 5) * 6),
+ self.table2.select().where((self.table2.c.field + 5) * 6),
"SELECT op.field FROM op WHERE (op.field + :field_1) * :param_1",
)
def test_operator_precedence_4(self):
self.assert_compile(
- self.table2.select((self.table2.c.field * 5) + 6),
+ self.table2.select().where((self.table2.c.field * 5) + 6),
"SELECT op.field FROM op WHERE op.field * :field_1 + :param_1",
)
def test_operator_precedence_5(self):
self.assert_compile(
- self.table2.select(5 + self.table2.c.field.in_([5, 6])),
+ self.table2.select().where(5 + self.table2.c.field.in_([5, 6])),
"SELECT op.field FROM op WHERE :param_1 + "
"(op.field IN ([POSTCOMPILE_field_1]))",
)
def test_operator_precedence_6(self):
self.assert_compile(
- self.table2.select((5 + self.table2.c.field).in_([5, 6])),
+ self.table2.select().where((5 + self.table2.c.field).in_([5, 6])),
"SELECT op.field FROM op WHERE :field_1 + op.field "
"IN ([POSTCOMPILE_param_1])",
)
def test_operator_precedence_7(self):
self.assert_compile(
- self.table2.select(
+ self.table2.select().where(
not_(and_(self.table2.c.field == 5, self.table2.c.field == 7))
),
"SELECT op.field FROM op WHERE NOT "
@@ -1404,26 +1406,28 @@ class OperatorPrecedenceTest(fixtures.TestBase, testing.AssertsCompiledSQL):
def test_operator_precedence_8(self):
self.assert_compile(
- self.table2.select(not_(self.table2.c.field == 5)),
+ self.table2.select().where(not_(self.table2.c.field == 5)),
"SELECT op.field FROM op WHERE op.field != :field_1",
)
def test_operator_precedence_9(self):
self.assert_compile(
- self.table2.select(not_(self.table2.c.field.between(5, 6))),
+ self.table2.select().where(
+ not_(self.table2.c.field.between(5, 6))
+ ),
"SELECT op.field FROM op WHERE "
"op.field NOT BETWEEN :field_1 AND :field_2",
)
def test_operator_precedence_10(self):
self.assert_compile(
- self.table2.select(not_(self.table2.c.field) == 5),
+ self.table2.select().where(not_(self.table2.c.field) == 5),
"SELECT op.field FROM op WHERE (NOT op.field) = :param_1",
)
def test_operator_precedence_11(self):
self.assert_compile(
- self.table2.select(
+ self.table2.select().where(
(self.table2.c.field == self.table2.c.field).between(
False, True
)
@@ -1434,7 +1438,7 @@ class OperatorPrecedenceTest(fixtures.TestBase, testing.AssertsCompiledSQL):
def test_operator_precedence_12(self):
self.assert_compile(
- self.table2.select(
+ self.table2.select().where(
between(
(self.table2.c.field == self.table2.c.field), False, True
)
@@ -1445,7 +1449,7 @@ class OperatorPrecedenceTest(fixtures.TestBase, testing.AssertsCompiledSQL):
def test_operator_precedence_13(self):
self.assert_compile(
- self.table2.select(
+ self.table2.select().where(
self.table2.c.field.match(self.table2.c.field).is_(None)
),
"SELECT op.field FROM op WHERE (op.field MATCH op.field) IS NULL",
@@ -1514,7 +1518,9 @@ class OperatorPrecedenceTest(fixtures.TestBase, testing.AssertsCompiledSQL):
def test_op_operators(self):
self.assert_compile(
- self.table1.select(self.table1.c.myid.op("hoho")(12) == 14),
+ self.table1.select().where(
+ self.table1.c.myid.op("hoho")(12) == 14
+ ),
"SELECT mytable.myid, mytable.name, mytable.description FROM "
"mytable WHERE (mytable.myid hoho :myid_1) = :param_1",
)
@@ -2319,7 +2325,7 @@ class NegationTest(fixtures.TestBase, testing.AssertsCompiledSQL):
def test_negate_operators_2(self):
self.assert_compile(
- self.table1.select(
+ self.table1.select().where(
(self.table1.c.myid != 12) & ~(self.table1.c.name == "john")
),
"SELECT mytable.myid, mytable.name FROM "
@@ -2329,7 +2335,7 @@ class NegationTest(fixtures.TestBase, testing.AssertsCompiledSQL):
def test_negate_operators_3(self):
self.assert_compile(
- self.table1.select(
+ self.table1.select().where(
(self.table1.c.myid != 12)
& ~(self.table1.c.name.between("jack", "john"))
),
@@ -2340,7 +2346,7 @@ class NegationTest(fixtures.TestBase, testing.AssertsCompiledSQL):
def test_negate_operators_4(self):
self.assert_compile(
- self.table1.select(
+ self.table1.select().where(
(self.table1.c.myid != 12)
& ~and_(
self.table1.c.name == "john",
@@ -2356,7 +2362,7 @@ class NegationTest(fixtures.TestBase, testing.AssertsCompiledSQL):
def test_negate_operators_5(self):
self.assert_compile(
- self.table1.select(
+ self.table1.select().where(
(self.table1.c.myid != 12) & ~self.table1.c.name
),
"SELECT mytable.myid, mytable.name FROM "
diff --git a/test/sql/test_query.py b/test/sql/test_query.py
index 14dc397f6..b3d728ab3 100644
--- a/test/sql/test_query.py
+++ b/test/sql/test_query.py
@@ -309,7 +309,9 @@ class QueryTest(fixtures.TablesTest):
connection.execute(users.insert(), dict(user_id=8, user_name="fred"))
u = bindparam("userid")
- s = users.select(and_(users.c.user_name == u, users.c.user_name == u))
+ s = users.select().where(
+ and_(users.c.user_name == u, users.c.user_name == u)
+ )
r = connection.execute(s, dict(userid="fred")).fetchall()
assert len(r) == 1
@@ -581,20 +583,20 @@ class QueryTest(fixtures.TablesTest):
connection.execute(users.insert(), dict(user_id=8, user_name="fred"))
connection.execute(users.insert(), dict(user_id=9, user_name=None))
- s = users.select(users.c.user_name.in_([]))
+ s = users.select().where(users.c.user_name.in_([]))
r = connection.execute(s).fetchall()
# No username is in empty set
assert len(r) == 0
- s = users.select(not_(users.c.user_name.in_([])))
+ s = users.select().where(not_(users.c.user_name.in_([])))
r = connection.execute(s).fetchall()
assert len(r) == 3
- s = users.select(users.c.user_name.in_(["jack", "fred"]))
+ s = users.select().where(users.c.user_name.in_(["jack", "fred"]))
r = connection.execute(s).fetchall()
assert len(r) == 2
- s = users.select(not_(users.c.user_name.in_(["jack", "fred"])))
+ s = users.select().where(not_(users.c.user_name.in_(["jack", "fred"])))
r = connection.execute(s).fetchall()
# Null values are not outside any set
assert len(r) == 0
@@ -842,7 +844,7 @@ class QueryTest(fixtures.TablesTest):
u = bindparam("search_key", type_=String)
- s = users.select(not_(u.in_([])))
+ s = users.select().where(not_(u.in_([])))
r = connection.execute(s, dict(search_key="john")).fetchall()
assert len(r) == 3
r = connection.execute(s, dict(search_key=None)).fetchall()
@@ -857,7 +859,7 @@ class QueryTest(fixtures.TablesTest):
connection.execute(users.insert(), dict(user_id=8, user_name="fred"))
connection.execute(users.insert(), dict(user_id=9, user_name=None))
- s = users.select(not_(literal("john").in_([])))
+ s = users.select().where(not_(literal("john").in_([])))
r = connection.execute(s).fetchall()
assert len(r) == 3
@@ -879,13 +881,13 @@ class QueryTest(fixtures.TablesTest):
],
)
- s = users.select(users.c.user_name.in_([]) == True) # noqa
+ s = users.select().where(users.c.user_name.in_([]) == True) # noqa
r = connection.execute(s).fetchall()
assert len(r) == 0
- s = users.select(users.c.user_name.in_([]) == False) # noqa
+ s = users.select().where(users.c.user_name.in_([]) == False) # noqa
r = connection.execute(s).fetchall()
assert len(r) == 3
- s = users.select(users.c.user_name.in_([]) == None) # noqa
+ s = users.select().where(users.c.user_name.in_([]) == None) # noqa
r = connection.execute(s).fetchall()
assert len(r) == 0
diff --git a/test/sql/test_resultset.py b/test/sql/test_resultset.py
index 892cfee53..b1ede060d 100644
--- a/test/sql/test_resultset.py
+++ b/test/sql/test_resultset.py
@@ -391,7 +391,9 @@ class CursorResultTest(fixtures.TablesTest):
],
)
- r = connection.execute(users.select(users.c.user_id == 2)).first()
+ r = connection.execute(
+ users.select().where(users.c.user_id == 2)
+ ).first()
eq_(r.user_id, 2)
eq_(r._mapping["user_id"], 2)
eq_(r._mapping[users.c.user_id], 2)
@@ -411,7 +413,9 @@ class CursorResultTest(fixtures.TablesTest):
],
)
- r = connection.execute(users.select(users.c.user_id == 2)).first()
+ r = connection.execute(
+ users.select().where(users.c.user_id == 2)
+ ).first()
eq_(r.user_id, 2)
eq_(r._mapping["user_id"], 2)
@@ -766,7 +770,9 @@ class CursorResultTest(fixtures.TablesTest):
users = self.tables.users
connection.execute(users.insert(), dict(user_id=1, user_name="john"))
- r = connection.execute(users.select(users.c.user_id == 1)).first()
+ r = connection.execute(
+ users.select().where(users.c.user_id == 1)
+ ).first()
connection.execute(users.delete())
connection.execute(users.insert(), r._mapping)
eq_(connection.execute(users.select()).fetchall(), [(1, "john")])
@@ -1241,7 +1247,9 @@ class CursorResultTest(fixtures.TablesTest):
users = self.tables.users
connection.execute(users.insert(), dict(user_id=1, user_name="foo"))
- r = connection.execute(users.select(users.c.user_id == 1)).first()
+ r = connection.execute(
+ users.select().where(users.c.user_id == 1)
+ ).first()
eq_(r[0], 1)
eq_(r[1], "foo")
eq_([x.lower() for x in r._fields], ["user_id", "user_name"])
@@ -1288,7 +1296,7 @@ class CursorResultTest(fixtures.TablesTest):
),
)
r = connection.execute(
- shadowed.select(shadowed.c.shadow_id == 1)
+ shadowed.select().where(shadowed.c.shadow_id == 1)
).first()
eq_(r.shadow_id, 1)
diff --git a/test/sql/test_selectable.py b/test/sql/test_selectable.py
index efa3be523..00ef92efb 100644
--- a/test/sql/test_selectable.py
+++ b/test/sql/test_selectable.py
@@ -2422,9 +2422,9 @@ class ReduceTest(fixtures.TestBase, AssertsExecutionResults):
item_join = polymorphic_union(
{
- "BaseItem": base_item_table.select(
- base_item_table.c.child_name == "BaseItem"
- ).subquery(),
+ "BaseItem": base_item_table.select()
+ .where(base_item_table.c.child_name == "BaseItem")
+ .subquery(),
"Item": base_item_table.join(item_table),
},
None,