sql

All things SQL and JDBC...
nachos 2020-06-30T13:46:53.054Z

Does jdbc/with-options work with jdbc/with-transaction ?

seancorfield 2020-06-30T16:29:01.055200Z

@danisam17 Per the Getting Started docs: > Note: Because get-datasource and get-connection return plain JDBC objects (`javax.sql.DataSource` and java.sql.Connection respectively), next.jdbc/with-options cannot flow options across those calls, so if you are explicitly managing connections or transactions as above, you would need to have local bindings for the wrapped versions: (and then it has specific examples on how to handle that)

nachos 2020-06-30T18:05:29.056100Z

Oh I see, thanks a lot @seancorfield

Binny Zupnick 2020-06-30T18:14:56.058300Z

hey! I feel like I'm about to ask a very newb question but I'm new to Clojure in general 🙈 I have the following dependencies in my project.clj: [seancorfield/next.jdbc "1.1.547"]     `[org.postgresql/postgresql "42.2.10"]`     `[honeysql "1.0.444"]` and then have the following in my require in core.clj: [next.jdbc :as jdbc]     `[honeysql.core :as sql]` And I'm getting the following compilation error: Exception in thread "main" <http://java.io|java.io>.FileNotFoundException: Could not locate clojure/datafy__init.class or clojure/datafy.clj on classpath., compiling:(next/jdbc/result_set.clj:1:1)

Binny Zupnick 2020-06-30T18:15:39.059Z

when I take out the require of [next.jdbc :as jdbc] it DOES successfully compile

Binny Zupnick 2020-06-30T18:15:57.059400Z

Any idea what I'm doing wrong? Thanks 😃

seancorfield 2020-06-30T18:16:29.059800Z

Sounds like you're on an old version of Clojure.

seancorfield 2020-06-30T18:16:40.060100Z

next.jdbc requires at least Clojure 1.10.

seancorfield 2020-06-30T18:17:54.060600Z

https://cljdoc.org/d/seancorfield/next.jdbc/1.1.547/doc/getting-started -- "It is designed to work with Clojure 1.10 or later"

seancorfield 2020-06-30T18:18:09.061Z

@binny Does that help?

Binny Zupnick 2020-06-30T18:18:36.061400Z

oh damn! That's it! I see I'm running on 1.8. It's now downloading the new jar....I will update when it runs!

1
Binny Zupnick 2020-06-30T18:24:01.061700Z

uuhhmm. Now it's throwing me another error but it's not connected since the error still occurs when I require jdbc: Exception in thread "main" Syntax error macroexpanding clojure.core/refer-clojure at (clojure/core/async.clj:9:1). Call to clojure.core/refer-clojure did not conform to spec. It seems like upgrading gave me another issue 😜 To the Googles! Thanks for your super quick response, @seancorfield

Binny Zupnick 2020-06-30T18:34:45.061900Z

figured this one out too. I'm using Morse (Telegram bot interface) and that dep was outdated. Thanks again!

seancorfield 2020-06-30T18:36:21.062100Z

Clojure 1.9 tightened up a lot of the syntax checks.

2020-06-30T19:56:12.065200Z

With next.jdbc, how do i get a query like (jdbc/execute! ds ["select (foo,bar) from tableX join tableY on ....."]) to return a maps with of the form [{:foo ...,:bar ...} , ...] ?

2020-06-30T19:57:23.066200Z

I now get a vector with {:row PGObject} elements

2020-06-30T19:57:44.066700Z

Is there some option i have to pass to execute! ?

danielglauser 2020-06-30T20:29:42.067800Z

What do folks recommend for managing DB changes? Seeing Migratus, Ragtime, and Joplin. I've used Migratus before but it's been a while and wanted to see what others thought.

Vachi 2020-07-01T11:13:18.082700Z

I used migratus, but now Liquibase.

lukasz 2020-06-30T20:53:22.068400Z

Ragtime works fine for me and my team, we use it with postgres

1
nachos 2020-06-30T21:21:53.069Z

In next.jdbc how would I convert org.postgresql.jdbc.PgArray in the result set to clojure array?

seancorfield 2020-06-30T21:49:23.069900Z

@danisam17 https://cljdoc.org/d/seancorfield/next.jdbc/1.1.547/doc/getting-started/tips-tricks#working-with-arrays (the docs have all sorts of useful stuff in them -- they're worth reading 🙂 )

1
seancorfield 2020-06-30T21:50:53.070900Z

@danielglauser We wrote our own, using sequential numbers like Ragtime and if we were starting again, I think we'd use Migratus instead.

1
lukasz 2020-06-30T21:51:29.071400Z

What are the differences/advantages over Ragtime?

seancorfield 2020-06-30T21:51:58.072Z

Using sequential numbers is problematic -- read the Migratus docs for an explanation.

lukasz 2020-06-30T21:52:09.072300Z

I see - we use timestamps with ragtime

lukasz 2020-06-30T21:52:28.072800Z

(hard learned lesson from early days of Rails)

seancorfield 2020-06-30T21:53:20.073600Z

Even so, it's an ordered sequence (problematic) rather than recording all the applied ones vs not-yet-applied, right?

seancorfield 2020-06-30T21:53:33.074Z

(but, yeah, timestamps are better)