diff options
Diffstat (limited to 'lib/sqlalchemy/testing')
| -rw-r--r-- | lib/sqlalchemy/testing/assertsql.py | 8 | ||||
| -rw-r--r-- | lib/sqlalchemy/testing/suite/test_types.py | 6 |
2 files changed, 9 insertions, 5 deletions
diff --git a/lib/sqlalchemy/testing/assertsql.py b/lib/sqlalchemy/testing/assertsql.py index 46fdf6b9b..d9aa3e256 100644 --- a/lib/sqlalchemy/testing/assertsql.py +++ b/lib/sqlalchemy/testing/assertsql.py @@ -266,6 +266,10 @@ class DialectSQL(CompiledSQL): def _dialect_adjusted_statement(self, paramstyle): stmt = re.sub(r"[\n\t]", "", self.statement) + + # temporarily escape out PG double colons + stmt = stmt.replace("::", "!!") + if paramstyle == "pyformat": stmt = re.sub(r":([\w_]+)", r"%(\1)s", stmt) else: @@ -278,6 +282,10 @@ class DialectSQL(CompiledSQL): elif paramstyle == "numeric": repl = None stmt = re.sub(r":([\w_]+)", repl, stmt) + + # put them back + stmt = stmt.replace("!!", "::") + return stmt def _compare_sql(self, execute_observed, received_statement): diff --git a/lib/sqlalchemy/testing/suite/test_types.py b/lib/sqlalchemy/testing/suite/test_types.py index 7989b1e39..82e6fa238 100644 --- a/lib/sqlalchemy/testing/suite/test_types.py +++ b/lib/sqlalchemy/testing/suite/test_types.py @@ -480,19 +480,15 @@ class CastTypeDecoratorTest(_LiteralRoundTripFixture, fixtures.TestBase): impl = String(50) cache_ok = True - def get_dbapi_type(self, dbapi): - return dbapi.NUMBER - def column_expression(self, col): return cast(col, Integer) def bind_expression(self, col): - return cast(col, String(50)) + return cast(type_coerce(col, Integer), String(50)) return StringAsInt() def test_special_type(self, metadata, connection, string_as_int): - type_ = string_as_int t = Table("t", metadata, Column("x", type_)) |
