summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/postgresql/pg8000.py
diff options
context:
space:
mode:
authorPhilip Jenvey <pjenvey@underboss.org>2009-08-11 05:12:50 +0000
committerPhilip Jenvey <pjenvey@underboss.org>2009-08-11 05:12:50 +0000
commit1b43a06aaccf9ed17db7364896dab50761a44e34 (patch)
treed186174b74f48df5446dfed30d9dd5e425dd1ae1 /lib/sqlalchemy/dialects/postgresql/pg8000.py
parentcd33d09ce08f04078840b322d203a9f262513a3f (diff)
downloadsqlalchemy-1b43a06aaccf9ed17db7364896dab50761a44e34.tar.gz
move postgresql's % escape handling out of base
Diffstat (limited to 'lib/sqlalchemy/dialects/postgresql/pg8000.py')
-rw-r--r--lib/sqlalchemy/dialects/postgresql/pg8000.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/pg8000.py b/lib/sqlalchemy/dialects/postgresql/pg8000.py
index e8dd03113..2a5c4e032 100644
--- a/lib/sqlalchemy/dialects/postgresql/pg8000.py
+++ b/lib/sqlalchemy/dialects/postgresql/pg8000.py
@@ -22,7 +22,7 @@ from sqlalchemy.engine import default
import decimal
from sqlalchemy import util
from sqlalchemy import types as sqltypes
-from sqlalchemy.dialects.postgresql.base import PGDialect, PGCompiler
+from sqlalchemy.dialects.postgresql.base import PGDialect, PGCompiler, PGIdentifierPreparer
class _PGNumeric(sqltypes.Numeric):
def bind_processor(self, dialect):
@@ -39,13 +39,27 @@ class _PGNumeric(sqltypes.Numeric):
return value
return process
+
class PostgreSQL_pg8000ExecutionContext(default.DefaultExecutionContext):
pass
+
class PostgreSQL_pg8000Compiler(PGCompiler):
def visit_mod(self, binary, **kw):
return self.process(binary.left) + " %% " + self.process(binary.right)
-
+
+ def post_process_text(self, text):
+ if '%%' in text:
+ util.warn("The SQLAlchemy postgresql dialect now automatically escapes '%' in text() "
+ "expressions to '%%'.")
+ return text.replace('%', '%%')
+
+
+class PostgreSQL_pg8000IdentifierPreparer(PGIdentifierPreparer):
+ def _escape_identifier(self, value):
+ value = value.replace(self.escape_quote, self.escape_to_quote)
+ return value.replace('%', '%%')
+
class PostgreSQL_pg8000(PGDialect):
driver = 'pg8000'
@@ -58,6 +72,7 @@ class PostgreSQL_pg8000(PGDialect):
supports_sane_multi_rowcount = False
execution_ctx_cls = PostgreSQL_pg8000ExecutionContext
statement_compiler = PostgreSQL_pg8000Compiler
+ preparer = PostgreSQL_pg8000IdentifierPreparer
colspecs = util.update_copy(
PGDialect.colspecs,