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

Support Contains on byte arrays on SqlServer #19071

Merged
merged 1 commit into from
Nov 26, 2019
Merged

Support Contains on byte arrays on SqlServer #19071

merged 1 commit into from
Nov 26, 2019

Conversation

roji
Copy link
Member

@roji roji commented Nov 26, 2019

Resolves #4601

@@ -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;
Copy link
Member Author

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?

Copy link
Contributor

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

Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

Will do this.

@roji roji force-pushed the ByteArrayContains branch from 94c0091 to 801e485 Compare November 26, 2019 07:22
@roji roji force-pushed the ByteArrayContains branch from 801e485 to cf470a0 Compare November 26, 2019 21:06
@roji roji merged commit 066b637 into master Nov 26, 2019
@roji roji deleted the ByteArrayContains branch November 26, 2019 23:22
@roji roji changed the title Support Contains on byte arrays Support Contains on byte arrays on SqlServer Nov 26, 2019
&& method.GetGenericMethodDefinition().Equals(EnumerableMethods.Contains)
&& arguments[0].Type == typeof(byte[]))
{
instance = arguments[0];
Copy link
Contributor

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.

Copy link
Member Author

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".

Copy link
Contributor

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.

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.

Query: Translate Enumerable.Contains() with byte arrays
4 participants