Fork me on GitHub
#honeysql
<
2021-02-12
>
dharrigan16:02:55

Converted my application to honeysql v2

dharrigan16:02:01

slowly working through it to find any breakage

dharrigan16:02:29

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

dharrigan16:02:04

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

dharrigan16:02:18

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

dharrigan16:02:39

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

seancorfield16:02:32

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.

dharrigan16:02:03

consistency is key! 🙂

seancorfield17:02:34

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.

seancorfield17:02:28

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

dharrigan17:02:09

I think it's looking good, question.

dharrigan17:02:38

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

dharrigan17:02:27

Figured it out

dharrigan17:02:41

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

dharrigan17:02:47

(on-conflict (do-nothing))

dharrigan17:02:07

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

dharrigan17:02:02

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

dharrigan17:02:39

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

dharrigan17:02:49

will check over the data in due course

seancorfield18:02:06

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

seancorfield19:02:19

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

dharrigan19:02:53

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

dharrigan19:02:41

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

3
seancorfield19:02:48

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

dharrigan20:02:50

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

dharrigan20:02:10

encouraging! 🙂

dharrigan20:02:15

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 🙂

seancorfield20:02:05

Sounds like some serious testing -- thank you!

dharrigan20:02:30

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

dharrigan20:02:39

oh and U too 🙂

seancorfield20:02:47

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

seancorfield21:02:06

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

dharrigan21:02:14

my inserts do various joins over several tables

dharrigan21:02:31

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

dharrigan21:02:26

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

dharrigan21:02:36

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