Fork me on GitHub
#honeysql
<
2021-01-26
>
jimi hendrix14:01:22

Is there any support for postgres's CTE?

markaddleman17:01:51

fwiw, I have extended honeysql to support BigQuery CTEs (which are similar to Postgres CTEs). It was pretty easy

markaddleman17:01:58

(defmethod fmt/format-clause ::with [[_ ctes] _]
  (str "WITH " (fmt/comma-join (map (fn [[cte alias]]
                                      (try (str (fmt/to-sql alias) " AS " (fmt/to-sql cte))
                                           (catch Exception e
                                             (throw (ex-info "Unable to format"
                                                             {:alias alias :cte cte}
                                                             e)))))
                                    ctes))))

seancorfield18:01:07

FYI with will be built-in with v2.

orestis15:01:17

Yes, via “with”

orestis15:01:54

Iirc the merge helper is missing

orestis15:01:08

AFK right now so can’t help with sample code

athomasoriginal17:01:30

And then I usually take a look at https://github.com/seancorfield/honeysql/blob/5e087617159fa61a15363bf76ad3d6598dd7d30f/src/honeysql/format.cljc#L222 when I need to remind myself of some of the options. I also build the HSQL manually and without helpers…a habit I would like to break because I imagine that they are actually “helpful”

Janne Sauvala17:01:24

HoneySql 2 looks promising. What is the state of it? Is it too early to start using it?

athomasoriginal17:01:10

@janne.sauvala agreed. I’m not speaking for Sean, but TMK it’s still in an “evolving” state.

seancorfield18:01:32

@janne.sauvala v2 is very much in "hammock mode" right now. The v2 branch mostly works but there are some features from v1 not implemented yet -- still figuring out the best approach. Several features will behave differently but v2 uses different namespaces (and will have a different Maven coordinate: seancorfield/honeysql) so you can load both v1 and v2 into your project and migrate piecemeal.

Janne Sauvala10:01:29

Good to know I can use them at the same time - I might go that route if I feel that v2 seems to be more superior 🙂

seancorfield18:01:56

I'm hoping to have something "usable" next week. I'm taking four days off to work on OSS (Thu-Tue) and I plan to deal with the parameterization issue which is the current blocker as far as I'm concerned. If I can get that working this weekend and get all the tests to pass, then I'll probably ask folks to test it -- if I can also get enough documentation in place.

seancorfield18:01:32

I don't consider it even "alpha" yet and I'm not yet trying to use it at work 🙂

Janne Sauvala10:01:32

I think Clojure has spoiled me with the definition of “alpha” in our community. Usually alpha versions of any Clojure lib works fine but in any other language those alpha versions barely even compiles 😄

seancorfield18:01:16

I'm taking a few days off at the end of this week (Thursday through Tuesday) and plan to spend quite a bit of time on OSS projects -- which is possible because of GitHub sponsorship! I'll probably tackle stuff in the order: next.jdbc, depstar, clj-new, and then HoneySQL v2 (but those first three projects only need a few hours of time on them).

🎉 14
seancorfield18:01:07

FYI with will be built-in with v2.