This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-08-31
Channels
- # announcements (3)
- # aws-lambda (1)
- # babashka (122)
- # beginners (241)
- # calva (28)
- # cider (7)
- # clara (7)
- # clj-kondo (43)
- # clojars (5)
- # clojure (326)
- # clojure-europe (60)
- # clojure-italy (2)
- # clojure-nl (4)
- # clojure-spec (21)
- # clojure-uk (4)
- # clojurescript (162)
- # cursive (30)
- # datomic (3)
- # editors (5)
- # emacs (4)
- # figwheel-main (1)
- # fulcro (24)
- # gratitude (3)
- # helix (7)
- # honeysql (20)
- # improve-getting-started (1)
- # introduce-yourself (11)
- # jobs (3)
- # joker (2)
- # kaocha (15)
- # lsp (21)
- # lumo (2)
- # meander (3)
- # off-topic (34)
- # re-frame (6)
- # reagent (1)
- # releases (4)
- # rum (2)
- # shadow-cljs (37)
- # spacemacs (16)
- # tools-deps (16)
- # vim (23)
- # xtdb (32)
ah great, thank @seancorfield
another question, do we have create index command https://www.postgresql.org/docs/current/sql-createindex.html, it seem different with add-index
above?
CREATE INDEX ON foo (title);
@quan Is there a reason to use CREATE INDEX ON <table> ...
rather than ALTER TABLE <table> ADD <index> ...
?
SQL/DDL is insanely variable so it's really kind of hard to support everything... 🙂
Fine (gods, I hate PostgreSQL!) go create an issue on GH and I'll look at adding it...
PG is far and away the most work of any database I ever have to support, both for HoneySQL and for next.jdbc
😞
for delete-from
helper, how can I add alias for delete table. I try with this but it's not expected
(-> (delete-from [:foo :a])
(using [:bar :b])
(where [:= :a.id :b.id])
sql/format)
=> ["DELETE FROM FOO(a) USING bar b WHERE a.id = b.id"]
@quan Is this what you're looking for in that delete-from
?
dev=> (-> (h/delete-from :foo :a)
#_=> (h/using [:bar :b])
#_=> (h/where [:= :a.id :b.id])
#_=> (sql/format))
["DELETE FROM foo a USING bar b WHERE a.id = b.id"]
ah yeah, thank @seancorfield. For me look like behavior of delete-from
is inconsistent with another function, e.g using
bellow. It seem not clear to have (h/delete-from :foo :a)
based on the doc 🙂
It wasn't a syntax I expected. I'll need to look at the docs for the various databases, and also in more detail at that specific formatter.
@quan I double-checked and delete-from
is formatted like a select
except that it expects a single form, however it doesn't add AS
which probably makes more sense so I'll update the as
filter so delete-from
is formatted that way. I still need to double-check a few databases' docs to verify that is safe.
Looks like that might be PG only, but I think alias support is harmless -- delete from foo a ...
will work on PG and won't work on other DBs, so it would be clearer to support delete from foo as a ...
I think.
(that'll be in the next release -- but you have a working solution now)
Here's the issue for create index
https://github.com/seancorfield/honeysql/issues/348 -- it's hard because that's completely vendor-specific syntax (and not compatible between PG and MS SQL -- I haven't even looked at Oracle or MySQL there. DDL is all over the map across different DBs.
For comparison, here's MySQL which is different again https://dev.mysql.com/doc/refman/5.7/en/create-index.html