Visitar URL original
fix: throw SQLException for #getBoolean BIT(>1) by marschall · Pull Request #2386 · pgjdbc/pgjdbc · GitHub
Skip to content

fix: throw SQLException for #getBoolean BIT(>1) - #2386

Merged
davecramer merged 1 commit into
pgjdbc:masterfrom
marschall:CallableStatement-getBoolean-SQLException
Jan 3, 2022
Merged

davecramer merged 1 commit into
pgjdbc:masterfrom
marschall:CallableStatement-getBoolean-SQLException

Conversation

@marschall

Copy link
Copy Markdown
Contributor

Throw SQLException instead of ClassCastException when calling
CallableStatement#getBoolean(int) on BIT(>1).

Currently when users call CallableStatement#getBoolean(int) on an out parameter of type BIT(>1) they get ClassCastException because the driver casts the result to a Boolean without checking the type first. This works for BIT(1) bit fails for BIT(>1) because then the type currently is PGobject. I know there are many related issues and PRs resolving around how we should treat bistring types

This PR doesn't preclude any approach on these issues, it just changes the exception type for the current behavior.

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?
    There are many related ones but I didn't find any for this specific issue.

Changes to Existing Features:

  • Does this break existing behaviour? If so please explain.
    Users get SQLException instead of ClassCastException. Users already need to catch SQLException so hopefully the impact isn't too big. Additionally the combination of CallableStatement and BIT(>1) may be quite low, otherwise we may have gotten bug reports.
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully run tests with your changes locally?

Throw SQLException instead of ClassCastException when calling
CallableStatement#getBoolean(int) on BIT(>1).

@bokken bokken left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@marschall

Copy link
Copy Markdown
Contributor Author

This effectively matches the behavior of PgResultSet getBoolean.

Indeed it does.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants