Repository navigation
Use a JSONPATH for quoted JSON property names on SQLite - #39378
Merged
AndriySvyryd merged 1 commit intoOct 22, 2026
Merged
Conversation
- A property name that needs quoting was emitted as a plain ->> label, so SQLite looked up the key with the quotes included and never matched - Added a predicate test on a quoted property inside a JSON collection element and updated the affected baselines Fixes dotnet#39328
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No unresolved review issues were identified, and the supplied assessments indicate the changes are ready for approval.
No open issues 🎉
What changed in this PR
This pull request fixes SQLite JSON scalar lookups for quoted property names by emitting a $.-prefixed JSONPath for terminal segments that require quoting.
Changes:
- Corrects SQLite JSON SQL generation for quoted terminal property names.
- Adds regression coverage for quoted properties in JSON collection predicates.
- Updates affected SQLite SQL baselines.
| File | Description |
|---|---|
test/EFCore.Sqlite.FunctionalTests/Query/JsonQuerySqliteTest.cs |
Adds regression coverage and updates expected SQL baselines. |
src/EFCore.Sqlite.Core/Query/Internal/SqliteQuerySqlGenerator.cs |
Generates valid JSONPath operands for quoted terminal property names. |
Review effort: Lite
Contributor
Author
|
The two failing checks look unrelated to this SQLite-only change:
|
AndriySvyryd
approved these changes
Oct 22, 2026
AndriySvyryd
left a comment
Member
There was a problem hiding this comment.
Thanks for your contribution!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #39328
When a JSON property name needs quoting and is the last segment,
VisitJsonScalarwrote it as a plain->>label (->> '"display_name"'). SQLite reads a right operand that doesn't start with$as a literal key, so the quotes become part of the name and the lookup returns NULL. With this change, such names are written as a JSONPATH instead (->> '$."display_name"'). Names that don't need quoting still use the short label form.Tests:
Custom_naming_predicate_on_scalar_in_collection_elementinJsonQuerySqliteTest. It filters onユニコーンFraction一角獣insideCustomOwnedCollectionBranchand returned 0 rows before the change.Custom_naming_projection_everythingandCustom_naming_projection_owned_referencebaselines updated. They were asserting the broken form.Ran all SQLite tests with Json, Complex or PrimitiveCollections in the class name: 4943 passed, 125 skipped, 0 failed.
I posted the plan on the issue just now. I'm happy to change the approach if you'd rather handle it elsewhere, for example in
DelimitJsonPathElement.