Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expanding IN regex too greedy #4140

Closed
sqlalchemy-bot opened this issue Dec 1, 2017 · 3 comments
Closed

expanding IN regex too greedy #4140

sqlalchemy-bot opened this issue Dec 1, 2017 · 3 comments
Labels
bug Something isn't working engine engines, connections, transactions, isolation levels, execution options high priority
Milestone

Comments

@sqlalchemy-bot
Copy link
Collaborator

Migrated issue, originally created by Michael Bayer (@zzzeek)

diff --git a/test/sql/test_query.py b/test/sql/test_query.py
index afb113748..d6e0c18e6 100644
--- a/test/sql/test_query.py
+++ b/test/sql/test_query.py
@@ -471,6 +471,63 @@ class QueryTest(fixtures.TestBase):
                 ), [{"uname": ['fred']}, {"uname": ['ed']}]
             )
 
+    def test_expanding_in_special_chars(self):
+        testing.db.execute(
+            users.insert(),
+            [
+                dict(user_id=7, user_name='jack'),
+                dict(user_id=8, user_name='fred'),
+            ]
+        )
+
+        with testing.db.connect() as conn:
+            stmt = select([users]).where(
+                users.c.user_name.in_(bindparam('u35', expanding=True))
+            ).where(
+                users.c.user_id == bindparam("u46")
+            ).order_by(users.c.user_id)
+
+            eq_(
+                conn.execute(stmt, {"u35": ['jack'], "u46": 7}).fetchall(),
+                [(7, 'jack')]
+            )
+
+            stmt = select([users]).where(
+                users.c.user_name.in_(bindparam('u.35', expanding=True))
+            ).where(
+                users.c.user_id == bindparam("u.46")
+            ).order_by(users.c.user_id)
+
+            eq_(
+                conn.execute(stmt, {"u.35": ['jack'], "u.46": 7}).fetchall(),
+                [(7, 'jack')]
+            )
+
+    def test_expanding_in_multiple(self):
+        testing.db.execute(
+            users.insert(),
+            [
+                dict(user_id=7, user_name='jack'),
+                dict(user_id=8, user_name='fred'),
+                dict(user_id=9, user_name='ed')
+            ]
+        )
+
+        with testing.db.connect() as conn:
+            stmt = select([users]).where(
+                users.c.user_name.in_(bindparam('uname', expanding=True))
+            ).where(
+                users.c.user_id.in_(bindparam('uid', expanding=True))
+            ).order_by(users.c.user_id)
+
+            eq_(
+                conn.execute(
+                    stmt,
+                    {"uname": ['jack', 'fred', 'ed'], "uid": [8, 9]}
+                ).fetchall(),
+                [(8, 'fred'), (9, 'ed')]
+            )
+
     @testing.requires.tuple_in
     def test_expanding_in_composite(self):
         testing.db.execute(

@sqlalchemy-bot
Copy link
Collaborator Author

Michael Bayer (@zzzeek) wrote:

https://gerrit.sqlalchemy.org/605

@sqlalchemy-bot
Copy link
Collaborator Author

Michael Bayer (@zzzeek) wrote:

Fix regexp for expanding IN

Fixed bug in new "expanding bind parameter" feature whereby if multiple
params were used in one statement, the regular expression would not
match the parameter name correctly.

Change-Id: Ifaf7d627aac4ead2a13c8dddccb5c515253d88e6
Fixes: #4140

e447582

@sqlalchemy-bot
Copy link
Collaborator Author

Changes by Michael Bayer (@zzzeek):

  • changed status to closed

@sqlalchemy-bot sqlalchemy-bot added high priority bug Something isn't working engine engines, connections, transactions, isolation levels, execution options labels Nov 27, 2018
@sqlalchemy-bot sqlalchemy-bot added this to the 1.2 milestone Nov 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working engine engines, connections, transactions, isolation levels, execution options high priority
Projects
None yet
Development

No branches or pull requests

1 participant