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

Added Support for translating Array.IndexOf methods for byte arrays for SqlServer & SQLite #34457

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

nikhil197
Copy link

@nikhil197 nikhil197 commented Aug 17, 2024

  • Added Support for translating byte[].IndexOf method for Sql Server & SQLite

  • Added tests for the same
    Fixes Query: Translate byte array.IndexOf #19287

  • I've read the guidelines for contributing and seen the walkthrough

  • I've posted a comment on an issue with a detailed description of how I am planning to contribute and got approval from a member of the team

  • The code builds and tests pass locally (also verified by our automated build checks)

  • Commit messages follow this format:

        Summary of the changes
        - Detail 1
        - Detail 2

        Fixes #bugnumber
  • Tests for the changes have been added (for bug fixes / features)
  • Code follows the same patterns and style as existing code in this repo

@nikhil197 nikhil197 changed the title [WIP] Added Support for translating byte[].IndexOf methods for SqlServer Added Support for translating byte[].IndexOf methods for SqlServer Aug 17, 2024
@nikhil197
Copy link
Author

@dotnet-policy-service agree

@nikhil197 nikhil197 changed the title Added Support for translating byte[].IndexOf methods for SqlServer Added Support for translating Array.IndexOf methods for byte arrays for SqlServer Aug 17, 2024
@nikhil197 nikhil197 changed the title Added Support for translating Array.IndexOf methods for byte arrays for SqlServer Added Support for translating Array.IndexOf methods for byte arrays for SqlServer & SQLite Aug 18, 2024
@nikhil197
Copy link
Author

Hi @roji
I think the PR is ready for review now. I have added translation for both SQL Server & SQLite and have also added tests for both.
Please take a look when you get sometime

src/Shared/ArrayMethods.cs Outdated Show resolved Hide resolved
public virtual Task Byte_array_with_max_possible_length_filter_by_index_of_literal(bool async)
=> AssertQuery(
async,
ss => ss.Set<Squad>().Where(w => Array.IndexOf(w.Banner, (byte)1) == 1),
Copy link
Member

Choose a reason for hiding this comment

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

The cast here shouldn't be needed, no?

Suggested change
ss => ss.Set<Squad>().Where(w => Array.IndexOf(w.Banner, (byte)1) == 1),
ss => ss.Set<Squad>().Where(w => Array.IndexOf(w.Banner, 1) == 1),

Copy link
Author

@nikhil197 nikhil197 Aug 19, 2024

Choose a reason for hiding this comment

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

No actually, it is needed. Without this it's picking non-generic version of the method IndexOf(Array arr, object value) (because 1 is an Int32 by default and I haven't specified the type argument on the IndexOf).

Do we want to support that too?

@nikhil197 nikhil197 requested a review from roji August 19, 2024 14:22
@nikhil197
Copy link
Author

Hi @roji
Could you please take a look at this PR, when you get sometime? I have resolved the comments that you added earlier. Please let me know if there's something else needed

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 byte array.IndexOf
2 participants