diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/dialect/mssql/test_types.py | 48 | ||||
| -rw-r--r-- | test/requirements.py | 14 |
2 files changed, 60 insertions, 2 deletions
diff --git a/test/dialect/mssql/test_types.py b/test/dialect/mssql/test_types.py index 356057af1..54dd6876a 100644 --- a/test/dialect/mssql/test_types.py +++ b/test/dialect/mssql/test_types.py @@ -7,6 +7,7 @@ import os import sqlalchemy as sa from sqlalchemy import Boolean from sqlalchemy import Column +from sqlalchemy import column from sqlalchemy import Date from sqlalchemy import DateTime from sqlalchemy import DefaultClause @@ -14,6 +15,7 @@ from sqlalchemy import Float from sqlalchemy import inspect from sqlalchemy import Integer from sqlalchemy import LargeBinary +from sqlalchemy import literal from sqlalchemy import MetaData from sqlalchemy import Numeric from sqlalchemy import PickleType @@ -27,7 +29,9 @@ from sqlalchemy import Text from sqlalchemy import text from sqlalchemy import Time from sqlalchemy import types +from sqlalchemy import Unicode from sqlalchemy import UnicodeText +from sqlalchemy import util from sqlalchemy.databases import mssql from sqlalchemy.dialects.mssql import ROWVERSION from sqlalchemy.dialects.mssql import TIMESTAMP @@ -37,6 +41,7 @@ from sqlalchemy.dialects.mssql.base import MS_2008_VERSION from sqlalchemy.dialects.mssql.base import TIME from sqlalchemy.sql import sqltypes from sqlalchemy.testing import assert_raises_message +from sqlalchemy.testing import AssertsCompiledSQL from sqlalchemy.testing import AssertsExecutionResults from sqlalchemy.testing import ComparesTables from sqlalchemy.testing import emits_warning_on @@ -922,6 +927,49 @@ class TypeRoundTripTest( engine.execute(tbl.delete()) +class StringTest(fixtures.TestBase, AssertsCompiledSQL): + __dialect__ = mssql.dialect() + + def test_unicode_literal_binds(self): + self.assert_compile( + column("x", Unicode()) == "foo", "x = N'foo'", literal_binds=True + ) + + def test_unicode_text_literal_binds(self): + self.assert_compile( + column("x", UnicodeText()) == "foo", + "x = N'foo'", + literal_binds=True, + ) + + def test_string_text_literal_binds(self): + self.assert_compile( + column("x", String()) == "foo", "x = 'foo'", literal_binds=True + ) + + def test_string_text_literal_binds_explicit_unicode_right(self): + self.assert_compile( + column("x", String()) == util.u("foo"), + "x = 'foo'", + literal_binds=True, + ) + + def test_string_text_explicit_literal_binds(self): + # the literal experssion here coerces the right side to + # Unicode on Python 3 for plain string, test with unicode + # string just to confirm literal is doing this + self.assert_compile( + column("x", String()) == literal(util.u("foo")), + "x = N'foo'", + literal_binds=True, + ) + + def test_text_text_literal_binds(self): + self.assert_compile( + column("x", Text()) == "foo", "x = 'foo'", literal_binds=True + ) + + class BinaryTest(fixtures.TestBase): __only_on__ = "mssql" __requires__ = ("non_broken_binary",) diff --git a/test/requirements.py b/test/requirements.py index c70169acf..c265bb3c9 100644 --- a/test/requirements.py +++ b/test/requirements.py @@ -663,6 +663,16 @@ class DefaultRequirements(SuiteRequirements): return exclusions.open() @property + def expressions_against_unbounded_text(self): + """target database supports use of an unbounded textual field in a + WHERE clause.""" + + return fails_if( + ["oracle"], + "ORA-00932: inconsistent datatypes: expected - got CLOB", + ) + + @property def unicode_data(self): """target drive must support unicode data stored in columns.""" return skip_if([no_support("sybase", "no unicode driver support")]) @@ -1173,9 +1183,9 @@ class DefaultRequirements(SuiteRequirements): lookup = { # will raise without quoting "postgresql": "POSIX", - # note MySQL databases need to be created w/ utf8mb3 charset + # note MySQL databases need to be created w/ utf8mb4 charset # for the test suite - "mysql": "utf8mb3_bin", + "mysql": "utf8mb4_bin", "sqlite": "NOCASE", # will raise *with* quoting "mssql": "Latin1_General_CI_AS", |
