Fork me on GitHub
#sql
<
2020-06-30
>
danisam1713:06:53

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

seancorfield16:06:01

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

danisam1718:06:29

Oh I see, thanks a lot @seancorfield

binny18:06:56

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" .FileNotFoundException: Could not locate clojure/datafy__init.class or clojure/datafy.clj on classpath., compiling:(next/jdbc/result_set.clj:1:1)

binny18:06:39

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

binny18:06:57

Any idea what I'm doing wrong? Thanks 😃

seancorfield18:06:29

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

seancorfield18:06:40

next.jdbc requires at least Clojure 1.10.

seancorfield18:06:09

@binny Does that help?

binny18:06:01

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

binny18:06:45

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

seancorfield18:06:21

Clojure 1.9 tightened up a lot of the syntax checks.

binny18:06:36

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!

chrisblom19:06:12

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 ...} , ...] ?

seancorfield21:06:45

This section of the docs might give you some ideas https://cljdoc.org/d/seancorfield/next.jdbc/1.1.547/doc/getting-started/tips-tricks#working-with-json-and-jsonb -- I don't know what select (foo,bar) is intended to do?

chrisblom19:06:23

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

chrisblom19:06:44

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

danielglauser20:06:42

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.

vachichng11:07:18

I used migratus, but now Liquibase.

lukaszkorecki20:06:22

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

danisam1721:06:53

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

seancorfield21:06:23

@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 🙂 )

danisam1705:07:29

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

seancorfield05:07:43

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

seancorfield21:06:53

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

lukaszkorecki21:06:29

What are the differences/advantages over Ragtime?

seancorfield21:06:58

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

lukaszkorecki21:06:09

I see - we use timestamps with ragtime

lukaszkorecki21:06:28

(hard learned lesson from early days of Rails)

seancorfield21:06:20

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

seancorfield21:06:33

(but, yeah, timestamps are better)