honeysql

Discussion of https://github.com/seancorfield/honeysql :slightly_smiling_face:
dharrigan 2021-02-12T07:29:39.089700Z

🙂

dharrigan 2021-02-12T16:51:55.089900Z

Converted my application to honeysql v2

dharrigan 2021-02-12T16:52:01.090200Z

slowly working through it to find any breakage

dharrigan 2021-02-12T16:53:29.091400Z

I notice now that function calls are uppercased, i.e., in honey v1, [:ST_SetSRID....] now becomes ST_SETSRID(... when formatted in honey v2

dharrigan 2021-02-12T16:54:04.091900Z

(just an observation, natch it's fine as sql is case insensitive unless quoted)

dharrigan 2021-02-12T16:55:18.092700Z

Modified about 15 files that used honeysql calls, so let's see what happens 🙂

dharrigan 2021-02-12T16:57:39.095100Z

I am liking the natural use of [:foo being a function call

seancorfield 2021-02-12T16:58:32.096Z

Re: uppercase -- yeah, v1 was a bit inconsistent about that, depending on how it treated the context so you'd get lowercase for some things that were clearly built-in and "should" be uppercase, you'd get mixed case in some situations, and then you'd get uppercase for other things 😐 So I just took the position that your own "vars" (tables and column names) should be left as is (modulo the - -> _ thing) and pretty much everything else should be uppercase.

dharrigan 2021-02-12T16:59:03.096700Z

consistency is key! 🙂

seancorfield 2021-02-12T17:00:34.098500Z

Having to wrap things in (sql/call ..) in v1 was probably the most common thing I got support questions and GitHub issues about: because [:foo 1 2 3] worked in "most" situations but there were lots of edge cases where it didn't quite work and you needed to "help" HoneySQL figure it out. And that's why I went with all the other "special syntax" as plain "function" calls too: raw, inline, param, etc.

seancorfield 2021-02-12T17:01:28.099Z

(I'm going to make coffee and feed cats but will be back to answer any Qs in 10 mins)

seancorfield 2021-02-12T17:20:58.099200Z

(back)

dharrigan 2021-02-12T17:46:09.099500Z

I think it's looking good, question.

dharrigan 2021-02-12T17:46:38.100200Z

how does the on-conflict, do-nothing work (previously I was using a defhelper to default a clause)

dharrigan 2021-02-12T17:47:27.100400Z

Figured it out

dharrigan 2021-02-12T17:47:41.100800Z

Man, working with the repl, rich comment blocks is fantastic, such quick feedabck

dharrigan 2021-02-12T17:47:47.101Z

(on-conflict (do-nothing))

dharrigan 2021-02-12T17:48:07.101300Z

(insert-sql {:id 1}) ;; ["INSERT INTO investigation (id) VALUES (?) ON CONFLICT DO NOTHING" 1]

dharrigan 2021-02-12T17:49:02.102300Z

(as an aside, conjure on vim recently gained the ability to put the evaluation into a comment beside the form - that's what you're seeing there - makes capturing the result of a RCF fantastic and easy to look back upon)

dharrigan 2021-02-12T17:56:39.102700Z

Well, so far so good, the happy path of my application works with honey v2

dharrigan 2021-02-12T17:56:49.103100Z

will check over the data in due course

seancorfield 2021-02-12T18:29:06.104700Z

Nice. Yeah, I haven't documented the helpers yet -- even tho' I prefer those over working with raw data -- but, as you're finding out, they're a lot more comprehensive than in v1 (there is literally a helper now for every single clause -- and a couple of helpers for special syntax forms as well).

seancorfield 2021-02-12T19:14:19.106200Z

Once I've finished implementing all the parts of nilenso/honeysql-postgres I'll add a specific section to the docs that talks about the differences between HoneySQL v2 and that lib -- there are a few things that just made sense to do a bit differently @dharrigan

dharrigan 2021-02-12T19:34:53.107100Z

np, looking forward to it. So far, the upgrade has been relatively straightforward. The main thing for me was replacing "sql/call" and "sql/raw" statements

dharrigan 2021-02-12T19:35:41.107900Z

will do some testing over the weekend, apart from some temporal differences, the data produced v1 vs v2 should be the same

1
seancorfield 2021-02-12T19:52:48.108700Z

Much appreciated! I will continue working on the docs over the weekend, after completing the PG DDL stuff.

dharrigan 2021-02-12T20:47:50.109100Z

so far, data produced is identical, apart from a datetime stamp (of creation)

dharrigan 2021-02-12T20:48:10.109400Z

encouraging! 🙂

dharrigan 2021-02-12T20:50:15.110600Z

the two results are about +135,000 lines long, comprised of various sql reports, so only 2 lines differ, and that's the date of when the request to generate the reports was done 🙂

seancorfield 2021-02-12T20:58:05.111700Z

Sounds like some serious testing -- thank you!

dharrigan 2021-02-12T20:58:30.112100Z

more testing adhoc over the weekend on the CD of CRUD actions 🙂

dharrigan 2021-02-12T20:58:39.112300Z

oh and U too 🙂

seancorfield 2021-02-12T20:59:47.113300Z

It should now support stuff like delete from multiple tables, delete using, insert into as, and various other stuff that v1 omitted (or had only partially added).

seancorfield 2021-02-12T21:00:06.114Z

It also has all the OVER / PARTITION BY / WINDOW stuff built in now.

dharrigan 2021-02-12T21:00:14.114200Z

my inserts do various joins over several tables

dharrigan 2021-02-12T21:00:31.114700Z

and my reports do use OVER window functions too, so that appears to be tickity-boo for me atm

dharrigan 2021-02-12T21:01:26.115200Z

I've replaced all the honeysql-postgres extensions from nilenso too

dharrigan 2021-02-12T21:02:36.115700Z

right, ttfn! off to re-re-re-read LOTR!