Skip to content

Commit bfca4fe

Browse files
author
Hideki Itakura
committed
Fixed CBL Android 560
- getViewId() should not set 0 in case of failing to retrieve `view_id` from `views` table
1 parent cbb8bc2 commit bfca4fe

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

src/main/java/com/couchbase/lite/View.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ public boolean setMapReduce(Mapper mapBlock,
247247
*/
248248
@InterfaceAudience.Public
249249
public void deleteIndex() {
250-
if (getViewId() < 0) {
250+
if (getViewId() <= 0) {
251251
return;
252252
}
253253

@@ -295,18 +295,15 @@ public Query createQuery() {
295295
public int getViewId() {
296296
if (viewId < 0) {
297297
String sql = "SELECT view_id FROM views WHERE name=?";
298-
String[] args = { name };
298+
String[] args = {name};
299299
Cursor cursor = null;
300300
try {
301301
cursor = database.getDatabase().rawQuery(sql, args);
302302
if (cursor.moveToNext()) {
303303
viewId = cursor.getInt(0);
304-
} else {
305-
viewId = 0;
306304
}
307305
} catch (SQLException e) {
308306
Log.e(Log.TAG_VIEW, "Error getting view id", e);
309-
viewId = 0;
310307
} finally {
311308
if (cursor != null) {
312309
cursor.close();

0 commit comments

Comments
 (0)