diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-04-17 13:37:39 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-04-29 11:54:25 -0400 |
| commit | 099522075088a3e1a333a2285c10a8a33b203c19 (patch) | |
| tree | b1359c9ff50d19e4787d8ead0bfe5b03ad1fb69a /test/sql/test_operators.py | |
| parent | 2f55c844051d9fe8865576bd77107e94c6de16c1 (diff) | |
| download | sqlalchemy-099522075088a3e1a333a2285c10a8a33b203c19.tar.gz | |
Reimplement .compare() in terms of a visitor
Reworked the :meth:`.ClauseElement.compare` methods in terms of a new
visitor-based approach, and additionally added test coverage ensuring that
all :class:`.ClauseElement` subclasses can be accurately compared
against each other in terms of structure. Structural comparison
capability is used to a small degree within the ORM currently, however
it also may form the basis for new caching features.
Fixes: #4336
Change-Id: I581b667d8e1642a6c27165cc9f4aded1c66effc6
Diffstat (limited to 'test/sql/test_operators.py')
| -rw-r--r-- | test/sql/test_operators.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/test/sql/test_operators.py b/test/sql/test_operators.py index 82c69003b..c6eff6ac9 100644 --- a/test/sql/test_operators.py +++ b/test/sql/test_operators.py @@ -38,6 +38,7 @@ from sqlalchemy.sql import sqltypes from sqlalchemy.sql import table from sqlalchemy.sql import true from sqlalchemy.sql.elements import _literal_as_text +from sqlalchemy.sql.elements import BindParameter from sqlalchemy.sql.elements import Label from sqlalchemy.sql.expression import BinaryExpression from sqlalchemy.sql.expression import ClauseList @@ -193,7 +194,13 @@ class DefaultColumnComparatorTest(fixtures.TestBase): assert left.comparator.operate(operators.in_op, [1, 2, 3]).compare( BinaryExpression( left, - Grouping(ClauseList(literal(1), literal(2), literal(3))), + Grouping( + ClauseList( + BindParameter("left", value=1, unique=True), + BindParameter("left", value=2, unique=True), + BindParameter("left", value=3, unique=True), + ) + ), operators.in_op, ) ) @@ -204,7 +211,13 @@ class DefaultColumnComparatorTest(fixtures.TestBase): assert left.comparator.operate(operators.notin_op, [1, 2, 3]).compare( BinaryExpression( left, - Grouping(ClauseList(literal(1), literal(2), literal(3))), + Grouping( + ClauseList( + BindParameter("left", value=1, unique=True), + BindParameter("left", value=2, unique=True), + BindParameter("left", value=3, unique=True), + ) + ), operators.notin_op, ) ) |
