Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Fix substring search on multi-byte strings, LIKE on values with *, and sort nulls first - #41

Merged
colemancda merged 3 commits into
masterfrom
fix/substring-and-null-order
Nov 17, 2026
Merged

colemancda merged 3 commits into
masterfrom
fix/substring-and-null-order

Conversation

@colemancda

@colemancda colemancda commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Three fixes in the in-memory evaluator, found by comparing it with CoreModel-SQLite on the same requests.

Substrings. Collection.contains(_:), which CONTAINS and IN on strings resolve to, stepped through the pattern with the subject's index(after:). A string's step depends on its encoding, so with a two-byte character such as É it skipped one of the pattern's: "Édsger" contained "ra". It now steps with other.index(after:).

LIKE on a value with a *. wildcardMatch compared the pattern's character with the value's before checking for a wildcard, so a * in the value was matched as a literal against the pattern's *: "a*b?[c]" LIKE "a*" was false. A pattern's * is now always the wildcard.

Nulls in a sort. AttributeValue.order has no order for a null, so sorted(by:) treated a null as equal to every value. That isn't a strict weak ordering: where nulls ended up depended on the order the objects came in. A null or missing value now sorts before every other value, as SQLite and Core Data sort them (so last when descending).

Tests: substringsOfWiderCharacters, sortingNulls and more cases in wildcardMatch, in PredicateEvaluationTests. All tests pass on macOS.

@github-code-quality

Copy link
Copy Markdown

Code coverage overview

Languages: Swift

Swift / code-coverage/llvm-cov

master 456c3e1 fix/substring-and-nu... cb06a5d +/-
96% 96% 0%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.

@colemancda
colemancda merged commit 695fb48 into master Nov 17, 2026
32 checks passed
@colemancda
colemancda deleted the fix/substring-and-null-order branch November 17, 2026 03:50
@colemancda colemancda changed the title Fix substring search on multi-byte strings and sort nulls first Fix substring search on multi-byte strings, LIKE on values with *, and sort nulls first Nov 17, 2026
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.

1 participant