any case, and cx_Oracle 6.x has removed the connection-level "twophase"
flag upon which this feature relied.
+ .. change:: 3973
+ :tags: bug, mssql
+ :tickets: 3973
+ :versions: 1.2.0b1
+
+ Added a placeholder type :class:`.mssql.XML` to the SQL Server
+ dialect, so that a reflected table which includes this type can
+ be re-rendered as a CREATE TABLE. The type has no special round-trip
+ behavior nor does it currently support additional qualifying
+ arguments.
+
.. changelog::
:version: 1.1.10
:released: Friday, May 19, 2017
__visit_name__ = 'IMAGE'
+class XML(sqltypes.Text):
+ """MSSQL XML type.
+
+ This is a placeholder type for reflection purposes that does not include
+ any Python-side datatype support. It also does not currently support
+ additional arguments, such as "CONTENT", "DOCUMENT",
+ "xml_schema_collection".
+
+ .. versionadded:: 1.1.11
+
+ """
+ __visit_name__ = 'XML'
+
+
class BIT(sqltypes.TypeEngine):
__visit_name__ = 'BIT'
'bit': BIT,
'real': REAL,
'image': IMAGE,
+ 'xml': XML,
'timestamp': TIMESTAMP,
'money': MONEY,
'smallmoney': SMALLMONEY,
def visit_IMAGE(self, type_, **kw):
return "IMAGE"
+ def visit_XML(self, type_, **kw):
+ return "XML"
+
def visit_VARBINARY(self, type_, **kw):
return self._extend(
"VARBINARY",
from sqlalchemy import util
from sqlalchemy.dialects.mssql.information_schema import CoerceUnicode, tables
from sqlalchemy.dialects.mssql import base
+from sqlalchemy.testing import mock
-
-class ReflectionTest(fixtures.TestBase, ComparesTables):
+class ReflectionTest(fixtures.TestBase, ComparesTables, AssertsCompiledSQL):
__only_on__ = 'mssql'
__backend__ = True
self.assert_tables_equal(users, reflected_users)
self.assert_tables_equal(addresses, reflected_addresses)
+ @testing.provide_metadata
+ def _test_specific_type(self, type_obj, ddl):
+ metadata = self.metadata
+
+ table = Table(
+ 'type_test', metadata,
+ Column('col1', type_obj)
+ )
+ table.create()
+
+ m2 = MetaData()
+ table2 = Table('type_test', m2, autoload_with=testing.db)
+ self.assert_compile(
+ schema.CreateTable(table2),
+ "CREATE TABLE type_test (col1 %s NULL)" % ddl
+ )
+
+ def test_xml_type(self):
+ self._test_specific_type(mssql.XML, "XML")
+
+ def test_image_type(self):
+ self._test_specific_type(mssql.IMAGE, "IMAGE")
+
+ def test_money_type(self):
+ self._test_specific_type(mssql.MONEY, "MONEY")
+
@testing.provide_metadata
def test_identity(self):
metadata = self.metadata
testing.db.execute("""
create table foo (id integer primary key, data xml)
""")
- t1 = Table('foo', metadata, autoload=True)
+ with mock.patch.object(
+ testing.db.dialect, "ischema_names", {"int": mssql.INTEGER}):
+ t1 = Table('foo', metadata, autoload=True)
assert isinstance(t1.c.id.type, Integer)
assert isinstance(t1.c.data.type, types.NullType)