mssql datetime2 doesn't adapt correctly

Issue #2159 resolved
Mike Bayer repo owner created an issue

only in 0.6, as adapt() was rewritten in 0.7.

from sqlalchemy import *
from sqlalchemy.dialects.mssql import DATETIME2
import datetime

e = create_engine('mssql+pyodbc://scott:tiger@ms_2005/', echo=True)
m = MetaData(e)
t1 = Table('t', m, Column('x', DATETIME2))

m.drop_all()
m.create_all()

t1.insert().execute(x=datetime.datetime.now())
t1.select().execute().fetchall()



  File "/Users/classic/dev/sa06/lib/sqlalchemy/engine/default.py", line 224, in type_descriptor
    return sqltypes.adapt_type(typeobj, self.colspecs)
  File "/Users/classic/dev/sa06/lib/sqlalchemy/types.py", line 796, in adapt_type
    return typeobj.adapt(impltype)
  File "/Users/classic/dev/sa06/lib/sqlalchemy/types.py", line 1361, in adapt
    return impltype(timezone=self.timezone)
AttributeError: 'DATETIME2' object has no attribute 'timezone'

Comments (2)

  1. Log in to comment