Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Use JDBCType.NULL for null if possible #2069

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

Open
schauder wants to merge 5 commits into main
base: main
Choose a base branch
Loading
from issue/1935-jdbc-sql-type-for-null

Conversation

Copy link
Contributor

@schauder schauder commented Jun 4, 2025
edited
Loading

This is based on #2068.

Not all databases support the JDBCSqlType.NULL.
Therefore this handling was made dialect dependent, with SQL Server and DB2 using the old approach, while all others use JDBCSqlType.NULL

In the process modified AbstractJdbcConfiguration to use JdbcDialect instead of Dialect.

Closes #1935

schauder and others added 5 commits June 4, 2025 15:15
Signed-off-by: Sergey Korotaev <sergey.evgen.kor2501@gmail.com>
Original pull request #2068
Closes #1935 
Improved naming and formatting
Original pull request #2068
See #1935 
Not all databases support the JDBCSqlType.NULL.
Therefore this handling was made dialect dependent, with SQL Server and DB2 using the old approach, while all others use JDBCSqlType.NULL
In the process modified AbstractJdbcConfiguration to use JdbcDialect instead of Dialect.
Original pull request #2068
See #1935
See #2031 
Remove unused fields in TestConfiguration.
Original pull request #2068
See #1935 
* Implementation that always uses {@link JDBCType#NULL}. Suitable for all databases that actually support this
* {@link JDBCType}.
*/
NullTypeStrategy DEFAULT = sqlType -> JDBCType.NULL;
Copy link
Member

@mp911de mp911de Jun 5, 2025

Choose a reason for hiding this comment

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

We should have more meaningful names. Something like NULL_VALUE instead of DEFAULT

Copy link
Member

@mp911de mp911de left a comment

Choose a reason for hiding this comment

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

I'm not quite sure this is the best way to approach the problem because we're introducing configuration complexity on our side how to massage the JDBC driver.

In R2DBC, we've solved the issue of writing null values by considering these in the SQL statement using NULL instead of a parameter bind marker. That seems much easier than figuring out (and potentially asking the database to obtain) a SQL type number for a null value.

* {@link SQLType} to use for {@literal null} values.
*
* @param sqlType a fallback value that is considered suitable by the caller.
* @return Guaranteed not to be {@literal null}.
Copy link
Member

@mp911de mp911de Jun 5, 2025

Choose a reason for hiding this comment

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

🤣

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@mp911de mp911de mp911de requested changes

+1 more reviewer

@serezakorotaev serezakorotaev serezakorotaev approved these changes

Reviewers whose approvals may not affect merge requirements
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Saving a null Postgres enum results in a varchar value

AltStyle によって変換されたページ (->オリジナル) /