Fork me on GitHub
#sql
<
2020-02-26
>
serioga10:02:24

Hello @seancorfield Did you consider next.jdbc API for with-transaction where sym shadows name of transactable ?

; Current API
(with-open [conn (jdbc/get-connection my-datasource)]
  (jdbc/with-transaction [tx conn]
    (jdbc/execute! tx ...))) ; what is allowed to do with `conn` here?

; Alternative - the lexical scope of `conn` is changed
(with-open [conn (jdbc/get-connection my-datasource)]
  (jdbc/with-transaction [conn]
    (jdbc/execute! conn ...))) ; outer `conn` not accessible here

seancorfield17:02:39

You can already do

(jdbc/with-transaction [conn conn] ,,,)
if you want to hide conn inside the lexical scope so I see no reason to add a special case syntax for this. Note that in the general case the transactable can be a DataSource or even a db-spec.

orestis12:02:40

@dharrigan Let me know how that works. I had a look at how the nilenso extensions work and saw a bunch of numbers that presumably deal with precedence and clause ordering. I kind of shied away of HoneySQL at that point.

orestis12:02:43

We had a nice argument in the team the other day, should the "sugar" help you in the easy case or the hard case? We'll investigate Walkable next since it seems to lift the concern from SQL to another level, whereas HoneySQL still asks you to write SQL, just in another format...