Movatterモバイル変換


[0]ホーム

URL:


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

fix: UseResultSet.getObject to respect nullable columns of the basic SQL data types#22

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
ichizero wants to merge3 commits intosqlc-dev:main
base:main
Choose a base branch
Loading
fromichizero:get-nullable-columns-of-basic-types

Conversation

ichizero
Copy link

@ichizeroichizero commentedFeb 17, 2024
edited
Loading

Description

UseResultSet.getObject for the generation code of sqlc-gen-kotlin to respect nullable columns of the basic SQL data types.

Fixes#20

Details

java.sql.ResultSet.get{SpecificType}, such asResultSet.getInt,ResultSet.getBoolean, returns the zero value of each types when the selected value is SQL NULL.

"Returns: the column value; if the value is SQL NULL, the value returned is false."

https://docs.oracle.com/en/java/javase/21/docs/api/java.sql/java/sql/ResultSet.html#getBoolean(int)

On the other hand,ResultSet.getObject returns null when the selected value is SQL NULL.

https://docs.oracle.com/en/java/javase/21/docs/api/java.sql/java/sql/ResultSet.html#getObject(int,java.lang.Class)

Bothpgjdbc/PgResultSet.getObject,mysql-connector-j/ResultSetImpl.getObject implementsResultSet.getObject with nullable column handling and basic SQL data types detection, so I think sqlc-gen-kotlin should be use it and rely on driver implementations.

Appendix

Toru-Takagi reacted with heart emoji
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Is it a specification for sqlc that retrieving null from a nullable boolean column in Postgres results in false?
1 participant
@ichizero

[8]ページ先頭

©2009-2025 Movatter.jp