Issue #4086 new
Dan Stovall
created an issue

In MSSQL a ROWVERSION or TIMESTAMP column do not contain a date time. Instead the contain an 8-byte integer. Currently, the column is set as sqlachemy.sql.sqltypes.TIMESTAMP, which is an instance of the DateTime type. Running a query against a table with such a column returns a byte string value for those columns. The mssql dialect should probably have a specific ROWVERSION type and it should be an integer, not a DateTime. Also, it would be nice if the values of those columns returned an integer by using int.from_bytes to convert the byte string.

Comments (3)

  1. Mike Bayer repo owner

    As mentioned earlier, TIMESTAMP is just a datatype, it doesnt "return" a DateTime type if the database driver doesn't. The test you're looking for here is specifically:

    assert not isinstance(mssql.TIMESTAMP, sqltypes.DateTime)

    as for integer conversion, at best this would be a flag on mssql.TIMESTAMP type "convert_int=True" as this type advertises itself at as a binary number.

    additionally, it's deprecated in favor of ROWVERSION:

    nevertheless, mssql.TIMESTAMP should be a subclass of ROWVERSION. TIMESTAMP also seems to allow a goofy "no column name" syntax and I'd propose we have no support for that.

    ROWVERSION is also a binary so should subclass sqltypes._Binary.

  2. Log in to comment