Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CBL-6626: SQL++ query not return expected results #2209

Open
wants to merge 5 commits into
base: release/3.2
Choose a base branch
from

Conversation

callumbirks
Copy link
Contributor

The issue which caused the customer's query to not return the correct results is that litecore thinks the null value is not null.
The underlying cause of that is an issue with indexes which causes some values in certain indexes to not be correctly typed as null when passing into the query engine.
So this does not fix the underlying problem, but it is a good workaround that @snej agreed with.
Basically the problematic values do not get given the Null subtype when they should, so our usual check for the null subtype fails. Now, we also check if the size is 0 if the subtype has not been set.

@cbl-bot
Copy link

cbl-bot commented Jan 13, 2025

Code Coverage Results:

Type Percentage
branches 67.94
functions 79.23
instantiations 35.25
lines 79.28
regions 75.17

@jianminzhao jianminzhao requested a review from snej January 17, 2025 17:54
@jianminzhao
Copy link
Contributor

@snej I see Blob&&subtype==0 is being used in fl_result. I would defer to you whether to accept it as a patch to isNull() function.

@jianminzhao
Copy link
Contributor

Please also fix fl_result where we only check blob's subtype but not the size. Also for isNull(), size of the blob (being 0) is sufficient. Subtype is secondary. (non-zero size with subtype fleecenull reveals a bug)

@callumbirks
Copy link
Contributor Author

@jianminzhao I've added the fix to fl_result.

I'm unsure about removing the check for subtype == 0, this is what @snej told me was appropriate previously.
There are more subtypes which are used with blob, i.e. kPlainBlobSubtype, which is encoded as a slice, so may be allowed to be an empty slice - this I am unsure of.

// Untagged blob with size is already Fleece data
break;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it equivalent to:
case 0:
case kFleeceNullSubtype:
if (size > 0) break; // untagged blob ...
else {
// Fleece/JSON null
return;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants