This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-04-01
Channels
- # announcements (19)
- # asami (4)
- # babashka (34)
- # beginners (137)
- # calva (22)
- # cider (4)
- # clj-kondo (25)
- # cljs-dev (4)
- # clojure (67)
- # clojure-australia (1)
- # clojure-berlin (1)
- # clojure-europe (35)
- # clojure-germany (3)
- # clojure-nl (5)
- # clojure-serbia (3)
- # clojure-uk (8)
- # clojuredesign-podcast (2)
- # clojurescript (11)
- # conjure (56)
- # data-oriented-programming (1)
- # datascript (1)
- # datomic (6)
- # deps-new (11)
- # eastwood (1)
- # fulcro (11)
- # honeysql (48)
- # inf-clojure (1)
- # jobs (1)
- # joker (6)
- # lsp (26)
- # malli (2)
- # meander (3)
- # off-topic (48)
- # pathom (4)
- # polylith (4)
- # re-frame (19)
- # releases (2)
- # remote-jobs (1)
- # rewrite-clj (127)
- # shadow-cljs (6)
- # spacemacs (3)
- # tools-deps (43)
- # xtdb (16)
Hi there. I’m having a problem with Postgresql not being very happy with HoneySQL@v2 converting :foo/bar
to "foo"."bar"
when set
-ing a new value. For example:
(-> (helpers/update :user)
(helpers/set {:foo/bar 1})
(helpers/where [:= :user/id id])
(helpers/returning :*)
(sql/format {:dialect :ansi}))
will not work because PSQL requires that columns do not contain the table name. Is there a way to disable this behaviour? I can just convert those keywords to simple keywords but that’s a bit ugly. Thanks in advance.Open an issue on github and I'll fix it tomorrow. It's a bug.
Hi there. Where should I be looking into if I want to configure automatic conversion between kebab-case
and snake_case
for both table names and column names? Thanks in advance.
I’m using Hikari for pooling, and every time I use honeysql it always yell at me for not having the proper relation
so here’s what I have atm:
;; conn
(connection/->pool HikariDataSource (select-keys env [:jdbcUrl]))
(s/defn read-user-tab :- [TabDB]
[{:user/keys [id]} :- {:user/id s/Uuid}]
(log/info "Reading tabs for user id" id)
(nj/with-transaction [tx db]
(nj/execute! tx (-> (helpers/select :*)
(helpers/from :tab)
(helpers/where [:= :tab/user-id id])
(sql/format {:dialect :ansi})))))
@dharrigan No luck. It’s still giving me ERROR: column "user-id" of relation "tab" does not exist
it's probably because as you're using ansi, it won't make any assumptions about the identifiers
I mean I can rename the table, but it’s hard trying to find anything more suitable than user
@rextruong To clarify some stuff about the camel snake kebab stuff: that only affects next.jdbc
and it only affects 1) names in ResultSet
’s that the library converts to Clojure and 2) names in Clojure data structures that the library converts to SQL — it does not (cannot) affect anything in the SQL string itself.
HoneySQL V2 defaults to :ansi
dialect so you don’t need to provide it as an option (it’s relatively harmless to do so). If you specify a dialect, you get quoting. You can also ask for :quoted true
to get quoted with the current/default dialect.
If you ask HoneySQL to quote names, it does so without dealing with -
/`_` — in both V1 (which is the code @dharrigan linked to) and V2 here: https://github.com/seancorfield/honeysql/blob/v2/src/honey/sql.cljc#L150-L169
user=> (-> {:select :* :from :tab :where [:= :tab/user-id 42]} (sql/format))
["SELECT * FROM tab WHERE tab.user_id = ?" 42]
user=> (-> {:select :* :from :tab :where [:= :tab/user-id 42]} (sql/format {:quoted true}))
["SELECT * FROM \"tab\" WHERE \"tab\".\"user-id\" = ?" 42]
See some of the important differences around V1/V2 handling of names here https://github.com/seancorfield/honeysql/blob/v2/doc/differences-from-1-x.md#option-changes