sql

All things SQL and JDBC...
nachos 2020-07-01T05:06:29.076300Z

@seancorfield Oh wow. I was searching for this all day. Guess I was searching for postgres specific doc. Thanks a lot 🙂

seancorfield 2020-07-01T05:07:43.076500Z

I'm just grateful to all the PostgreSQL users who keep submitting pull requests 🙂 That whole section was submitted by the community. I don't use PostgreSQL at all...

2020-07-01T05:19:17.078100Z

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

2020-07-01T05:19:44.078700Z

which are a uuid and string in this case

seancorfield 2020-07-01T05:20:04.079100Z

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

seancorfield 2020-07-01T05:20:33.079800Z

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

2020-07-01T05:22:01.081200Z

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

emccue 2020-07-01T10:40:42.082200Z

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

emccue 2020-07-04T22:11:18.125200Z

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

emccue 2020-07-04T22:11:34.125400Z

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

1
emccue 2020-07-01T10:40:52.082500Z

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

sandbags 2020-07-01T13:10:09.084200Z

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.

sandbags 2020-07-01T13:16:03.084800Z

@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!

🎉 1
dangercoder 2020-07-01T13:22:08.085300Z

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

✔️ 1
dangercoder 2020-07-02T18:15:06.104900Z

Not yet David. Giving it another shot tomorrow

seancorfield 2020-07-01T16:17:36.086700Z

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

seancorfield 2020-07-01T16:18:43.086900Z

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.

seancorfield 2020-07-01T16:18:59.087100Z

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

2020-07-01T19:21:13.088900Z

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

2020-07-01T19:22:44.090Z

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

2020-07-01T19:23:01.090500Z

For the driver. Hope it helps!