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: untyped null parameters would cause NPE #1680

Merged
merged 1 commit into from
Feb 15, 2022

Conversation

olavloite
Copy link
Collaborator

Adding an untyped null value as a parameter to a statement was not
possible, as:

  1. The parameter collection would allow a null value to be added, but
    when the statement was built, it would throw a NullPointerException
    because it used an ImmutableMap internally, which does not support
    null values.
  2. The translation from a hand-written Statement instance to a proto
    Statement instance would fail, as it did not take into account that
    the parameter could be null.

Fixes #1679

Adding an untyped null value as a parameter to a statement was not
possible, as:
1. The parameter collection would allow a null value to be added, but
   when the statement was built, it would throw a NullPointerException
   because it used an ImmutableMap internally, which does not support
   null values.
2. The translation from a hand-written Statement instance to a proto
   Statement instance would fail, as it did not take into account that
   the parameter could be null.

Fixes #1679
@olavloite olavloite requested a review from a team as a code owner February 11, 2022 15:54
@product-auto-label product-auto-label bot added the api: spanner Issues related to the googleapis/java-spanner API. label Feb 11, 2022
olavloite added a commit to GoogleCloudPlatform/pgadapter that referenced this pull request Feb 11, 2022
- Adds more integration tests using the native PG JDBC driver.
- Adds support for null values in query parameters.

The PG JDBC driver sends DATE/TIMESTAMP parameters with type code
Oid.UNSPECIFIED. Untyped NULL values are currently not supported by the
Spangres backend, and also not by the Java client library / JDBC driver.
A patch for the Java client library has been submitted here: googleapis/java-spanner#1680
Copy link
Contributor

@thiagotnunes thiagotnunes left a comment

Choose a reason for hiding this comment

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

LGTM

@olavloite olavloite merged commit 7095f94 into main Feb 15, 2022
@olavloite olavloite deleted the allow-untyped-null-value-parameters branch February 15, 2022 09:15
olavloite added a commit to GoogleCloudPlatform/pgadapter that referenced this pull request Feb 16, 2022
* fix: support null parameters

- Adds more integration tests using the native PG JDBC driver.
- Adds support for null values in query parameters.

The PG JDBC driver sends DATE/TIMESTAMP parameters with type code
Oid.UNSPECIFIED. Untyped NULL values are currently not supported by the
Spangres backend, and also not by the Java client library / JDBC driver.
A patch for the Java client library has been submitted here: googleapis/java-spanner#1680

* fix: update expected method calls
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the googleapis/java-spanner API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Statement.Builder#bind("some-param").to((Value) null) causes NullPointerException
2 participants