diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-08-30 12:19:54 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-08-30 12:27:21 -0400 |
| commit | 51c24329181f8bef17348f9b3899303569d32c81 (patch) | |
| tree | 193936c051ba2e11231ac4324157bb5a4de2f50e /lib/sqlalchemy | |
| parent | 812c08efb41ff0a8bdafb876fe49079da5074916 (diff) | |
| download | sqlalchemy-51c24329181f8bef17348f9b3899303569d32c81.tar.gz | |
Add preparer to pymssql that disables percent doubling
Fixed the pymssql dialect so that percent signs in SQL text, such
as used in modulus expressions or literal textual values, are
**not** doubled up, as seems to be what pymssql expects. This is
despite the fact that the pymssql DBAPI uses the "pyformat" parameter
style which itself considers the percent sign to be significant.
Tests are part of standard suite already (CI has been disabled)
Change-Id: Ie05de403caefcba3292a967183a995e95a5854d5
Fixes: #4057
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/dialects/mssql/pymssql.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/sqlalchemy/dialects/mssql/pymssql.py b/lib/sqlalchemy/dialects/mssql/pymssql.py index cd800471d..51237990e 100644 --- a/lib/sqlalchemy/dialects/mssql/pymssql.py +++ b/lib/sqlalchemy/dialects/mssql/pymssql.py @@ -18,7 +18,7 @@ pymssql is a Python module that provides a Python DBAPI interface around Linux, MacOSX and Windows platforms. """ -from .base import MSDialect +from .base import MSDialect, MSIdentifierPreparer from ... import types as sqltypes, util, processors import re @@ -31,10 +31,21 @@ class _MSNumeric_pymssql(sqltypes.Numeric): return sqltypes.Numeric.result_processor(self, dialect, type_) +class MSIdentifierPreparer_pymssql(MSIdentifierPreparer): + + def __init__(self, dialect): + super(MSIdentifierPreparer_pymssql, self).__init__(dialect) + # pymssql has the very unusual behavior that it uses pyformat + # yet does not require that percent signs be doubled + self._double_percents = False + + class MSDialect_pymssql(MSDialect): supports_sane_rowcount = False driver = 'pymssql' + preparer = MSIdentifierPreparer_pymssql + colspecs = util.update_copy( MSDialect.colspecs, { |
