I am sure I am doing something daft but… I am using sqlite in development and finding that Hugsql appears to be returning timestamp column values as strings rather than date objects of some kind. A quick google hasn't rustled anything up.
Anyone know what I might obviously have missed here?
@sandbags have you tried using jdbc/query directly to see if strings are also returned? It’s usually the JDBC driver that does the marshalling/unmarshalling
@rymndhng good idea
So, yes, it seems like they are coming back as strings from jdbc/query
this seems a might odd to me
@sandbags if you want a way around it you can probably do something as follows:
(extend-protocol jdbc/IResultSetReadColumn
;; all SQL timestamp cols returned as Java longs
Timestamp
(result-set-read-column [ts _ _]
(.getTime ^Timestamp ts))
;; all SQL date cols returned as longs
Date
(result-set-read-column [ts _ _]
(.getTime ^Date ts)))
This will convert your date/timestamp fields into long (Or whatever you want them to be)
You can read more about this here: http://clojure-doc.org/articles/ecosystem/java_jdbc/using_sql.html