olavloite / spanner-jdbc

JDBC Driver for Google Cloud Spanner
MIT License
38 stars 10 forks source link

Passing a null parameter value can cause INVALID_ARGUMENT errors #54

Closed olavloite closed 6 years ago

olavloite commented 6 years ago

From olavloite/spanner-hibernate#1:

When i pass a null value param to a JPQL query i get the next error:

nl.topicus.jdbc.shaded.io.grpc.StatusRuntimeException: INVALIDARGUMENT: No matching signature for operator = for argument types: STRING, BOOL. Supported signature: ANY = ANY [at 1:401] ...and contact0.providerid=@p1 and (@p2 is null or contact0.position_id=@p...

In the query i use the next WHERE clause

WHERE :positionId IS NULL OR c.position.id = :positionId

This problem is in the handling of null values of parameters in the jdbc driver and not in the Hibernate dialect.

olavloite commented 6 years ago

@flascaray Definitely a bug which will be fixed. In the meantime the following work-around will probably work. Change the query into something like this:

SELECT ... FROM ... WHERE COALESCE(CAST(:positionId AS STRING), '')='' OR c.position.id = CAST(:positionId AS STRING)

olavloite commented 6 years ago

Fixed in version 1.0.6.