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

Add new KiwiJdbc utility to return null instead of blank strings #1047

Closed
sleberknight opened this issue Oct 5, 2023 · 0 comments · Fixed by #1060
Closed

Add new KiwiJdbc utility to return null instead of blank strings #1047

sleberknight opened this issue Oct 5, 2023 · 0 comments · Fixed by #1060
Assignees
Labels
new feature A new feature such as a new class, method, package, group of classes, etc.
Milestone

Comments

@sleberknight
Copy link
Member

sleberknight commented Oct 5, 2023

Add a utility to KiwiJdbc to return null if a string obtained from calling ResultSet#getString is blank (i.e. null, empty string, or whitespace-only).

Signature:

@Nullable
String stringOrNullIfBlank(ResultSet rs, String columnName)

Behavior:

If the value returned by ResultSet#getString is null, return null. If it is blank, return null. Otherwise, return the exact value without modification.

Examples:

String Value Return Value
null null
"" null
" " null
"\t\r\n" null
"alice" "alice"
"Sphinx of black quartz, judge my vow" "Sphinx of black quartz, judge my vow"
" string with leading whitespace" " string with leading whitespace"
"string with trailing whitespace " "string with trailing whitespace "
" string with leading and trailing whitespace " " string with leading and trailing whitespace "
@sleberknight sleberknight added the new feature A new feature such as a new class, method, package, group of classes, etc. label Oct 5, 2023
@sleberknight sleberknight added this to the 3.1.0 milestone Oct 5, 2023
@sleberknight sleberknight self-assigned this Oct 5, 2023
@sleberknight sleberknight changed the title Add new KiwiJdbc utilities to return null instead of blank strings Add new KiwiJdbc utility to return null instead of blank strings Oct 5, 2023
sleberknight added a commit that referenced this issue Oct 8, 2023
Add stringOrNullIfBlank method to KiwiJdbc. If the value returned
from the database is null or blank (whitespace only), this method
returns null. If the value from the database is not blank, the
string is returned as-is.

Closes #1047
sleberknight added a commit that referenced this issue Oct 8, 2023
Add stringOrNullIfBlank method to KiwiJdbc. If the value returned
from the database is null or blank (whitespace only), this method
returns null. If the value from the database is not blank, the
string is returned as-is.

Closes #1047
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature A new feature such as a new class, method, package, group of classes, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant