-
Notifications
You must be signed in to change notification settings - Fork 934
Fix OData string comparisons (lt, gt, ge, le) #2386
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
840efd7
Test case
bahusoid 4a610aa
Fix
bahusoid e4b2635
Fix locate function for SQLite
bahusoid 66a3562
Support with warn StringComparison in StartsWith, EndsWith, IndexOf, …
bahusoid ccb0bfa
Revert "Fix locate function for SQLite"
bahusoid 08ba31c
Skip locate on SQLite
bahusoid 64be7b6
Fix some whitespace glitches
fredericDelaporte aa70607
Avoid ToList for arguments
bahusoid a2421a4
Remove SupportsLocate checks
bahusoid 53d8527
Merge branch 'master' into odataCompare
hazzik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we do not register
EndsWith
,StartsWith
orIndexOf
overloads withStringComparison
, does this means there is an inconsistency in OData implementation here? It would emitCompare
calls with that argument, but it would omit it for these three other cases?So I see three options:
@maca88, @hazzik
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeap. Seems to be.
I would choose this one as I see no difference with call to default
string.Compare
. It's not corelated in any way to with how DB is configured to make string comparisons. In factStringComparison
might be used to make LINQ to objects queries behave the same as DB (as I already mentioned in case of default SQL Server case insensitive collation)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By just adding the missing overload we introduce another issue where we generate the same query when using
StringComparison.XXX
andStringComparison.XXXIgnoreCase
, which would cause an unexpected result on a case sensitive collation. IMO we should at least try to mimic .NET behavior when usingXXXIgnoreCase
by usinglower
function on each side.Yes, from the OData source code only
StringComparison.Ordinal
option is used forstring.Compare
, where forEndsWith
,StartsWith
and other methods theStringComparison
overload is not used.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thing is, we do not try to support different
StringComparison
values, we just ignore them. The trouble is the same conversely, with case insensitive collations, when using a non ignoring caseStringComparison
. And for this converse case, there is no ".Net" side workaround.The current state is, NHibernate bluntly states these overloads are not supported. That is fine for user generated expression. But when the user cannot control the generated expression, it is a blocker.
So I think accepting these overloads, while not actually supporting the
StringComparison
argument, is an acceptable trade-of. Maybe we should emit a NHibernate warning or information about the argument being ignored, though.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some databases support the COLLATE clause (SqlLite, SqlServer, Oracle, PostgreSql, MySql) within the query, which could be used to do case sensitive/insensitive comparison. But that's a matter for a separate PR.
It is fine by me.