Cannot evaluate com.couchbase.lite.Select.toString()

java
sdk
mobile

#1

Hi,
i’m trying to create a dynamic query using couchbase lite 2.0.2.
What i’m doing is to add select, from and where dynamically, so i have a method that is like that:

Select select = mSelect.addToQuery();
From from = mFrom.addToQuery(select)
Where where = mWhere.addToQuery(from);
Order orderBy = mOrderBy.addToQuery(where);
Query query = mLimit.addToQuery(orderBy);

and in mSelect.addToQuery() i’ve got:

public Select addToQuery() {
        return QueryBuilder.select(SelectResult.all());
}

but every time i run the query debug shows me:

Method threw 'java.lang.NullPointerException' exception. Cannot evaluate com.couchbase.lite.Select.toString()

The rest of the query elements works without exceptions.
Do you know why is there this error?

If i run a simple full query instead it works, so it should be something related the thing that i’m “creating” the query.

Thanks in advance


#2

I’m not that familiar with Java, but that seems like an error thrown by the actual debugger instead of normal use. Is that right?


#3

Which line throws the exception? What’s the backtrace?


#4

Hi,
the exception is not shows on the console, but only during debugging, so i guess @borrrden could be right.
If i debug the complete query i end up with this:

The query select the fields correctly, even though there is the error.
This is the select:


I’m worried for side effects mostly, and that’s why i asked.
Have you ever seen this kind of error?


#5

It’s probably just a bug in the toString method which is what the debugger uses to display things. Unless you call it otherwise it won’t be used but if you file it on github then I think it can be fixed. It’s at worst an inconvenience now though so don’t worry.