-
Notifications
You must be signed in to change notification settings - Fork 227
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 Convert.ToDateTime as a supported method for translation #1297 #1298
base: main
Are you sure you want to change the base?
Conversation
Maybe it would have been best if I didn't created a pull request so soon. I could have asked the same referencing the commit on my fork without creating a pull request. |
@TanielianVB no worries about creating a PR! Yeah, it actually is that simple (though a test would also be good). The reason this hasn't been done is that unlike Convert.ToInt32, Convert.ToDateTime would not work on the database in the same way as it would work in C#: the date format strings accepted by PostgreSQL and by .NET ToDateTime are very different. Let's wait for some feedback in #1297 before doing anything. |
I think that if a dev uses Convert.ToDateTime he has to know in what SQL the query will be translated. But, we can also add functions like EF.Functions.ILike to the TO_DATE and TO_TIMESTAMP functions. |
The general principle in EF is for methods to behave in the same way when translated to the server, as they would when executed on the client - this is why Convert.ToDateTime is somewhat problematic... But you're right that in any case we can provide something on EF.Functions. |
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.
Sorry for taking so long to review this.
Can you please add a test to NorthwindFunctionsQueryNpgsqlTest which follows the model of the tests in EF Core?
src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlConvertTranslator.cs
Outdated
Show resolved
Hide resolved
test/EFCore.PG.FunctionalTests/Query/NorthwindFunctionsQueryNpgsqlTest.cs
Outdated
Show resolved
Hide resolved
Already made all requested changes. |
It could not be so simple as that right? But I could not find the unit tests that asserted the translated query from the other Convert methods so... How could I test it?
Sorry in advance if I took an unnecessary step.