This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-09-19
Channels
- # announcements (5)
- # asami (7)
- # aws (10)
- # babashka (10)
- # beginners (49)
- # calva (12)
- # cider (5)
- # circleci (1)
- # clj-kondo (25)
- # clj-yaml (14)
- # clojars (5)
- # clojure (134)
- # clojure-europe (142)
- # clojure-france (3)
- # clojure-nl (1)
- # clojure-norway (4)
- # clojurescript (10)
- # cursive (8)
- # datomic (19)
- # emacs (11)
- # fulcro (8)
- # graalvm (29)
- # honeysql (7)
- # jobs (4)
- # jobs-discuss (9)
- # lsp (196)
- # obb (4)
- # off-topic (40)
- # pathom (4)
- # releases (4)
- # remote-jobs (3)
- # shadow-cljs (16)
- # sql (25)
- # squint (2)
- # tools-deps (12)
- # xtdb (7)
- # yada (4)
Hello guys!
Is it possible to use lower case table names when constructing create-table
query?
For example I have a table in my Postgres - "user"
quoted, so in all my queries I should use a lover case name
And I’m trying to do something like this
(sql/format {:create-table :table
:with-columns [[:user :uuid [:references :user]]]}
{:quoted true})
which gives me ["CREATE TABLE \"table\" (\"user\" \"UUID\" REFERENCES \"USER\")"]
string with upper case "USER"
as a table name. But Postgres doesn’t recognize it as an existing table user
.
and I see that HoneySQL is calling upper-case
function for all columns here.There's no real good solution right now but it's something I'm looking at because the logic around DDL creation and casing is... a bit of a hack. If you're on a recent version of HoneySQL, you could try [:references :'user]
which should treat user
as something literal but will probably not quote the name.
As I suspected, using the "literal name" escape hatch also (deliberately) avoids quoting:
user=> (sql/format {:create-table :table
:with-columns [[:user :uuid [:references :'user]]]}
{:quoted true})
["CREATE TABLE \"table\" (\"user\" \"UUID\" REFERENCES user)"]
user=>
Thanks, but I think Postgres wouldn’t accept that as user
is a reserved keyword and have to be quoted