This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-06-10
Channels
- # announcements (1)
- # babashka (178)
- # beginners (216)
- # bootstrapped-cljs (1)
- # brompton (5)
- # calva (3)
- # chlorine-clover (1)
- # clj-kondo (2)
- # cljdoc (37)
- # cljfx (4)
- # cljs-dev (2)
- # clojure (360)
- # clojure-chile (8)
- # clojure-europe (3)
- # clojure-italy (5)
- # clojure-nl (9)
- # clojure-spec (2)
- # clojure-sweden (1)
- # clojure-uk (61)
- # clojuredesign-podcast (1)
- # clojurescript (83)
- # clr (2)
- # conjure (4)
- # core-async (14)
- # cursive (20)
- # data-science (2)
- # datomic (15)
- # docker (11)
- # emotion-cljs (1)
- # figwheel-main (28)
- # find-my-lib (1)
- # fulcro (46)
- # helix (16)
- # honeysql (14)
- # jobs (10)
- # jobs-discuss (17)
- # joker (1)
- # juxt (9)
- # kaocha (8)
- # leiningen (3)
- # meander (3)
- # news-and-articles (1)
- # off-topic (110)
- # pathom (7)
- # pedestal (4)
- # protojure (2)
- # re-frame (12)
- # reagent (25)
- # ring (4)
- # shadow-cljs (109)
- # spacemacs (9)
- # specter (1)
- # sql (3)
- # tools-deps (23)
Ah well. If you're set on using honeysql for ddl, you could probably adapt the definitions from postgres.
@aviflax Outside of the tests in clojure.java.jdbc
, I've never used the DDL helpers -- they just don't add enough.
I don't use them, either. I tend to put ddl in raw sql migration files.
@codonnell Yeah, that's the route we've gone at work, so it's easier to roll a database up for testing to a specific "version".
That makes sense. Thanks!
FWIW, I was just hoping to find some kind of “standardized” way to represent a create table
statement as a data structure rather than as a string, because I am working on a function that will eventually return something that has generated create table
statement in its metadata, and I want to be able to write equality checks in my tests without worrying about string formatting.
I whipped this up on the fly, thinking this might work:
[:create-table
"technologies"
"name varchar(255) not null primary key"
"links-main text"]
But my SQL is so rusty I don’t have much confidence in something so simple being actually viable. 😅I would probably use a hash map: {:create-table :technologies :columns ["name varchar(255) not null primary key", "links_main text"]}
then you can (clojure.string/join ", " ...)
on the columns and then it's just (str "CREATE TABLE" (:create-table data) "(" column-string ")")
Hello. I'm trying to create a new row, and return the generated primary key (or complete row).
(-> (insert-into :person)
(values [{:name "foo"}])
(sql/format)
(->> (jdbc/execute! *database*)))
This inserts the row as expected, but returns (1)
instead of the new row. Is there any way I can get the primary key? I also saw that there was a jdbc/insert!
, but this takes a map instead of an SQL string. Meaning I can't use honeysql with this. Any tips?Ah ok, I also need to use jdbc/query
instead of jdbc/execute!
if I want it to return data
Use :return-keys true
(As an option passed to execute!