KEMBAR78
Use -> operator for SQLite JsonScalarExpression by roji · Pull Request #30745 · dotnet/efcore · GitHub
Skip to content

Conversation

@roji
Copy link
Member

@roji roji commented Apr 23, 2023

Closes #30334

@roji roji requested a review from maumar April 23, 2023 11:15
{
if (jsonScalarExpression.Path.Count == 1
&& jsonScalarExpression.Path[0].ToString() == "$")
// TODO: This trims the leading $ PathSegment, which isn't actually part of the path (but rather path of the JSONPATH language
Copy link
Member Author

@roji roji Apr 23, 2023

Choose a reason for hiding this comment

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

@maumar note this - I think we should remove the $ path segment at the beginning, at the source... It's purely a SQL generation concern, and PostgreSQL would need to ignore it (since it doesn't use JSONPATH for this). Even for SQLite, when there's just a single (non-$) path segment, this PR does JsonColumn ->> 'Foo' (property) or JsonColumn ->> 1 (array), which is simpler and again doesn't need the $.

On a related note, when the JSON expression has no path segments, it shouldn't be created in translation - there's this piece of code here for ignoring/unwrapping it when it's empty.

Does that make sense? If so I can open a separate issue to do that.

Copy link
Contributor

Choose a reason for hiding this comment

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

makes sense!

Copy link
Member Author

Choose a reason for hiding this comment

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

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.

JSON/Sqlite: use -> and ->> where possible when traversing JSON, rather than json_extract

2 participants