qbs
qbs copied to clipboard
Fix for issue with sqlite3 datetime parsing
Fix for error parsing time "2015-12-02 19:15:53.964608741-08:00": extra text: -08:00
when loading time.Time fields from sqlite3 TEXT fields
Can you write a test for this issue. Thank you. And have you tested that this change is compatiable with old data?
Oy. Do you have a sample of "old data" that I could use?
I mean the data created before this change, before this change, tables was created with 'TEXT" column type for time.Time
go type.
And can you explain why this change fixes this issue?
The field is still created as a TEXT field. This issue, as I traced it, seems to have more to do with your use of github.com/mattn/go-sqlite3. Making the sqlType return "datetime" seems to be able to handle one of the proper time.Time formats as defined in https://github.com/mattn/go-sqlite3/blob/master/sqlite3.go line 101 onwards.
Seeing as how a list of formats is outlined in go-sqlite3/sqlite3.go, a set of tests that verifies each format as stored in a TEXT field (as done by qbs as is when it is allowed to create tables with CreateTableIfNotExists) could be a sensical deliverable from me.
Any test cases you already have in mind or vetted by you (I assume you have seen a thing or two since you are the guy building an ORM) in the form of some sort of db dump would also work wonders.
What are your thoughts?
Whoops. Clicked the wrong thing. Tomorrow I will take the time to trace through and come up with a complete explanation of why the fix works for my needs, as well.
OK, now I know why this change fixes that issue. Please add a test cover this issue, then I will merge it. Thank you.
No problem. Will do. Thanks for all the effort on qbs.