honeysql

Discussion of https://github.com/seancorfield/honeysql :slightly_smiling_face:
jimi hendrix 2021-01-26T14:47:22.015900Z

Is there any support for postgres's CTE?

orestis 2021-01-26T15:20:17.016400Z

Yes, via “with”

orestis 2021-01-26T15:20:54.016900Z

Iirc the merge helper is missing

orestis 2021-01-26T15:21:08.017400Z

AFK right now so can’t help with sample code

markaddleman 2021-01-26T17:22:51.017600Z

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

markaddleman 2021-01-26T17:22:58.017800Z

(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))))

athomasoriginal 2021-01-26T17:35:49.020800Z

@nasikebuli156 :with and :with-recurive are supported by HSQL. You can see usage https://github.com/seancorfield/honeysql/blob/5e087617159fa61a15363bf76ad3d6598dd7d30f/test/honeysql/format_test.cljc#L62

athomasoriginal 2021-01-26T17:37:30.022300Z

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 Sauvala 2021-01-26T17:41:24.023800Z

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

athomasoriginal 2021-01-26T17:44:10.024700Z

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

seancorfield 2021-01-26T18:13:32.026900Z

@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 Sauvala 2021-01-27T10:41:29.032600Z

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 🙂

seancorfield 2021-01-27T18:02:56.034400Z

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.

seancorfield 2021-01-26T18:14:32.027500Z

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

Janne Sauvala 2021-01-27T10:44:32.032800Z

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 😄

seancorfield 2021-01-26T18:16:16.029300Z

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).

🎉 4