From 9fca5d827d880ccc529c94bb65c46de6aafd227c Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 24 Jan 2020 14:07:24 -0500 Subject: 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 --- test/sql/test_update.py | 61 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 2 deletions(-) (limited to 'test/sql/test_update.py') 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 -- cgit v1.2.1