-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Support Contains on byte arrays on SqlServer #19071
Conversation
@@ -116,6 +116,10 @@ public override async Task Select_datetimeoffset_comparison_in_projection(bool a | |||
FROM ""Missions"" AS ""m"""); | |||
} | |||
|
|||
public override Task Byte_array_contains_literal(bool async) => null; | |||
|
|||
public override Task Byte_array_contains_parameter(bool async) => null; |
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.
Sqlite does have INSTR which works great for literal, but I couldn't find a way to cast/convert a non-literal byte into an Sqlite BLOB. Maybe @bricelam knows?
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.
SELECT *
FROM Squads
WHERE instr(Banner, char(@someByte)) > 0
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.
Technically, that converts Banner to TEXT, but the result is the same. cast(char(@someByte) as blob)
would keep them both blob.
Note, without char(), someByte is converted from integer to blob which results in an 8-byte blob.
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.
Will do this.
94c0091
to
801e485
Compare
test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/GearsOfWarData.cs
Show resolved
Hide resolved
test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs
Outdated
Show resolved
Hide resolved
src/EFCore.SqlServer/Query/Internal/SqlServerMethodCallTranslatorProvider.cs
Outdated
Show resolved
Hide resolved
Resolves #4601
801e485
to
cf470a0
Compare
&& method.GetGenericMethodDefinition().Equals(EnumerableMethods.Contains) | ||
&& arguments[0].Type == typeof(byte[])) | ||
{ | ||
instance = arguments[0]; |
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.
Don't assign to instance. Using parameters of a function to store local variable causes confusion.
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.
It may be even more confusing to have a two instance variables, one "bad" and one "good".
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.
Don't call it instance. Just call it firstArgument.
Resolves #4601