This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-05-14
Channels
- # admin-announcements (1)
- # beginners (18)
- # boot (61)
- # cljsjs (4)
- # cljsrn (12)
- # clojure (60)
- # clojure-gamedev (1)
- # clojure-russia (13)
- # clojure-taiwan (1)
- # clojure-uk (4)
- # clojurescript (62)
- # core-async (7)
- # cursive (1)
- # data-science (1)
- # hoplon (74)
- # lein-figwheel (3)
- # off-topic (3)
- # om (2)
- # other-languages (58)
- # planck (4)
- # protorepl (3)
- # reagent (58)
- # rethinkdb (1)
- # spacemacs (1)
hi - i have a honeysql question (there doesn’t appear to be a room for it - if there’s a better room for this question, please let me know). I’m trying to slowly build a query, and using merge-where
, but i’m not sure i’m using it right. it recursively nests the where
clauses, where i’d rather see them all AND
ed together at the “root” of the query, so to speak - is there something I’m missing?
user=> (require '[honeysql.core :as sql])
user=> (require '[honeysql.helpers :as h])
user=> (def query {:select [:*] :from [:mytable]})
user=> (def w1 (h/merge-where query [:= :a 1]))
user=> (def w2 (h/merge-where w1 [:= :b 2]))
user=> (def w3 (h/merge-where w2 [:= :c 3]))
user=> w3
{:select [:*], :from [:mytable], :where [:and [:and [:= :a 1] [:= :b 2]] [:= :c 3]]}
user=> (sql/format w3)
["SELECT * FROM mytable WHERE ((a = 1 AND b = 2) AND c = 3)”]
I know that logically, it doesn’t make any difference, but as I build more complex thing, I’m a little nervous of some little subtle thing I miss, and a simpler query would make more sense to me - thanks in advance for any advice!
where will combine multiple clauses together using and:
(-> (select :*)
(from :foo)
(where [:= :a 1] [:< :b 100])
sql/format)
=> ["SELECT * FROM foo WHERE (a = 1 AND b < 100)”]
hey thanks - yeah, i got that far, i’m trying to pass the query map around among a bunch of functions, adding on clauses as i go (“is there a :b
param? add that to the query - is there a :c
param? add that to the query” - etc
so i thought in each function, i could add another clauses to the :where
in the map, and they would all be AND
ed together at the end
so maybe i should just build up a list of clauses as i go, and add it to the query map at the end?
hi everyone! what kind of path i need to set up for hiccup image? relative or absolute or else? [:img {:style "width:1366px;height:180px;", :alt "myImg", :src "/resources/public/img/image.png"}]
I'm trying to find documentation on this bit of code ['in [1 2 3 4]]
.. The 'in
. I'm not sure what this is called nor what it does. Any links/suggestions?
So normally if you write a symbol, such as in
, it's evaluated which means that you don't get in
back, you get the value bound to in
.
It does. Reading through the documentation and playing with it in the repl now. Thanks! 😃
please show someone how to define hiccup image element
@agi_underground: I would start with an absolute path to be sure it works and experiment from there, other than that relative or absolute is your preference (exactly the same as if you were writing html). Also hiccup tests are always a nice reference when in doubt (or your REPL also) https://github.com/weavejester/hiccup/blob/53057de9799b27d5d0ddfe865fdac6e7a141d896/test/hiccup/core_test.clj#L69 .