#13487 closed (worksforme)
django.db.backends.util.typecast_date fails with a ValueError with sqlite3
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.2-alpha |
Severity: | Keywords: | sqlite3 | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
When trying to convert a NULL field, typecast_date fails because SQLite returns a string consisting of "NULL".
The extra error text is "invalid literal for int() with base 10: 'NULL'".
Change History (2)
comment:1 by , 15 years ago
Resolution: | → worksforme |
---|---|
Status: | new → closed |
comment:2 by , 15 years ago
Thanks for taking a look into this for me. It would appear that a curious combination of the setup I was using was at fault.
I populated a table with rows from a CSV file, and, because SQLite is dynamically typed, it didn't balk at assigning "NULL" as a string to a datetime field.
Note:
See TracTickets
for help on using tickets.
I can't recreate this. Given this model:
I can create a record with an empty
expire_date
and have no trouble reading that back from the DB:I had put a breakpoint in at
typecast_date
; it did not even get hit whenNone
was specified asexpire_date
. It does get hit on reading from the DB if I specifyexpire_date
as a string (or datetime.date object):I'm not sure how you have gotten the string "NULL" in for a date, since when I try that I get an error:
I get the same error trying this on the 1.1.X branch, so this is not new behavior.
How are you creating dates with the string value "NULL"?