summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2019-12-11 11:04:26 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2019-12-11 11:04:26 -0500
commitfce052b2af28001f4269c0790e0d1c4464813675 (patch)
treee41b37cc819a49eda24e5ae1c3e9866251e30887
parent9ce6b030e7f530afbd3dac25721ac5aaa53c6557 (diff)
downloadoslo-db-fce052b2af28001f4269c0790e0d1c4464813675.tar.gz
Use regex to compare SQL strings with IN5.1.1
SQLAlchemy 1.4 will be changing the method by which it renders an IN expression such that the bound parameters are not fully rendered until the statement is executed, rather than when the statement is compiled into its initial string form [1]. Adjust tests which are asserting the presence of IN expressions based on the compiled form to allow for an arbitrary expression within the parenthesis. [1] https://github.com/sqlalchemy/sqlalchemy/issues/4645 Change-Id: I8640ad0cbd96647ed74678631479190146bd908e
-rw-r--r--oslo_db/tests/sqlalchemy/test_update_match.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/oslo_db/tests/sqlalchemy/test_update_match.py b/oslo_db/tests/sqlalchemy/test_update_match.py
index 36ebf73..15eeed4 100644
--- a/oslo_db/tests/sqlalchemy/test_update_match.py
+++ b/oslo_db/tests/sqlalchemy/test_update_match.py
@@ -60,19 +60,19 @@ class ManufactureCriteriaTest(oslo_test_base.BaseTestCase):
specimen = MyModel(
y='y1', z=('z1', 'z2'),
)
- self.assertEqual(
- "my_table.y = :y_1 AND my_table.z IN (:z_1, :z_2)",
- str(update_match.manufacture_entity_criteria(specimen).compile())
+ self.assertRegex(
+ str(update_match.manufacture_entity_criteria(specimen).compile()),
+ r"my_table.y = :y_1 AND my_table.z IN \(.+?\)",
)
def test_instance_criteria_tuples_wnone(self):
specimen = MyModel(
y='y1', z=('z1', 'z2', None),
)
- self.assertEqual(
- "my_table.y = :y_1 AND (my_table.z IS NULL OR "
- "my_table.z IN (:z_1, :z_2))",
- str(update_match.manufacture_entity_criteria(specimen).compile())
+ self.assertRegex(
+ str(update_match.manufacture_entity_criteria(specimen).compile()),
+ r"my_table.y = :y_1 AND \(my_table.z IS NULL OR "
+ r"my_table.z IN \(.+?\)\)",
)
def test_instance_criteria_none_list(self):