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
https://github.com/seancorfield/next-jdbc/blob/develop/src/next/jdbc/connection.clj#L459
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.Reading https://github.com/seancorfield/next-jdbc/blob/develop/doc/all-the-options.md#datasources-and-connections, it seems :read-only should work?
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.