Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The readOnly queries don't work with Snowflake/SQLite JDBC drivers #1169

Open
seratch opened this issue Feb 20, 2021 · 3 comments
Open

The readOnly queries don't work with Snowflake/SQLite JDBC drivers #1169

seratch opened this issue Feb 20, 2021 · 3 comments

Comments

@seratch
Copy link
Member

seratch commented Feb 20, 2021

The same problem appears in SQLite (xerial/sqlite-jdbc#247), where setReadOnly also triggers an exception. This actually seems like correct behaviour on their part, since transparently ignoring concurrency directives seems like a recipe for trouble. Given how extensively readOnly appears throughout the scalikejdbc internals, would it be possible to add a flag on the ConnectionPool (or similar) that allows users to manually request that readOnly be transparently replaced with a read/write transaction mode?

Originally posted by @okennedy in #1071 (comment)

@seratch
Copy link
Member Author

seratch commented Feb 20, 2021

I am not planning to take action for this in the short term but if someone has thoughts or inputs on this issue, please share the knowledge with the community!

@seratch seratch added the core label Feb 20, 2021
@okennedy
Copy link

Thanks for having a look @seratch I'm not sure this will help, but in case anyone comes across this issue in the future, here's a workaround:

The main gimmick is here where it silently drops calls to SQLiteConnection.setReadOnly

The driver needs to be registered with JDBC, and then you set up Scalikejdbc by just prefixing the normal SQLite URL with no-read-only::

DriverManager.registerDriver(SQLiteNoReadOnlyDriver)
ConnectionPool.singleton(
  url = "no-read-only:jdbc:sqlite:" + new File(config.basePath(), db).toString,
  ...
)

See here for an example.

@seratch seratch changed the title readOnly query execution does not work with SQLite JDBC driver readOnly query execution does not work with Snowflake/SQLite JDBC driver Jun 12, 2021
@seratch seratch changed the title readOnly query execution does not work with Snowflake/SQLite JDBC driver The readOnly queries don't work with Snowflake/SQLite JDBC drivers Jun 12, 2021
@seratch
Copy link
Member Author

seratch commented Jun 12, 2021

If having a new option like GlobalSettings.setReadOnlyDisabled, which is similar to jtaDataSourceCompatible but it does not do anything for autoCommit, may be helpful for the following JDBC driver users:

  • Snowflake
  • SQLite3

Anything else?

@seratch seratch added this to the version 4.1.x milestone Jun 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants