This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-11
Channels
- # announcements (2)
- # babashka (27)
- # beginners (99)
- # biff (16)
- # calva (15)
- # clj-kondo (6)
- # clj-on-windows (38)
- # clojure (54)
- # clojure-austin (1)
- # clojure-europe (30)
- # clojure-france (4)
- # clojure-nl (1)
- # clojure-norway (43)
- # clojure-spec (10)
- # conjure (28)
- # core-async (4)
- # cursive (7)
- # figwheel-main (1)
- # graphql (9)
- # gratitude (3)
- # honeysql (9)
- # introduce-yourself (1)
- # jobs (1)
- # joyride (128)
- # lambdaisland (2)
- # malli (8)
- # membrane (12)
- # nbb (5)
- # off-topic (1)
- # polylith (11)
- # re-frame (9)
- # reitit (1)
- # remote-jobs (5)
- # sci (15)
- # shadow-cljs (50)
- # tools-deps (2)
- # xtdb (12)
Sorry if I'm missing it in the docs, but how do I keep something from being wrapped in parens? I'm trying to get:
REFERENCES FOO ON DELETE CASCADE
but end up with:
REFERENCES FOO ON DELETE(CASCADE)
In DDL you can probably use :delete-cascade
to produce plain SQL keywords with spaces.
But it would help if you showed what DSL day you are trying...😁
@U04V70XH6 I'm trying to do something like this:
(-> (hh/create-table :bar)
(hh/with-columns
[[:did :uuid [:default [:gen_random_uuid]]]
[:foo-id :varchar [:not nil]]
[[:primary-key :did :foo-id]]
[[:foreign-key :foo-id]
[:references :foo]
[:on-delete :cascade]]]))
The Postgres syntax I'm trying to produce is like this:
CREATE TABLE order_items (
product_no integer REFERENCES products ON DELETE RESTRICT,
order_id integer REFERENCES orders ON DELETE CASCADE,
quantity integer,
PRIMARY KEY (product_no, order_id)
);
Can you create a GH issue with that example so I can think about it? DDL is horribly non-regular so trying to figure out DSL syntax for it is tricky at times. I'm not sure right now what the best solution for this case is -- I'll have to look at how various databases handle this.
Thanks, @U04V70XH6. I'll have that issue up sometime soon. I was asking in here just in case I missed it. Grepping through the project I saw there was some mention of added support for CREATE TABLE
/ CASCADE
a while ago, but couldn't find supporting examples to match my target:
https://github.com/seancorfield/honeysql/blob/dda3aa017e62b54863d302252c574fabf687543c/CHANGELOG.md?plain=1#L139-L141
DROP .. CASCADE
is supported, as I recall, but that change entry refers to the top-level DSL clauses, not columns within CREATE TABLE
.
https://github.com/seancorfield/honeysql/issues/437 Just leaving the link to the issue here for reference.
Recently I had to deal with DDLs as well. In particular clauses like ON DELETE SET NULL ON UPDATE CASCADE
. I wasn't able to get this outputted with e.g. [:on-delete :set nil]
, but as a temporary workaround you can use individual keywords. That is, you can use :on :delete :set nil :on :update :cascade
for the time being. This is what I plan to do until HoneySQL improves support for this kind of syntax