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

Query: Allow providers to replace and extend SqlTranslatingExpressionVisitor #6888

Closed
roji opened this issue Oct 27, 2016 · 4 comments
Closed
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-enhancement
Milestone

Comments

@roji
Copy link
Member

roji commented Oct 27, 2016

While working on array support for PostgreSQL, I ran into an issue: array indexing expressions, which are BinaryExpressions with NodeType ExpressionType.ArrayIndex, aren't recognized in SqlTranslatingExpressionVisitor.VisitBinary, which returns null for them. This prevents Npgsql from being able to map array indexing to SQL.

I could easily extend SqlTranslatingExpressionVisitor, but this doesn't seem to be something providers are supposed to do (i.e. I can't see it in RelationalDatabaseProviderServices). I realize I'm pushing things here, but it seems like a good idea to open this up to provider customizations.

@roji
Copy link
Member Author

roji commented Oct 31, 2016

Out of curiosity - what exactly would be the impact of extending SqlTranslatingExpressionVisitor right now, before it officially becomes a "provider-overridable" service? Is it purely an issue of contract (where this service may change at any time so I risk breakage), or is there something else?

@ajcvickers
Copy link
Contributor

@roji EF Core allows services for multiple providers to be registered within in the same D.I. container. The set of services to use is then determined for a given context instance with a UseSqlServer or similar. This works because provider service resolution goes through the indirection of IDatabaseProviderServices--it ensures that the context instance gets the correct services for the provider in use.

If a provider replaces a non-provider service when multiple providers have been registered, then the replacement service is going to be resolved even if a different provider is currently being used. This will cause problems if the replaced service does not work with the other provider, or if both providers have attempted to replace the same service.

This bug will not manifest in common cases--where there is only one provider registered. So it could be said that its not a super-important bug. Nevertheless, EF does support multiple provider registration, so providers should play nice and only replace provider services.

@roji
Copy link
Member Author

roji commented Nov 1, 2016

@ajcvickers thanks for the explanation, understood. And thanks for making the change.

@ajcvickers ajcvickers added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Nov 1, 2016
@roji
Copy link
Member Author

roji commented Nov 1, 2016

Super, thanks for the quick turnaround!

@ajcvickers ajcvickers changed the title Allow providers to replace and extend SqlTranslatingExpressionVisitor Query: Allow providers to replace and extend SqlTranslatingExpressionVisitor May 9, 2017
@ajcvickers ajcvickers modified the milestones: 2.0.0-preview1, 2.0.0 Oct 15, 2022
@ajcvickers ajcvickers removed their assignment Sep 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-enhancement
Projects
None yet
Development

No branches or pull requests

3 participants