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

Correct LTree type mapping logic #2489

Merged
merged 1 commit into from
Aug 31, 2022
Merged

Correct LTree type mapping logic #2489

merged 1 commit into from
Aug 31, 2022

Conversation

roji
Copy link
Member

@roji roji commented Aug 31, 2022

Fixes #2487

@roji roji enabled auto-merge (rebase) August 31, 2022 10:00
// If it's a parameter, we can also just apply the mapping (which causes NpgsqlDbType to be set to LQuery).
// For anything else, we may need an explicit cast to LQuery, e.g. a plain text column or a concatenation between strings;
// apply the default type mapping and then apply an additional Convert node if the resulting mapping isn't what we need.
private SqlExpression ApplyTypeMappingOrConvert(SqlExpression sqlExpression, RelationalTypeMapping typeMapping)
Copy link
Member Author

Choose a reason for hiding this comment

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

@smitpatel you may be interested in this. The context is that CLR string can be mapped to PG lquery; previously, functions requiring an lquery simply applied the type mapping, which didn't work for non-lquery columns (a cast node is needed), or for concatenation (since the type mapping would filter down to the operands, but concat on lquery isn't supported - the type mapping must be applied after the concatenation happens over strings).

On the other hand I don't want to just always have a convert node (don't need it for literals, parameters, or column which already are of type lquery); in that sense could be related to dotnet/efcore#26411. So there's the logic here to determine when the explicit convert is needed. May be worth thinking about in relational...

@roji roji disabled auto-merge August 31, 2022 11:07
@roji roji merged commit ddc63fc into npgsql:main Aug 31, 2022
@roji roji deleted the LTreeTranslation branch August 31, 2022 11:07
@roji
Copy link
Member Author

roji commented Aug 31, 2022

Backported to 6.0.7 via 9b2a90c

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.

Incorrect SQL generation for LTree.MatchesLQuery
1 participant