pushtorefresh / storio

Reactive API for SQLiteDatabase and ContentResolver.
Apache License 2.0
2.55k stars 182 forks source link

Throw exception if contentResolver.query() returns null #441

Closed artem-zinnatullin closed 9 years ago

artem-zinnatullin commented 9 years ago

At the moment we return empty MatrixCursor if original call to contentResolver.query() returns null, but in fact if ContentProvider returns null, it means that this query can not be processed because of some error/exception.

So we should throw it as exception.

@nikitin-da and others thoughts?

See: http://stackoverflow.com/questions/13080540/what-causes-androids-contentresolver-query-to-return-null

nikitin-da commented 9 years ago

This decision was made using only sources, without docs. Can it be platform specific? If it's always error state, it's nice idea to follow non-null approach - throw runtime exception.

artem-zinnatullin commented 9 years ago

Documentation for ContentProvider says that query() can return Cursor or null. In my opinion, if there is no data for this query (eg table is empty) ContentProvider should return empty cursor, but if such query does not have mapping (eg no such table for uri and so on) it should return null, which is exceptional case for us and users of StorIO, I guess.

artem-zinnatullin commented 9 years ago

Closed by #451.