Skip to content

Update the plugin model for expression filters - #581

Merged
austindrenski merged 2 commits into
npgsql:devfrom
austindrenski:plugin-model-patch
Aug 9, 2018
Merged

austindrenski merged 2 commits into
npgsql:devfrom
austindrenski:plugin-model-patch

Conversation

@austindrenski

Copy link
Copy Markdown
Contributor

Split from #577

  • Introduces a composite expression filter.
  • Pushes full-text search filtering into a specific filter.
  • Adds xml docs throughout.

- Introduces a composite expression filter.
- Pushes full-text search filtering into a specific filter.
- Adds xml docs throughout.

@roji roji left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, see my comments before merging please.

/// <inheritdoc />
public NpgsqlCompositeEvaluatableExpressionFilter([NotNull] IModel model, [NotNull] INpgsqlOptions npgsqlOptions) : base(model)
{
var versionDependentFilters =

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not so sure this makes sense here, let's add it if we ever actually need it?

node.Method.DeclaringType != typeof(NpgsqlFullTextSearchDbFunctionsExtensions) &&
node.Method.DeclaringType != typeof(NpgsqlFullTextSearchLinqExtensions);

bool IEvaluatableExpressionFilter.IsEvaluatableBinary(BinaryExpression node) => true;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit unfortunate, in the future we can introduce an abstract base class which takes care of all of these, and leaves only IsEvaluatableMethodCall(), which is likely to be the only interesting one. But it's OK for now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll also need IsEvaluatableMember() in #577, but agreed that the interface feels...a bit busy.

There is actually a class that exposes just these two methods, but it currently resides in Microsoft.EntityFrameworkCore.Query.Internal, so I opted for the interface for the time being.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That class also contains more concrete logic (DateTime.Now, GUIDs...).

However, there's EvaluatableExpressionFilterBasein relinq which seems to be exactly what you need, maybe just inherit that?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked at that too... but one of the items mentioned here gave me pause:

Decide on architecture changes, if any. For example internalize or remove Relinq.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, no big deal, we can always improve on this later if we want.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One additional thought: EF Core themselves extend that class, so any breakage at the relinq side will surely be well thought-out :)

@austindrenski
austindrenski merged commit 45f4204 into npgsql:dev Aug 9, 2018
@austindrenski
austindrenski deleted the plugin-model-patch branch August 9, 2018 05:57
@austindrenski austindrenski self-assigned this Aug 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants