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 the WhereConditions. The stack trace looks like this:
Fatal Exception: java.lang.IllegalArgumentException
the bind value at index 1 is null
net.sqlcipher.database.SQLiteProgram.bindString (SQLiteProgram.java:237)
net.sqlcipher.database.SQLiteQuery.bindString (SQLiteQuery.java:185)
net.sqlcipher.database.SQLiteDirectCursorDriver.query (SQLiteDirectCursorDriver.java:48)
net.sqlcipher.database.SQLiteDatabase.rawQueryWithFactory (SQLiteDatabase.java:1772)
net.sqlcipher.database.SQLiteDatabase.rawQuery (SQLiteDatabase.java:1737)
de.greenrobot.dao.database.EncryptedDatabase.rawQuery (EncryptedDatabase.java:31)
de.greenrobot.dao.query.Query.list (Query.java:76)
...
It is difficult to debug the source of the poorly constructed queries, that didn't check for null before creating the WhereConditions, especially when the query was built using an AsyncSession. 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 specific WhereCondition 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. The PropertyCondition.checkValueForType() method previously would throw a DaoException in the case of a Date or boolean property type being null. But every other type did not have any explicit checking. This change will throw a DaoException if any null value is found.
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.