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

Add plugin support to EvaluatableExpressionFilter #13454

Closed
roji opened this issue Sep 30, 2018 · 8 comments · Fixed by #20033
Closed

Add plugin support to EvaluatableExpressionFilter #13454

roji opened this issue Sep 30, 2018 · 8 comments · Fixed by #20033
Assignees
Labels
area-query closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported type-enhancement
Milestone

Comments

@roji
Copy link
Member

roji commented Sep 30, 2018

2.2 is introducing plugins, which can extend type mappings and method/member translations from outside EF Core. I'm currently porting Npgsql's own plugin model (introduced in 2.1) to the new EF Core one (npgsql/efcore.pg#658), and one missing extension point is for EvaluatableExpressionFilter: our NodaTime plugin flags SystemClock.Instance.GetCurrentInstance() as non-evaluatable, to make sure it's evaluated at the server (much like DateTime.Now).

It seems important for this to make it into 2.2, otherwise NodaTime specifically won't be portable to the new plugin model (and this may also affect other plugins). I'll probably be able to submit a PR in about 2-3 weeks, is that early enough?

@bricelam
Copy link
Contributor

bricelam commented Oct 1, 2018

On a related note, I've wanted hooks for the following in my TimeSpan on SQLite extension:

  • SqlTranslatingExpressionVisitor
    • VisitUnary
    • VisitBinary
  • RelationalConnection
    • Open
    • OpenAsync

@ajcvickers
Copy link
Member

@roji 2-3 weeks won't make it for preview3, but it should be good for RTM. This doesn't sound like it will be a risky change, so I think we'll be good taking it directly into RTM. (There is no RC for 2.2; rightly or not, we're going straight from preview3 to RTM.)

@ajcvickers ajcvickers added this to the 2.2.0 milestone Oct 1, 2018
@ajcvickers ajcvickers modified the milestones: 2.2.0-preview3, 2.2.0 Oct 15, 2018
roji added a commit to roji/efcore.pg that referenced this issue Oct 21, 2018
Notes:

* Added some missing NTS translations
* The new EF Core plugin model doesn't yet support specifying
  evaluatable (dotnet/efcore#13454),
  so we currently hack that up inside the main provider using type
  names as strings.

Fixes npgsql#658
@ajcvickers
Copy link
Member

@smitpatel and @bricelam to follow up with @roji whether this makes sense for 2.2 given changes coming in 3.0.

@smitpatel
Copy link
Member

@roji - Is this required to be in 2.2 to support everything for npgsql? In new query pipeline, the structure of this would be changing especially current funcletizer depends on Relinq so any work here could become throw-away work. If it is necessary then we can do it for 2.2

@roji
Copy link
Member Author

roji commented Oct 27, 2018

I'm just completing npgsql/efcore.pg#672, which redoes Npgsql's plugins to use the new EF Core plugin model introduced in 2.2. The only place where specifying evaluatable was important is in NodaTime's SystemClock.GetCurrentInstant() (similar to DateTime.UtcNow, but for now I hacked around the lack of support by checking for this method in Npgsql's own EvaluatableExpressionFilter (the provider's, not in NodaTime plugin), using string checks to avoid taking a reference on NodaTime. This is an ugly workaround but is totally fine.

Long story short, there's no critical need for this in 2.2 - if things are radically changing in 3.0 we can forget it.

@roji roji closed this as completed Oct 27, 2018
roji added a commit to roji/efcore.pg that referenced this issue Oct 27, 2018
Notes:

* Added some missing NTS translations
* The new EF Core plugin model doesn't yet support specifying
  evaluatable (dotnet/efcore#13454),
  so we currently hack that up inside the main provider using type
  names as strings.

Fixes npgsql#658
roji added a commit to roji/efcore.pg that referenced this issue Oct 29, 2018
Notes:

* Added some missing NTS translations
* The new EF Core plugin model doesn't yet support specifying
  evaluatable (dotnet/efcore#13454),
  so we currently hack that up inside the main provider using type
  names as strings.

Fixes npgsql#658
roji added a commit to npgsql/efcore.pg that referenced this issue Oct 29, 2018
Notes:

* Added some missing NTS translations
* The new EF Core plugin model doesn't yet support specifying
  evaluatable (dotnet/efcore#13454),
  so we currently hack that up inside the main provider using type
  names as strings.

Fixes #658
@ajcvickers ajcvickers removed this from the 2.2.0 milestone Oct 29, 2018
@smitpatel
Copy link
Member

@roji - Do we still need this in new pipeline?

@roji
Copy link
Member Author

roji commented Jun 24, 2019

@smitpatel if I understand correctly, methods/properties like DateTime.UtcNow will now always be translated (if translatable) so I don't see any further need....

@roji
Copy link
Member Author

roji commented Sep 30, 2019

@smitpatel unless I'm mistaken this is actually needed even in the new pipeline, to make sure that ParameterExtractingExpressionVisitor doesn't evaluate invocations of methods and embed the result as a constant?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-query closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported type-enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants