summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2015-11-28 12:23:21 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2015-11-28 12:23:21 -0500
commitb8a825978e7998614cd10f53b84f9f5015fb59a7 (patch)
tree9a7994f0125ebc7b9b27b6f2296773a260a3d1d6
parentab0874e893af4331b43055776aa5a44e4d6a995e (diff)
downloadsqlalchemy-pr200_updated.tar.gz
- add tests for ordered params with onupdatespr200_updated
-rw-r--r--test/sql/test_update.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/sql/test_update.py b/test/sql/test_update.py
index 0b01071a8..3ab580b11 100644
--- a/test/sql/test_update.py
+++ b/test/sql/test_update.py
@@ -33,6 +33,11 @@ class _UpdateFromTestBase(object):
test_needs_autoincrement=True),
Column('address_id', None, ForeignKey('addresses.id')),
Column('data', String(30)))
+ Table('update_w_default', metadata,
+ Column('id', Integer, primary_key=True),
+ Column('x', Integer),
+ Column('ycol', Integer, key='y'),
+ Column('data', String(30), onupdate=lambda: "hi"))
@classmethod
def fixtures(cls):
@@ -236,6 +241,35 @@ class UpdateTest(_UpdateFromTestBase, fixtures.TablesTest, AssertsCompiledSQL):
'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
+
+ values = [
+ (table.c.y, table.c.x + 5),
+ ('x', 10)
+ ]
+
+ self.assert_compile(
+ table.update(preserve_parameter_order=True).values(values),
+ "UPDATE update_w_default SET ycol=(update_w_default.x + :x_1), "
+ "x=:x, data=:data"
+ )
+
+ def test_update_ordered_parameters_override_onupdate(self):
+ table = self.tables.update_w_default
+
+ values = [
+ (table.c.y, table.c.x + 5),
+ (table.c.data, table.c.x + 10),
+ ('x', 10)
+ ]
+
+ self.assert_compile(
+ table.update(preserve_parameter_order=True).values(values),
+ "UPDATE update_w_default SET ycol=(update_w_default.x + :x_1), "
+ "data=(update_w_default.x + :x_2), x=:x"
+ )
+
def test_update_preserve_order_reqs_listtups(self):
table1 = self.tables.mytable
testing.assert_raises_message(