diff options
Diffstat (limited to 'test/sql')
| -rw-r--r-- | test/sql/test_type_expressions.py | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/test/sql/test_type_expressions.py b/test/sql/test_type_expressions.py index cab4f6371..70c8839e3 100644 --- a/test/sql/test_type_expressions.py +++ b/test/sql/test_type_expressions.py @@ -9,6 +9,7 @@ from sqlalchemy import testing from sqlalchemy import TypeDecorator from sqlalchemy import union from sqlalchemy.sql import LABEL_STYLE_TABLENAME_PLUS_COL +from sqlalchemy.sql.type_api import UserDefinedType from sqlalchemy.testing import AssertsCompiledSQL from sqlalchemy.testing import eq_ from sqlalchemy.testing import fixtures @@ -431,6 +432,8 @@ class RoundTripTestBase: class StringRoundTripTest(fixtures.TablesTest, RoundTripTestBase): + __requires__ = ("string_type_isnt_subtype",) + @classmethod def define_tables(cls, metadata): class MyString(String): @@ -448,6 +451,29 @@ class StringRoundTripTest(fixtures.TablesTest, RoundTripTestBase): ) +class UserDefinedTypeRoundTripTest(fixtures.TablesTest, RoundTripTestBase): + @classmethod + def define_tables(cls, metadata): + class MyString(UserDefinedType): + cache_ok = True + + def get_col_spec(self, **kw): + return "VARCHAR(50)" + + def bind_expression(self, bindvalue): + return func.lower(bindvalue) + + def column_expression(self, col): + return func.upper(col) + + Table( + "test_table", + metadata, + Column("x", String(50)), + Column("y", MyString()), + ) + + class TypeDecRoundTripTest(fixtures.TablesTest, RoundTripTestBase): @classmethod def define_tables(cls, metadata): @@ -474,7 +500,11 @@ class ReturningTest(fixtures.TablesTest): @classmethod def define_tables(cls, metadata): - class MyString(String): + class MyString(TypeDecorator): + impl = String + + cache_ok = True + def column_expression(self, col): return func.lower(col) |
