We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ce730e9 commit 23a7291Copy full SHA for 23a7291
CHANGELOG.md
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
9
### Fixed
10
11
- #34 - Pre-1970 dates causes OverflowError
12
+- #38 - 'datetime.date' object has no attribute 'date'
13
14
## [1.10.1] - 2023-12-21
15
src/firebird/driver/core.py
@@ -176,7 +176,7 @@ def _encode_timestamp(v: Union[datetime.datetime, datetime.date]) -> bytes:
176
if isinstance(v, datetime.datetime):
177
return _util.encode_date(v.date()).to_bytes(4, 'little') + _util.encode_time(v.time()).to_bytes(4, 'little')
178
if isinstance(v, datetime.date):
179
- return _util.encode_date(v.date()).to_bytes(4, 'little') + _util.encode_time(datetime.time()).to_bytes(4, 'little')
+ return _util.encode_date(v).to_bytes(4, 'little') + _util.encode_time(datetime.time()).to_bytes(4, 'little')
180
raise ValueError("datetime.datetime or datetime.date expected")
181
182
def _is_fixed_point(dialect: int, datatype: SQLDataType, subtype: int,
tests/test_driver.py
@@ -1485,6 +1485,16 @@ def test_insert_datetime(self):
1485
self.assertListEqual(rows,
1486
[(5, datetime.date(1859, 11, 16), datetime.time(15, 0, 1, 200000),
1487
datetime.datetime(1859, 11, 16, 15, 0, 1, 200000))])
1488
+ # Pass date instead datetime for timestamp field (fix for #38)
1489
+ now = datetime.datetime(2011, 11, 13, 15, 00, 1, 200000)
1490
+ cur.execute('insert into T2 (C1,C6,C7,C8) values (?,?,?,?)', [6, now.date(), now.time(), now.date()])
1491
+ self.con.commit()
1492
+ cur.execute('select C1,C6,C7,C8 from T2 where C1 = 6')
1493
+ rows = cur.fetchall()
1494
+ self.assertListEqual(rows,
1495
+ [(6, datetime.date(2011, 11, 13), datetime.time(15, 0, 1, 200000),
1496
+ datetime.datetime(2011, 11, 13, 0, 0, 0, 0))])
1497
+
1498
def test_insert_blob(self):
1499
with self.con.cursor() as cur, self.con2.cursor() as cur2:
1500
cur.execute('insert into T2 (C1,C9) values (?,?)', [4, 'This is a BLOB!'])
0 commit comments