This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # announcements (2)
- # aws (1)
- # beginners (63)
- # cider (2)
- # clj-kondo (1)
- # cljdoc (15)
- # clojure (119)
- # clojure-nl (1)
- # clojure-spec (15)
- # clojure-uk (10)
- # clojurescript (5)
- # clojutre (1)
- # community-development (6)
- # cursive (18)
- # data-science (1)
- # datascript (16)
- # datomic (2)
- # emacs (2)
- # events (3)
- # figwheel-main (2)
- # graphql (3)
- # jobs (2)
- # off-topic (23)
- # reitit (3)
- # shadow-cljs (27)
- # spacemacs (5)
- # sql (27)
- # unrepl (1)
toucan? I am looking for help on alias name. Ex:
SELECT column_name AS alias_name FROM table_name;
@gdrte Not sure I see the point of using
toucan. It doesn't look very idiomatic to me.
@gdrte the great thing about toucan is that you can use honeysql
(-> (select :a [:b :bar] :c [:d :x]) (from [:foo :quux]) (where [:= :quux.a 1] [:< :bar 100]) sql/format) => ["SELECT a, b AS bar, c, d AS x FROM foo quux WHERE (quux.a = ? AND bar < ?)" 1 100]
@andrethehunter It worked for me like this
(db/select [m/Facility :id [:facility_name :facilityName] [:standing_orders :standingOrders]])
Well, that doesn't use
toucan at all -- that's the great thing about HoneySQL and
The fact that someone has to ask about something as basic as a column alias says there's a problem with
toucan if it doesn't support that.
Yes that's the good thing about toucan (vs korma for example), it's still data driven
It uses a lot of global dynamic variables as well, which is terrible practice. It makes using multiple databases nigh on impossible.
@seancorfield @andrethehunter Thanks for the reply. First I looked at hugsql, but my team felt it is too much laborious which contradicted my reasoning to go with Clojure (our app is in Kotlin). I find toucan is enough to avoid too much of repetition and also I am convinced in case of more complex SQL there is HoneySql.
Yeah, I'm not a fan of HugSQL because I don't like the SQL separate from the code that uses it.
It's worth noting that, although the primary workflow of HugSQL is to allow separate SQL files, the library contains all of the necessary functions to use SQL inline in your code or at the repl. Specifically,
db-fn accomplish this and give you the same HugSQL parameter replacement abilities. https://www.hugsql.org/#using-other-fns
Using data is a lot more reusable and composable. A logical data translation layer really helps (like honeysql vs SQL, hiccup vs HTML). SQL strings have various limitations and can cause security issues (if parameters aren't used)
(sql/get-by-id connectable :table-name the-key) seems a pretty concise way to get a hash map of a single row by primary key (one of Toucan's misleading examples makes it looks like this needs to be a lot of work).
My point is that Toucan makes a lot of strawman comparisons to try to show it is "better" than an unrealistic alternative that nobody would actually use anyway.
Toucan adds a lot of useful things. For example, how would you do hydration easily using SQL? It also has nice post and pre process functionality.
datafy/`nav` provides that feature out-of-the-box in both
next.jdbc. That wasn't available when we implemented or DB layer. I'll check it out 🙂
But you'd be better off doing a
join in SQL in the first place instead. That sort of "convenience" is one of the bad/misleading things that ORMs try to make "easy" for you.
Yes but joins don't create nested structures. Is there a way to do that easily?
I don't like ORMS either. Toucan doesn't add a
.save method on the data. You pass on the model definition and just data.
@gdrte is better to use the specific channel for questions. See #toucan, #honeysql, and #sql channels
When we create a sub-vector it holds on original vector, but what happens to original if we conj onto sub-vector and throw it away?
if you have a moment maybe you can watch the video from here ? https://youtu.be/wASCH_gPnDw?t=1753 , it explains some things very well
I'm banging my head against a jetty server that after a
(.stop svr) and
(.join svr) is still using the port. The server is configured for websockets, so I'm not sure if that's related at all. Hoping this sounds vaguely familiar to someone who can help me out 🙂
That's a good question, I'm not certain. I think it resolves it itself given a little time (human typing time) this only happens on
i use the same pattern myself in some integration tests and i don't remember it misbehaving
I'm pretty sure this is related to websockets somehow, because it only happens if the server-side component of that is activated. Well, more specifically, if figwheel is trying to start a repl.
netstat's output also lists the process id's , there's always a chance you have forgotten another process around that lives on the same port 😉
Na, I've got a "mostly reproducible" (because it's racey)
echo '(future (cljs-repl)) (go)' | clj -A:dev which succeeds for one of them, and fails for the other with "Address in use"
I stuck a
clojure.java.shell/sh in after the
.join and I can't see the port in there at all 😞
i think join itself is just there to wait for the thread to stop after the server has been shut down ... join itself shouldn't do anything with the port by itself
The join may well not be necessary, it was a guess I added. I suspected that the server wasn't completely shutdown yet.
tested here locally, right after i do (.stop server) the port is not being listened on anymore
so it does sound like there is indeed something racey going on in your machine , but i wouldn't blame it on jetty right away 😉
if it solves in little time then perhaps make the server restart thingy more persistent in it's actions 🙂
we used to that on servers too before all the operating systems started to support the reuse flags on sockets
then you'd see an apache server going down and having to wait a minute before a you could do a rebind (on a badly configured linux server)
This is in development, and is pretty much just the internal figwheel stuff being stopped/started quickly via the api.
http://hea-www.harvard.edu/~fine/Tech/addrinuse.html I only get this if I try and start a cljs repl (server side). I don't think that's a websocket client, but maybe it is (or maybe it just alters the timing just so)
and you are sure there is no accidental duplicate process trying to rebind at the same time either ? 🙂
That would also show up in the
ss I'm running just before starting (or, at least it should once)
no funny macro business going on either evaluated at a different time than you think ? 🙂
I have code that is passed a channel, reads an item from the channel and throw it away.
I'm looking for libraries which enable suspendable evaluations in clojure. Nothing in mind too much, just looking at implementing something which parallels excel.
I'd love to implement that paper, I don't think it's as general as it suggests, it's evaluation behaviour is pretty dependent on various haskell things like applicative
> Actually for aero Ahh ok, so you’re trying to manage a graph of effects inside an immutable edn tree?
I'm trying to model the completely dynamic dependency graph without setting my hair on fire. The first two implementations have set my hair on fire 🔥
I'm trying to add macro support at the same time, where macro means that #profile stops running all paths.
there’s another library that people were talking about on clojureverse a few months ago
or rather, even if it technically represents what is happening it isnt super useful beyond actually computing the values
excel has a "restarting scheduler" where it pauses evaluation on request of a cell, and re-orders the evaluation, then starts again. A little bit like what pedestal does with interceptors I guess.
I don't know whether it has the ability to "pause evaluation" in the way you're describing, but I immediately thought of Matrix when I thought of "excel-like" dataflow in Clojure https://github.com/kennytilton/matrix
Is there anything you can learn from the way Kotlin does it, their coroutine support, via libraries, is very well developed.
Of course, when Project Loom makes its way into the JVM, I'm sure the approach may change then too!
There are quite a few videos from the designer of the coroutine support of kotlin on youtube.
you basically need to make sure that the computations are a DAG and that you do them in topological order
excel is slightly heavy-handed with it's approach to dependencies, but it does generally satisfy minimality.
I do recall too that they (kotlin guys) changed the way coroutines worked, before making it public (i.e, non-experimental). Here's the post from Roman about it: https://medium.com/@elizarov/structured-concurrency-722d765aa952.
Have a look at https://github.com/leonoel/cloroutine it's a low-level macro that can be used to implement the patterns mentioned in the articles you linked. I'm not aware of any clojure implementation of trio-like structured concurrency but that lib would definitely be a good start if you're willing to explore this path.
Hello! I use deps.edn with cognitect/test-runner / Kaocha and cannot figure out how to get some namespaces AOT-compiled (needed due to
gen-class in test files). Any [googling/solution] tips? Thank you!
hey, I just asked the same questions few days ago over at the #tools-deps room: https://clojurians.slack.com/archives/C6QH853H8/p1557397085170000
is there a way to generate a hash-map with test.check.generators where one of the values is calculated from two of the other values?