Full text search with Left Outer Join causes fields to be null

Description

Using a full text search with left outer join can cause some fields to be null when they should not. Note this only occurs if the item on the outer join is null and appears in the query result. Please see the following example.

If an a row returns with a company the fields are populated but if the company is null then lastName is null. The field that is nullified seems to be relative to where ever a company field is placed. Note, ff the full text search is removed from the where expression the data comes back as expected.

From my investigation it looks like the missingColumns bitmask from here is incorrect. This is also an issue in the iOS sdk, the only difference is that nil is used instead of null.

We have tried moving the fields coming from the outer join to the bottom of the select expression with some success but this doesn't work as soon as you do more than one left outer join.

 

Explain:

 

SELECT
fl_result(fl_value("company".body, 'name')),
fl_result(fl_value("person".body, 'firstName')),
fl_result(fl_value("person".body, 'lastName')),
fl_result(fl_value("person".body, 'gender'))
FROM kv_default AS "person"
LEFT OUTER JOIN kv_default AS "company" ON
(fl_value("person".body, 'companyID') = fl_value("company".body, 'id'))
AND ("company".flags & 1 = 0)
WHERE (
fl_value("person".body, 'type') = 'Person')
AND ("person".flags & 1 = 0)

3|0|0| SCAN TABLE kv_default AS person
11|0|0| SCAN TABLE kv_default AS company

{"FROM":[{"AS":"person"},{"AS":"company","JOIN":"LEFT OUTER","ON":["=",[".person.companyID"],[".company.id"]]}],"WHAT":[[".company.name"],[".person.firstName"],[".person.lastName"],[".person.gender"]],"WHERE":["=",[".person.type"],"Person"]}

Activity

Show:

CB robot October 19, 2020 at 7:14 PM

Build couchbase-lite-ios-3.0.0-21 contains couchbase-lite-core commit 5029993 with commit message:
: Skip "hidden" columns when calculating missing columns (#1064)

CB robot October 9, 2020 at 12:34 AM

Build couchbase-lite-net-3.0.0-8 contains couchbase-lite-core commit 5029993 with commit message:
: Skip "hidden" columns when calculating missing columns (#1064)

CB robot October 8, 2020 at 7:18 PM

Build couchbase-lite-java-3.0.0-13 contains couchbase-lite-core commit 5029993 with commit message:
: Skip "hidden" columns when calculating missing columns (#1064)

CB robot October 8, 2020 at 7:07 PM

Build couchbase-lite-android-3.0.0-13 contains couchbase-lite-core commit 5029993 with commit message:
: Skip "hidden" columns when calculating missing columns (#1064)

CB robot October 8, 2020 at 6:09 AM

Build couchbase-lite-core-3.0.0-5 contains couchbase-lite-core commit 5029993 with commit message:
: Skip "hidden" columns when calculating missing columns (#1064)

Fixed
Pinned fields
Click on the next to a field label to start pinning.

Details

Assignee

Reporter

Story Points

Components

Fix versions

Affects versions

Priority

Instabug

Open Instabug

PagerDuty

Sentry

Zendesk Support

Created May 19, 2020 at 10:31 PM
Updated October 19, 2020 at 7:14 PM
Resolved September 12, 2020 at 12:54 AM
Instabug