Fork me on GitHub
#sql
<
2019-07-14
>
shubham11:07:11

Facing some trouble tying to use next.jdbc with Hikari datasource

(require '[next.jdbc :as nj])

(nj/execute! datasource ["
create table address (
  id int auto_increment primary key,
  name varchar(32),
  email varchar(255)
)"])
^This blurts out the error listed below.
Execution error (PSQLException) at org.postgresql.core.v3.QueryExecutorImpl/receiveErrorResponse (QueryExecutorImpl.java:2440).
ERROR: syntax error at or near "auto_increment"
  Position: 34
Is there something wrong with the way I’m using the datasource? NOTE: This is fixed Needed to extend ReadableColumn and SettableParameter protocols.

shubham12:07:27

So,

(nj/execute! datasource ["
create table address (
  name varchar(32),
  email varchar(255)
)"])
=> [#:next.jdbc{:update-count 0}]
(nj-sql/insert! datasource :address {:name "Shubham"
                                     :email ""})
=> #:address{:name "Shubham", :email ""}
(nj-sql/query datasource ["SELECT * FROM address where name = ?" "Shubham"])
=> [#:address{:name "Shubham", :email ""}]
^this works just fine. So, that removes the question of not using datasource correctly.

shubham12:07:25

Likewise, if I have a uuid column in my table, it results into a similar error Do I need to extend any protocol?

dmaiocchi21:07:30

what is the timeout default for next-jdbc