sql

All things SQL and JDBC...
adam 2020-06-21T01:11:54.309700Z

Is this (sql/query ds ["SELECT COUNT(1) FROM \"user\" WHERE email = ?" "<mailto:some@email.com|some@email.com>"]) how to count in next.jdbc or there is a shortcut to it?

adam 2020-06-21T03:11:06.312Z

Also, is it possible to drop the table prefix on returned results?.. to use (:id user) instead of (:user/id user) in: (let [user (first (find-by-keys datasource :user {:email "some@email"})) id (:user/id user)

seancorfield 2020-06-21T04:37:19.313500Z

@somedude314 The most common way folks count stuff in SQL is something like SELECT COUNT(*) AS n FROM ... and then run that through (-&gt; (sql/query ...) (first) :n) (or whatever you alias the count as).

👌 1
seancorfield 2020-06-21T04:38:04.314500Z

As for the qualified column names -- try to learn to live with them. It's a deliberate design decision and namespaced keywords are idiomatic Clojure.

seancorfield 2020-06-21T04:39:10.315900Z

(you could use a :builder-fn to provide unqualified names but I strongly recommend you try to get used to them and work with them before just abandoning them: Spec relies heavily on namespaced keywords and you'll see them crop up in Datomic and other query languages)

adam 2020-06-21T08:44:53.316Z

Thanks, will definitely keep them when the result is coming from more than one table