Throw exception when null value in WhereCondition #1031
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It's possible to get an
IllegalArgumentException
all the way down at the database level if a query was built using null values in any of theWhereConditions
. The stack trace looks like this:It is difficult to debug the source of the poorly constructed queries, that didn't check for null before creating the
WhereCondition
s, especially when the query was built using anAsyncSession
. In that case the stack trace looks like this:In this case, the
IllegalArgumentException
does not even log the actual message, at least indicating the index where the null value was found. But even knowing the index, it's much more difficult to figure out which was the specificWhereCondition
that bound the value to that index.It's much more helpful if the
WhereCondition
itself throws an exception at the time of creation in order to detect the invalid value sooner. ThePropertyCondition.checkValueForType()
method previously would throw aDaoException
in the case of aDate
orboolean
property type being null. But every other type did not have any explicit checking. This change will throw aDaoException
if any null value is found.