-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Translate Regex.IsMatch on SQLite #22497
Conversation
src/EFCore.Sqlite.Core/Storage/Internal/SqliteRelationalConnection.cs
Outdated
Show resolved
Hide resolved
src/EFCore.Sqlite.Core/Storage/Internal/SqliteRelationalConnection.cs
Outdated
Show resolved
Hide resolved
Base branch change to main. Please rebase on latest main. |
src/EFCore.Sqlite.Core/Infrastructure/SqliteDbContextOptionsBuilder.cs
Outdated
Show resolved
Hide resolved
src/EFCore.Sqlite.Core/Infrastructure/SqliteDbContextOptionsBuilder.cs
Outdated
Show resolved
Hide resolved
src/EFCore.Sqlite.Core/Query/Internal/SqliteMethodCallTranslatorProvider.cs
Outdated
Show resolved
Hide resolved
test/EFCore.Sqlite.Tests/SqliteDbContextOptionsBuilderExtensionsTest.cs
Outdated
Show resolved
Hide resolved
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.
One thing to be careful is the finer details of regex behavior. For example, in PostgreSQL the default is to have single-line behavior (where .
doesn't match \n), while the .NET default behavior isn't. It may be OK to translate the default overload of IsMatch (the one without RegexOptions) to whatever the default behavior is on Sqlite, but it would mean a subtle behavior mismatch.
src/EFCore.Sqlite.Core/Storage/Internal/SqliteRelationalConnection.cs
Outdated
Show resolved
Hide resolved
For comparison, here's the regex SQL generation in EFCore.PG (and here's the translation). In PG regex is a 1st-class operator instead of a function. |
@roji The beauty here is that SQLite doesn't provide an implementation. (Well, outside of an optional extension that the user would need to compile themselves.) The idea being that you just re-use your platform's regex so the app and the database have the same semantics. |
Ah, I see - so this would end up calling back into .NET Regex.IsMatch then? Or some native implementation? Just asking the question around behavioral discrepancy between Regex.IsMatch and what actually gets executed.. |
Yes, the database would call back into Regex.IsMatch |
50967fe
to
73d93d3
Compare
src/EFCore.Sqlite.Core/Storage/Internal/SqliteRelationalConnection.cs
Outdated
Show resolved
Hide resolved
Looks like we need to override the test in Cosmos too |
test/EFCore.SqlServer.FunctionalTests/Query/NorthwindFunctionsQuerySqlServerTest.cs
Show resolved
Hide resolved
a040050
to
050f647
Compare
(Rebased, squashed, and cleaned it up a bit) |
src/EFCore.Sqlite.Core/Query/Internal/SqliteRegexMethodTranslator.cs
Outdated
Show resolved
Hide resolved
test/EFCore.Specification.Tests/Query/NorthwindFunctionsQueryTestBase.cs
Outdated
Show resolved
Hide resolved
Fix type mapping
test/EFCore.Sqlite.FunctionalTests/Query/NorthwindFunctionsQuerySqliteTest.cs
Outdated
Show resolved
Hide resolved
576be14
to
a588fc7
Compare
a588fc7
to
551c58a
Compare
implements #18845