summaryrefslogtreecommitdiff
path: root/test/sql/test_update.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2020-01-24 14:07:24 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2020-02-12 12:44:47 -0500
commit9fca5d827d880ccc529c94bb65c46de6aafd227c (patch)
tree54383b90c6acfc644c563872f131724fed5ef6ea /test/sql/test_update.py
parent47202abbf9823e1058e0b88ce64ffd3b88027e96 (diff)
downloadsqlalchemy-9fca5d827d880ccc529c94bb65c46de6aafd227c.tar.gz
Create initial future package, RemovedIn20Warning
Reorganization of Select() is the first major element of the 2.0 restructuring. In order to start this we need to first create the new Select constructor and apply legacy elements to the old one. This in turn necessitates starting up the RemovedIn20Warning concept which itself need to refer to "sqlalchemy.future", so begin to establish this basic framework. Additionally, update the DML constructors with the newer no-keyword style. Remove the use of the "pending deprecation" and fix Query.add_column() deprecation which was not acting as deprecated. Fixes: #4845 Fixes: #4648 Change-Id: I0c7a22b2841a985e1c379a0bb6c94089aae6264c
Diffstat (limited to 'test/sql/test_update.py')
-rw-r--r--test/sql/test_update.py61
1 files changed, 59 insertions, 2 deletions
diff --git a/test/sql/test_update.py b/test/sql/test_update.py
index 0313db832..68db6270f 100644
--- a/test/sql/test_update.py
+++ b/test/sql/test_update.py
@@ -505,7 +505,7 @@ class UpdateTest(_UpdateFromTestBase, fixtures.TablesTest, AssertsCompiledSQL):
column_keys=["j"],
)
- def test_update_ordered_parameters_1(self):
+ def test_update_ordered_parameters_oldstyle_1(self):
table1 = self.tables.mytable
# Confirm that we can pass values as list value pairs
@@ -534,7 +534,35 @@ class UpdateTest(_UpdateFromTestBase, fixtures.TablesTest, AssertsCompiledSQL):
"mytable.name = :param_2 || mytable.name || :param_3",
)
- def test_update_ordered_parameters_2(self):
+ def test_update_ordered_parameters_newstyle_1(self):
+ table1 = self.tables.mytable
+
+ # Confirm that we can pass values as list value pairs
+ # note these are ordered *differently* from table.c
+ values = [
+ (table1.c.name, table1.c.name + "lala"),
+ (table1.c.myid, func.do_stuff(table1.c.myid, literal("hoho"))),
+ ]
+ self.assert_compile(
+ update(table1)
+ .where(
+ (table1.c.myid == func.hoho(4))
+ & (
+ table1.c.name
+ == literal("foo") + table1.c.name + literal("lala")
+ )
+ )
+ .ordered_values(*values),
+ "UPDATE mytable "
+ "SET "
+ "name=(mytable.name || :name_1), "
+ "myid=do_stuff(mytable.myid, :param_1) "
+ "WHERE "
+ "mytable.myid = hoho(:hoho_1) AND "
+ "mytable.name = :param_2 || mytable.name || :param_3",
+ )
+
+ def test_update_ordered_parameters_oldstyle_2(self):
table1 = self.tables.mytable
# Confirm that we can pass values as list value pairs
@@ -564,6 +592,35 @@ class UpdateTest(_UpdateFromTestBase, fixtures.TablesTest, AssertsCompiledSQL):
"mytable.name = :param_2 || mytable.name || :param_3",
)
+ def test_update_ordered_parameters_newstyle_2(self):
+ table1 = self.tables.mytable
+
+ # Confirm that we can pass values as list value pairs
+ # note these are ordered *differently* from table.c
+ values = [
+ (table1.c.name, table1.c.name + "lala"),
+ ("description", "some desc"),
+ (table1.c.myid, func.do_stuff(table1.c.myid, literal("hoho"))),
+ ]
+ self.assert_compile(
+ update(
+ table1,
+ (table1.c.myid == func.hoho(4))
+ & (
+ table1.c.name
+ == literal("foo") + table1.c.name + literal("lala")
+ ),
+ ).ordered_values(*values),
+ "UPDATE mytable "
+ "SET "
+ "name=(mytable.name || :name_1), "
+ "description=:description, "
+ "myid=do_stuff(mytable.myid, :param_1) "
+ "WHERE "
+ "mytable.myid = hoho(:hoho_1) AND "
+ "mytable.name = :param_2 || mytable.name || :param_3",
+ )
+
def test_update_ordered_parameters_fire_onupdate(self):
table = self.tables.update_w_default