Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

hfhbd
Copy link
Collaborator

@hfhbd hfhbd commented Mar 27, 2024

Oracle JDBC requires the correct java.sql.Types when using statement.setNull in setObject, so sqldelight should expose an overload too.
At the moment I am forced to implement my own jdbc driver.

private val preparedStatement: PreparedStatement,
) : SqlPreparedStatement {
override fun bindBytes(index: Int, bytes: ByteArray?) {
if (bytes == null) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed, the JDBC driver calls setNull for non primitive types itself.

}

// R2DBC uses boxed Java classes instead primitives: https://r2dbc.io/spec/1.0.0.RELEASE/spec/html/#datatypes
class R2dbcPreparedStatement(private val statement: Statement) : SqlPreparedStatement {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exposed to allow casting to a driver specific Statement to access driver methods.

"use bindObject with generics instead",
ReplaceWith("bindObject<T>", ""),
)
fun bindObject(index: Int, any: Any?, ignoredSqlType: Int) {
Copy link
Collaborator Author

@hfhbd hfhbd Mar 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ignoredSqlType parameter is needed because the dialect does not know if it is generating sync or async code. Ideally, we would have two dialects focussing on sync/async or we push the Gradle flag down to the dialect. I am okay with both.

}

fun bindObjectOther(index: Int, obj: Any?) {
fun bindObject(index: Int, obj: Any?, type: Int) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this makes this a binary-incompatible change, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we can also keep it but it's only used by the Postgres driver.
And according to Alec only the runtime needs to be api compatible.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that was pre-2.0.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Binary compatibility matters less for a driver like R2DBC which is still more "experimental", but the JDBC driver is widely used (and the SQLite one is an implementation of it) so we should definitely maintain compatibility for it.

We should enable the API dumper plugin!

Copy link
Collaborator

@griffio griffio Apr 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💁 I can refactor uses of bindObjectOther in the Postgres dialect to use this new api once it has been merged, then remove bindObjectOther before any new release.
bindObjectOther has only recently been added in the snapshot builds - so can be changed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can refactor uses of bindObjectOther

This is already part of this PR, but thanks.

It's only recently been added in the snapshot builds - so can be changed.

In this case I agree, we can change it.

We should enable the API dumper plugin!

Yes, will do it in another PR.

@griffio griffio mentioned this pull request Apr 2, 2024
@hfhbd hfhbd merged commit 8b4f448 into master Apr 4, 2024
@hfhbd hfhbd deleted the hfhbd/exposeJDBC branch April 4, 2024 06:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants