This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # aws (2)
- # aws-lambda (18)
- # beginners (68)
- # boot (6)
- # cider (2)
- # clara (2)
- # clojars (27)
- # clojure (68)
- # clojure-austin (5)
- # clojure-berlin (6)
- # clojure-dev (28)
- # clojure-greece (7)
- # clojure-italy (46)
- # clojure-japan (3)
- # clojure-nl (1)
- # clojure-russia (8)
- # clojure-sg (1)
- # clojure-spec (17)
- # clojure-uk (86)
- # clojurescript (82)
- # community-development (2)
- # cursive (18)
- # datomic (11)
- # duct (5)
- # fulcro (254)
- # garden (2)
- # graphql (6)
- # hoplon (19)
- # instaparse (4)
- # kekkonen (2)
- # leiningen (4)
- # luminus (3)
- # lumo (9)
- # off-topic (28)
- # om (7)
- # onyx (38)
- # other-languages (27)
- # portkey (7)
- # protorepl (1)
- # re-frame (56)
- # reagent (64)
- # ring (14)
- # ring-swagger (7)
- # shadow-cljs (255)
- # sql (2)
- # vim (11)
- # yada (10)
Is it too expensive to specify an
:identifier function that maps keywords in snake_case to kebab-case in clojure.jdbc queries?
@lvbarbosa Define "too expensive"... I would say "Do the right thing" and see how it performs. Only if it isn't fast enough should you make compromises on "the right thing".
@seancorfield not sure, maybe too much for aesthetic purposes.. I love kebab case and it hurts to see keywords using snake case xD
:identifiers function is
clojure.string/lower-case by the way -- so there's already a lot of string processing going on if you don't override it!)
Actually, that's a bit of a misleading answer. It constructs the "column names" once. For a sequence of maps, it
zipmaps the column names and the column values for each record.
Seriously tho', "do the right thing" and if you think your program is "too slow" then profile it. If you're already interacting with a SQL database, I doubt a bit of string manipulation is going to be your bottleneck!
thanks @seancorfield, and btw, nice work on clojure.java.jdbc! I am reading the “Clojure Programming” book by Emerick et. al. and there are references to the library (as you probably already know). The book is a bit outdated on that, since the library has evolved, but the official docs are helping me a lot
Even the community docs are bit outdated -- no documentation on
reducible-query yet, for example.
eg. you use wrap-defaults which includes wrap-upload, and then also add wrap-upload explicitly
When you find yourself propagating context args down a call chain (e.g runtime dependencies, cached values that are accumulated along the way etc.) , do you use a single context map? Would you pass it as the first arg to each function or as the last?
@noisesmith Do you also return a context map from these functions, perhaps accumulating data and passing it along with threading macro?
no, I don't return the context map from functions that use it - I can see how that pattern could be useful, but it also makes the context map a full fledged arbitrary state argument
Hey! I'm reading the about page for clojure.spec (https://clojure.org/about/spec) and came upon this paragraph (after showing how a spec for a Map is written)
> One of the most visible differences between spec and other systems is that there is no place in that map spec for specifying the values e.g. ⛑x can take. It is the (enforced) opinion of spec that the specification of values associated with a namespaced keyword, like :my.ns/k, should be registered under that keyword itself, and applied in any map in which that keyword appears. There are a number of advantages to this:
and I was wondering what exactly is meant by "specification of values associated with a namespaced keyword should be registered under that keyword itself"
If you give the keyword global meaning in your program, you can register that meaning once and rely upon it
one consequence is that maps specs don't have to be so redundant in describing their attribute <-> value bindings
RE: JS Interop Question I have a global JS array
What is best practice for adding something to the end of the
// index.js var players = ["James", "Karen"]
playersarray in CLJS?
not sure if it’s the best way, but you can use something like
(.push js/players "Alexandra")
hi. i'm trying to use the official java elasticsearch client, and it fails on a client creation with an error message i cannot understand this snippet (RestClient/builder (HttpHost. "localhost" 9200)) results in this error message ClassCastException org.apache.http.HttpHost cannot be cast to [Lorg.apache.http.HttpHost; wikimodels-preserver.core/eval12167 (form-init2602301893053636779.clj:83) what should [Lorg.apache... mean? why [L ?
so it’s looking for a java array of type
org.apache.http.HttpHost in this example
or if that doesn’t work,
(RestClient/builder (into-array org.apache.http.HttpHost [(HttpHost. "localhost" 9200)]))
that first one didn't work with
[Ljava.lang.Object; cannot be cast to [Lorg.apache.http.HttpHost
if you have, you can just use HttpHost - import only changes the rules for lookup, so as long as it looks up the right thing you can always use the briefer form
also, you can use classes without import- the vm auto-loads on usage, import just makes it more terse
this only works with classes though, not namespaces (which are a clojure thing and need require etc.)