This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-08-23
Channels
- # announcements (6)
- # beginners (54)
- # calva (9)
- # cider (2)
- # clj-kondo (26)
- # cljsrn (2)
- # clojure (49)
- # clojure-brasil (1)
- # clojure-dev (3)
- # clojure-europe (11)
- # clojure-italy (28)
- # clojure-nl (5)
- # clojure-serbia (1)
- # clojure-spec (4)
- # clojure-uk (182)
- # clojuredesign-podcast (2)
- # clojurescript (59)
- # clojurex (9)
- # cursive (26)
- # data-science (11)
- # datomic (40)
- # duct (1)
- # emacs (3)
- # events (4)
- # figwheel-main (2)
- # fulcro (7)
- # instaparse (1)
- # kaocha (2)
- # leiningen (25)
- # off-topic (3)
- # re-frame (36)
- # reagent (15)
- # shadow-cljs (87)
- # spacemacs (12)
- # sql (20)
- # tools-deps (8)
- # vim (1)
- # yada (40)
Hey everyone -I'm trying to simply retrieve a bool out of my database like so:
(defn- check-privilages
"Checks if the userID is an admin"
[id]
(let [[query] (sql/query @db-spec
[ "SELECT IsAdmin From Users
WHERE UserID=?
LIMIT 1"
id])]
(println
(true? (:users/isadmin query)))
(assoc id :is-admin
(true? (:users/isadmin query)))))
However, both the println
and the assoc
statements cause this error, which I haven't run into before after extensive use of my database:
org.postgresql.util.PSQLException: No hstore extension installed.
at org.postgresql.jdbc.PgPreparedStatement.setMap(PgPreparedStatement.java:465)
at org.postgresql.jdbc.PgPreparedStatement.setObject(PgPreparedStatement.java:948)
at next.jdbc.prepare$eval5154$fn__5155.invokePrim(prepare.clj:36)
at next.jdbc.prepare$eval5154$fn__5155.invoke(prepare.clj)
any ideas?
I'm calling it like so :
id (check-privilages (:identity request))]
You're treating id
as a hash map (the assoc
). Is it numeric or a hash map? If it is a hash map, then you'll need to extract just the ID value in the sql/query
call where id
is a parameter @ashley
The call to .setMap
in the stacktrace suggests id
is a hash map...
oh my gosh you're right, I forgot to destructure it. Been doing some heavy refactoring! Let me try again
Also, BTW, if could replace (let [[query] (sql/query ,,,)] ,,,)
with (let [query (jdbc/execute-one! ,,,)] ,,,)
(and I'd probably use result
or row
instead of query
.
It is, its the identity
of request to my server. I used to pass in the ID, but now I'm passing in the entire identity
map, so that this function can elevate privileges for the current API call
always helps to have fresh eyes when you've been working with the same code for hours
yeah, I've been using the sql-friendly functions like insert!
rather than execute-one!
. Is query
not a good convention then?
@seancorfield are you still on vacation? What ar eyou doing on here? 😛
Got back from the UK Tuesday. Working, working, working now 🙂
did you enjoy your time here? 🙂
It was great. Got to see mum for a day at each end and the cat show in Stoke-on-Trent was a lot of fun!
Driving around the M25 in the torrential rain during rush hour, not so much 🙂
it happens 😛 i'm glad you had fun though!
@U26FJ5FDM The cat show is "all breed" so it's up to 70 different breeds, as well as "household pet" which is mixed breed.
There were probably 30 different breeds at this show (and about 100 cats total).