I'm using an .edn file as a database seed and need a way to set a timestamp in that file and have it written to the db without a java error. (It turns out you can't just enter a timestamp as a string and have it convert automatically as some of us may be used to in more dynamic languages than java).
I've got as far as the following .edn file which seeds correctly if I remove the #inst and just put nil instead.
[{:table :subscriptions
:data [{:user_id 1
:price 9900
:transacted_at nil
:begin_at nil
:end_at #inst "2020-01-01T22:00:01-07:00"}]}]
But with the #inst included as above gives this error:
org.postgresql.util.PSQLException:
Can't infer the SQL type to use for an instance of java.util.Date.
Use setObject() with an explicit Types value
The question here is how to fix that specific error and get a timestamp into the database.
The EDN file is fine. Your problem comes from the JDBC driver when you attempt to insert the data. You don't say which Clojure JDBC library you are using, but if you are using
next.jdbc, you should require thenext.jdbc.date-timenamespace and that will automatically enable conversion fromjava.util.Dateto a valid PostgreSQL data type.