This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-07-26
Channels
- # aws-lambda (15)
- # babashka (7)
- # beginners (124)
- # calva (7)
- # cider (19)
- # clj-kondo (26)
- # clojure (261)
- # clojure-australia (3)
- # clojure-dev (10)
- # clojure-europe (45)
- # clojure-nl (4)
- # clojure-uk (6)
- # clojurescript (10)
- # datomic (7)
- # depstar (7)
- # emacs (11)
- # fulcro (41)
- # graalvm (48)
- # helix (1)
- # honeysql (17)
- # inf-clojure (7)
- # introduce-yourself (3)
- # jackdaw (2)
- # lsp (36)
- # malli (2)
- # meander (2)
- # membrane (1)
- # missionary (11)
- # off-topic (17)
- # pathom (83)
- # polylith (15)
- # re-frame (31)
- # reagent (42)
- # sci (35)
- # shadow-cljs (13)
- # spacemacs (13)
- # sql (19)
- # timbre (3)
- # tools-deps (77)
What would be a good way to go about deleting a record by ID with honeysqł? Newb question, just tinkering around. https://gist.github.com/v3gal0g/0944bae4b784cd96ad53de71c35bb793
@decim There are a couple of examples in the README https://github.com/seancorfield/honeysql#deletes
Hard to tell from that Gist what result you are getting that is different from what you are expecting?
@seancorfield the jdbc “sql/delete” gives me what I want but thats without honeysql. The other two attempts aren’t doing anything as of yet.
@seancorfield ok I believe i’ve got it working now.
@decim What did you need to change?
@seancorfield well I thought this would work, Apparently not but that SHOULD be correct….
(-> {:delete-from :books
:where [:= :books.id 2]}
(honeysql/format))
dev=> (-> {:delete-from :books
#_=> :where [:= :books.id 2]}
#_=> (sql/format))
["DELETE FROM books WHERE books.id = ?" 2]
What is that db-query-one
function you are calling?(defn db-query-one [sql]
(db/execute-one! data-source sql
{:return-keys true
:builder-fn rs/as-unqualified-maps}))
I’m no longer using that, I removed it for the delete. I get the same as what you posted when I evaluate it… oh. That’s one thing I was wondering. My ‘store-book!’ function does store data to the database but the delete isn’t picking up on the data source is my guess.
@seancorfield ooops, you were giving me a hint there. Now it does in fact work. I was running around like a chicken with his head cut off… =(
(-> (hh/delete-from :books)
(hh/where := :books.id 2)
(honeysql/format)
db-query-one)
I'm not sure what you even changed 🙂
@seancorfield it was a round of craziness… I confused myself and executed it without db-query-one, then added it back before making a gist. I’m looking over next.jdbc documentation as well now. I actually learned the very little that i’m using from a tutorial online so I’m tinkering to figure out what all is necessary for the basics.
Cool. Feel free to ask Qs here and in #sql whenever you get stuck or need clarification on something in the docs.