sql 2025-02-10

next.jdbc: I'm trying to get a read-only connection to a MySQL db, and it's a bit confusing. Seems the :read-only keyword is not having any effect.

@grav I didn't see it, but did you create a GH issue about this?

Nope, looked through the code, and it seems like next.jdbc is adhering to :read-only, so I'm still thinking it's an error on my side

Unless make-connection is never getting called, I can't see why it shouldn't work. I'll try again and see if I can repo. Maybe check out the source and step-debug

Thanks @grav -- I look forward to hearing what you figure out!

Here's a snippet:

(let [c (jdbc/get-connection (assoc db-conn {:read-only true}))]
    #_(jdbc/execute! c ["SET SESSION TRANSACTION READ ONLY;"])
    (jdbc/execute! c
                   ["drop database if exists mydb"])
    (jdbc/execute! c
                   ["create database mydb"]))
This unexpectedly works. If I comment in the SET SESSION TRANACTION READ ONLY part, it starts failing, as expected.

Oh, and adding in (.setReadOnly c true) also works

I'm flying so feel free to create a GH issue and I'll look when I land.