Fork me on GitHub
#sql
<
2020-07-01
>
chrisblom05:07:17

@seancorfield it selects the foo and bar column from the joined table

chrisblom05:07:44

which are a uuid and string in this case

seancorfield05:07:04

select foo, bar from ... would give you the plain hash map then?

seancorfield05:07:33

When you have (foo, bar) I think you're telling PG to produce a compound object.

chrisblom05:07:01

thanks, that makes sense, without the parens it returns maps

emccue10:07:42

Is there a way to use named parameters with raw next.jdbc calls, or should i go to honey/hug sql for that?

seancorfield16:07:36

I'd probably be inclined to just use ? three times here and pass the ID, the name, and the name again.

seancorfield16:07:43

But I also might use HoneySQL for this which accepts named parameters and transforms them behind the scenes (you pass a hash map to the formatter and it expands to the regular ["SQL" param1 param2 param3] format.

seancorfield16:07:59

(I don't use HugSQL but I can see that being a good option too)

emccue22:07:18

I ended up writing a small function and macro for if I end up wanting this for real

emccue22:07:34

(macroexpand-1 '(expand-named-parameters-compile-time
                  "INSERT INTO PERSON (id, name) VALUES (:id, :name)
                    ON CONFLICT (id)
                      DO
                        UPDATE
                        SET name = :name
                    RETURNING id, name"
                  {:name (:person/name person)
                   :id (:person/id person)}))
=>
(clojure.core/let
 [G__4732 (:person/name person) G__4733 (:person/id person)]
 ["INSERT INTO PERSON (id, name) VALUES (?, ?)
   ON CONFLICT (id)
     DO
       UPDATE
       SET name = ?
   RETURNING id, name"
  G__4733
  G__4732
  G__4732])

3
emccue10:07:52

INSERT INTO PERSON (id, name) VALUES (:id, :name)
        ON CONFLICT (id)
          DO
            UPDATE
            SET name = :name
        RETURNING id, name

sandbags13:07:09

I'm pretty rusty with SQL these days. Working on building a Tuple Space server implementation and considering the best way to handle the data including via SQL. If anyone could critique what I have so far and/or offer suggestions of alternatives https://gist.githubusercontent.com/mmower/289b56c1dc2811b5c26def554f2c8643/raw/a4333e1da2a7a40ca2fc8508c3a6bf6b432bd020/gistfile1.txt I'd welcome either. TIA.

sandbags13:07:03

@seancorfield thanks for all your work on next.jdbc and honeysql, I always enjoy coming back to Clojure/SQL stuff largely because it feels so sane!

🎉 3
dangercoder13:07:08

Are there any examples on how to get windows authentication to work with next.jdbc and sql-server? Found some old examples here: https://stackoverflow.com/questions/6330688/connecting-to-microsoft-sql-server-using-clojure/6331367

✔️ 3
David Pham19:07:13

I managed it by using the latest mssql driver, and by setting the jdbcUrl key for db.

David Pham19:07:44

You also need to store their auth dll somewhere on your java path

David Pham19:07:01

For the driver. Hope it helps!

dangercoder04:07:33

Thanks David, I read through the docs yesterday and found a lot of places that has to be correctly configured 🙂

David Pham06:07:21

Did you manage to make it work?

dangercoder18:07:06

Not yet David. Giving it another shot tomorrow