-
Notifications
You must be signed in to change notification settings - Fork 383
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 for int IndexOf(string value, int startIndex) #1625
Comments
Yes, currently You can take a look at the existing implementation as a guide to adding the overload in MySqlStringComparisonMethodTranslator. |
@mguinness I wanna contribute to this. Would you please help me review and accomplish my PR #1645 ? |
@ajcvickers @roji Is there a reason why the start index parameter of IndexOf() isn't translated for SQL Server or Postgres? Is it because there is a workaround, like substring? |
@mguinness I don't think there's any particular reason - probably just nobody asked for it... I can see overloads of CHARINDEX (SQL Server) and STRPOS (PG) which accept the additional starting position parameter. |
@mguinness @lauxjpn @LeaFrock it turns out this actually was implemented for SQL Server in dotnet/efcore#26623, for 7.0.0-preview.1. There's a specification test for it as well, but since it was using a top-most projection, the test can client-eval and always passes regardless of whether a provider implements translation support or not. I opened dotnet/efcore#28031 to improve the tests. Note that SQLite and PostgreSQL do not have a function which accepts a start position parameter. |
Thanks for the PR from @roji , and based on it, I've created another PR #1652 to optimize the previous translation. @mguinness Would you please add |
Wiki updated as requested. Since you're a collaborator, you should see an Edit button on the page to allow you to edit the markdown. |
Thanks for your update. I'm just a normal contributor 😄 and the edit button is hidden to me. |
Currently
We Currently have an implementation of
int IndexOf(string value)
callingcolumn.IndexOf("#") <= 1
that gets (roughly) translated into `Implementing
int IndexOf(string value, int startIndex)
means we can use the formLOCATE('#',column,X)=0
forcolumn.IndexOf("#", X) == -1
.A way to currently achieve this implementation is to use
Substring(1).IndexOf("#") == -1
which however results in a fairly interesting:The text was updated successfully, but these errors were encountered: