Fork me on GitHub
#sql
<
2019-03-30
>
gklijs08:03:18

I'm trying to move from using [alaisi/postgres.async "0.8.0"] to [org.clojure/java.jdbc "0.7.9"] [org.postgresql/postgresql "42.2.5.jre7"]

gklijs08:03:20

But I'm stuck doing a query.

(def pg-db {:dbtype     "postgresql"
            :dbname     "balancedb"
            :host       "localhost"
            :user       "clojure_ch"
            :password   "lacinia"
            :port       5432
            :ssl        false})

gklijs08:03:08

(defn find-cac-by-uuid
  [uuid]
  (log/debug "try to find cac" uuid)
  (j/with-db-connection [db-con pg-db]
                        (j/query db-con ["SELECT * FROM cac WHERE uuid = ?" uuid])))

gklijs08:03:22

where the uuid is a string, the query

SELECT * FROM cac WHERE uuid = 'cf869196-1edb-4e00-9d43-81c54e88118c';
in pgadmin executes fine

gklijs15:03:50

Apparently it's not the correct way to use an uuid. Whith the entire query in there it does work.

gklijs15:03:11

(defn find-cac-by-uuid
  [uuid]
  (log/debug "try to find cac" uuid)
  (j/with-db-connection [db-con pg-db]
                        (first(j/query db-con ["SELECT * FROM cac WHERE uuid = ?" (UUID/fromString uuid)]))))
is working 🙂