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

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

Conversation

marschall
Copy link
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).
Copy link
Member

@bokken bokken left a comment

Choose a reason for hiding this comment

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

@marschall
Copy link
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.

None yet

3 participants