mardi 20 octobre 2015

Android: SqlBrite observable from create query which contains WHERE clause is not invoked

I am struggling with below issue for last few hours and I don't see a reason of that or maybe what I am missing.

I have such piece of code which doesn't work, by doesn't work I mean that I don't get any errors in logs and the subscriber is not invoked, the mapToOne is not invoked as well.

 briteDatabase.
            createQuery(DatabaseTables.MY_TABLE, "SELECT * FROM " + DatabaseTables.MY_TABLE +" WHERE " + DatabaseColumns.MY_CODE +"=?", new String[]{code})
            .mapToOne(new Func1<Cursor, MyObject>() {
                @Override
                public MyObject call(Cursor cursor) {
                    return mapCursorToMyObject(cursor);
                }
            })
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new....

I tried to run above code without WHERE clause and everything works fine.

briteDatabase.
            createQuery(DatabaseTables.MY_TABLE, "SELECT * FROM " + DatabaseTables.MY_TABLE)
            .mapToOne(new Func1<Cursor, MyObject>() {
                @Override
                public MyObject call(Cursor cursor) {
                    return mapCursorToMyObject(cursor);
                }
            })
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new....

Can someone point me out what I am missing ?

Aucun commentaire:

Enregistrer un commentaire