diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-07-04 15:54:29 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-04-05 12:18:36 -0400 |
| commit | 86ef507cc73ee4a0a104b334d7ce08ad045e0c76 (patch) | |
| tree | a077e8f2de416e7a2affb898a13982f8136ad8ba /lib/sqlalchemy/testing/suite | |
| parent | 87b1404eda0f6d2e99b3b2a01ae1c641fbe91311 (diff) | |
| download | sqlalchemy-86ef507cc73ee4a0a104b334d7ce08ad045e0c76.tar.gz | |
Double percent signs based on paramstyle, not dialect
This patch moves the "doubling" of percent signs into
the base compiler and makes it completely a product
of whether or not the paramstyle is format/pyformat or
not. Without this paramstyle, percent signs
are not doubled across text(), literal_column(), and
column().
Change-Id: Ie2f278ab1dbb94b5078f85c0096d74dbfa049197
Fixes: #3740
Diffstat (limited to 'lib/sqlalchemy/testing/suite')
| -rw-r--r-- | lib/sqlalchemy/testing/suite/test_dialect.py | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/lib/sqlalchemy/testing/suite/test_dialect.py b/lib/sqlalchemy/testing/suite/test_dialect.py index 00884a212..0e62c347f 100644 --- a/lib/sqlalchemy/testing/suite/test_dialect.py +++ b/lib/sqlalchemy/testing/suite/test_dialect.py @@ -1,9 +1,11 @@ from .. import fixtures, config from ..config import requirements from sqlalchemy import exc -from sqlalchemy import Integer, String +from sqlalchemy import Integer, String, select, literal_column from .. import assert_raises from ..schema import Table, Column +from .. import provide_metadata +from .. import eq_ class ExceptionTest(fixtures.TablesTest): @@ -39,3 +41,33 @@ class ExceptionTest(fixtures.TablesTest): self.tables.manual_pk.insert(), {'id': 1, 'data': 'd1'} ) + + +class EscapingTest(fixtures.TestBase): + @provide_metadata + def test_percent_sign_round_trip(self): + """test that the DBAPI accommodates for escaped / nonescaped + percent signs in a way that matches the compiler + + """ + m = self.metadata + t = Table('t', m, Column('data', String(50))) + t.create(config.db) + with config.db.begin() as conn: + conn.execute(t.insert(), dict(data="some % value")) + conn.execute(t.insert(), dict(data="some %% other value")) + + eq_( + conn.scalar( + select([t.c.data]).where( + t.c.data == literal_column("'some % value'")) + ), + "some % value" + ) + + eq_( + conn.scalar( + select([t.c.data]).where( + t.c.data == literal_column("'some %% other value'")) + ), "some %% other value" + ) |
