- changed milestone to 0.4.3
Change to mssql datetime implementation breaks times in dates
Reading the history, it looks like the change in r3964 breaks datetime handling. I have a field that's a MSDateTime_pyodbc, and I assign it the value of datetime.datetime.now(), but when I commit it to the database, the time portion of the datetime isn't stored.
nr.respondent_date datetime.datetime(2008, 1, 6, 23, 6, 35, 961000) nr.flush() 2008-01-06 23:07:04,585 INFO sqlalchemy.engine.base.Engine.0x..90 BEGIN INFO:sqlalchemy.engine.base.Engine.0x..90:BEGIN 2008-01-06 23:07:04,585 INFO sqlalchemy.engine.base.Engine.0x..90 INSERT INTO respondent (participant_category_id, respondent_date) VALUES (?, ?); select scope_identity() INFO:sqlalchemy.engine.base.Engine.0x..90:INSERT INTO respondent (participant_category_id, respondent_date) VALUES (?, ?); select scope_identity() 2008-01-06 23:07:04,585 INFO sqlalchemy.engine.base.Engine.0x..90 datetime.datetime(2008, 1, 6, 0, 0) INFO:sqlalchemy.engine.base.Engine.0x..90:datetime.datetime(2008, 1, 6, 0, 0) 2008-01-06 23:07:04,618 INFO sqlalchemy.engine.base.Engine.0x..90 COMMIT INFO:sqlalchemy.engine.base.Engine.0x..90:COMMIT
Looking into mssql.py, I see that in MSDateTime_pyodbc.bind_processor.process, there is a test:
isinstance( value, datetime.date )
But you'll note that this is true if value is a datetime.date or value is a datetime.datetime.
I suspect this is because datetime.date is a superclass of datetime.datetime.
I was able to fix this unwanted behavior by changing the isinstance call to: "type(value) is datetime.date".
Please fix this for the next release.
Thanks, Jason
Comments (3)
-
repo owner -
Account Deleted - changed status to resolved
(original author: ram) fixed in 46720f0bbcf78a609cbcc1b7af55a8f4fb4ec319, thanks for the detailed analysis
-
repo owner - removed milestone
Removing milestone: 0.4.3 (automated comment)
- Log in to comment