Couchbase Lite 2.8.5 Android/iOS - QueryBuilder results missing properties

Hello everyone,

So lately I have been seeing something quite weird in Couchbase Lite 2.8.5 that we have reproduced in both our Android and iOS application. When using the QueryBuilder, we can end up in a scenario where the query results are missing keys if:

  • The size of the select clause is large, for example, a select on 30 properties
  • If 1 or more of the properties we are doing the select on is not present on the document.

For example, let’s say I have this:

    .select(
            SelectResult.expression(Meta.id),
            SelectResult.expression(Meta.revisionID)
            SelectResult.property("a"),
            SelectResult.property("b"),
            SelectResult.property("c"),
            SelectResult.property("d"),
            SelectResult.property("f"),
            SelectResult.property("f"),
            SelectResult.property("g"),
            SelectResult.property("h"),
            SelectResult.property("i"),
            SelectResult.property("j"),
            SelectResult.property("k"),
            SelectResult.property("l"),
            SelectResult.property("m"),
            SelectResult.property("n"),
            SelectResult.property("o"),
            SelectResult.property("p"),
            SelectResult.property("q"),
            SelectResult.property("r"),
            SelectResult.property("s"),
            SelectResult.property("t"),
            SelectResult.property("u"),
            SelectResult.property("v"),
            SelectResult.property("w"),
            SelectResult.property("x"),
            SelectResult.property("y"),
            SelectResult.property("z"),
            SelectResult.property("1"),
            SelectResult.property("2"),
            SelectResult.property("3"),
            SelectResult.property("4"),
            SelectResult.property("5"),
            SelectResult.property("6"),
            SelectResult.property("7"),
            SelectResult.property("8"),
            SelectResult.property("9"),
            SelectResult.property("10"),
            SelectResult.property("11"),
            SelectResult.property("12")

If for some reason properties “a” through “h” are not actually present on the doc, it could cause other properties that are actually present on the doc to go missing from the query results. This could also happen even if it’s just “a” that is missing from the document. So in this case, if property “y” is actually on the doc, it could end up missing.

The more selects you do on properties that are not present on the document, the more properties that are present on the document disappear from the query results.

It seems like SelectResult.all() could be a workaround for this, but either way this seems like weird behavior.

I cannot reproduce the issue you describe. If you have code that will demonstrate it, I’d love to see it.

I did this:

MutableDocument doc = new MutableDocument();
        doc.setString("i", "i");
        doc.setString("j", "j");
        doc.setString("k", "k");
        // ...
        doc.setString("10", "10");
        doc.setString("11", "11");
        doc.setString("12", "12");
        db.save(doc);

        List<Result> results = QueryBuilder.select(
                SelectResult.expression(Meta.id),
                SelectResult.expression(Meta.revisionID),
                SelectResult.property("a"),
                SelectResult.property("b"),
                SelectResult.property("c"),
                // ...
                SelectResult.property("10"),
                SelectResult.property("11"),
                SelectResult.property("12"))
            .from(DataSource.database(db))
            .execute()
            .allResults();

… and got exactly the expected result:

RESULT: 
    1 => 1
    2 => 2
    3 => 3
    4 => 4
    5 => 5
    6 => 6
    i => i
    id => ecb15c7c-152c-496f-aa1d-a6e7daafc9d4
    j => j
    k => k
    l => l
    m => m
    n => n
    o => o
    p => p
    q => q
    r => r
    revisionID => 1-cf887b8201f73bd073cb0cab32935f7ce1774d74
    s => s
    t => t
    u => u
    v => v
    w => w
    x => x
    y => y
    z => z

I note that your projection contains an error that will prevent it from running: the duplicated property “f”

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.