elixir-sqlite/sqlitex

do not parse 2015-09-28 16:53:52 as date time

Tica2 opened this issue · 2 comments

For
sqlite> select * from users;
id|username|email|password|status|inserted_at|updated_at
1|admin|root@localhost|******|2|2015-09-28 16:53:52.000000|2015-09-28 16:53:52.000000
datetime is parsed fine.

For
sqlite> select * from users;
id|username|email|password|status|inserted_at|updated_at
1|admin|root@localhost|******|2|2015-09-28 16:53:52|2015-09-28 16:53:52

I have error:
** (MatchError) no match of right hand side value: "16:53:52"
(sqlitex) lib/sqlitex/row.ex:60: Sqlitex.Row.to_time/1
(sqlitex) lib/sqlitex/row.ex:32: Sqlitex.Row.translate_value/1
(elixir) lib/enum.ex:1043: anonymous fn/3 in Enum.map/2
(elixir) lib/enum.ex:1385: Enum."-reduce/3-lists^foldl/2-0-"/3

Good to parse
2015-09-28 16:53:52 without milisecond

@Tica2 is the type of the column changed? Or just the way the data was inserted?

We can definitely get a patch out for this quickly, I just want to make sure I understand the scope of the issue.

same datetime and values generate by common functions.
Do not read back from db.

sqlite> select datetime('now');
2015-09-28 19:43:12
sqlite> select strftime('%Y-%m-%d %H:%M:%f', 'now');
2015-09-28 19:43:24.310
sqlite>