sqlite: dates and times are returned as strings
dgmora opened this issue · 3 comments
sqlite does not have a different storage class for dates and times. Because of this, blazer can't identify the field as a timestamp and ends up using a different type of chart (a barchart instead of a line chart). This happens here, the value is returned (unexpectedly) as a String:
Lines 48 to 67 in 134a969
I'm not quite sure what would be a good solution here. Trying to parse every string is odd. The schema information isn't reliable, since you can also add new columns that aren't part of the schema. Maybe it could be a configurable option like
sqlite:
column_types:
- created_at: "time"
- my_date: "time"
Or there could be certain suffixes like _date / _timestamp / _at that are treated as time if it's sqlite and the value is a string? (configurable as well, maybe)
Hi @dgmora, thanks for reporting. I think the best way to address this would be to get the types from the raw result and cast based on that.
connection_model.connection.raw_connection.query(sql, binds) do |result|
p result.types
endInteresting! The types not available with connection_model.connection.select_all though. So that would require to use the the raw_connection and manually build a result so that it contains the types,right?