Re: [Sqlalchemy-tickets] [sqlalchemy] #2363: sqlite datetime comparisons are off when microseconds
Brought to you by:
zzzeek
From: sqlalchemy <mi...@zz...> - 2011-12-31 20:37:32
|
#2363: sqlite datetime comparisons are off when microseconds != 0 ----------------------------------+------------------------------------ Reporter: wilsaj | Owner: Type: defect | Status: new Priority: medium | Milestone: Component: access | Severity: no triage selected yet Resolution: | Keywords: Progress State: awaiting triage | ----------------------------------+------------------------------------ Comment (by wilsaj): here's a unit test: (link: https://bitbucket.org/wilsaj/sqlalchemy/src/5fb332746f18/test/dialect/test_sqlite.py#cl-75) {{{ def test_datetime_comparison(self): meta = MetaData(testing.db) t = Table('datetime_table', meta, Column('id', Integer, primary_key=True), Column('dt', DateTime())) try: meta.create_all() testing.db.execute("INSERT INTO datetime_table (id, dt) " "VALUES (1, '2011-12-31 19:20:15');") testing.db.execute("INSERT INTO datetime_table (id, dt) " "VALUES (2, '2011-12-31 19:20:16');") testing.db.execute("INSERT INTO datetime_table (id, dt) " "VALUES (3, '2011-12-31 19:20:17.000125');") eq_(t.select(t.c.dt).where( t.c.dt == datetime.datetime(2011, 12, 31, 19, 20, 17, 125) ).execute().fetchall(), [(3, datetime.datetime(2011, 12, 31, 19, 20, 17, 125))]) eq_(t.select(t.c.dt).where( t.c.dt == datetime.datetime(2011, 12, 31, 19, 20, 16) ).execute().fetchall(), [(2, datetime.datetime(2011, 12, 31, 19, 20, 16))]) eq_(t.select(t.c.dt).where( t.c.dt >= datetime.datetime(2011, 12, 31, 19, 20, 16) ).order_by(t.c.dt).execute().fetchall(), [(2, datetime.datetime(2011, 12, 31, 19, 20, 16)), (3, datetime.datetime(2011, 12, 31, 19, 20, 17, 125))]) finally: meta.drop_all() }}} -- Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2363#comment:1> sqlalchemy <http://www.sqlalchemy.org/> The Database Toolkit for Python |