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

Switch to new EF Core plugin model #672

Merged
merged 1 commit into from
Oct 29, 2018
Merged

Switch to new EF Core plugin model #672

merged 1 commit into from
Oct 29, 2018

Conversation

roji
Copy link
Member

@roji roji commented Oct 21, 2018

@austindrenski @YohDeadfall @bricelam @ajcvickers here's a PR modifying the NetTopologySuite and NodaTime plugins to use the new EF Core plugin model introduced in 2.2. It's not a small change so I'd appreciate a review...

I did run into one annoying factoring issue when writing the type mapping source plugin for NodaTime. Although the NTS plugin is a bit special, the NodaTime plugin really has the same logic as the main NpgsqlTypeMappingSource - two lookup dictionaries (by store type, by CLR type) along with some non-trivial mapping lookup logic.. I experimented with refactoring the logic to avoid repetition but it isn't as easy it it looks. @ajcvickers it may be interesting for you to take a look; I know the type mapping APIs underwent quite a bit of change in the past, and there was a shift to a simpler model rather than trying to take care of too many things in the core. The relevant bits are the NodaTime plugin, and NpgsqlTypeMappingSource.

Some additional notes:

Fixes #658

@roji roji mentioned this pull request Oct 21, 2018
@austindrenski
Copy link
Contributor

@roji I'm starting a review now, but it looks like the new file are missing the license block at the top. Could you update to include it?

@roji
Copy link
Member Author

roji commented Oct 21, 2018

@austindrenski sorry about that. However, I've been wanting to simply get rid of these length messages, or at the very least drastically reduce them - I'm really not convinced having this big text in every single one of our source files helps in any way (just one at the repo root should be enough?). What do you think?

Copy link
Contributor

@austindrenski austindrenski left a comment

Choose a reason for hiding this comment

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

This looks awesome! See my review for one or two substantial issues (e.g. a missing ' in the SQL), a few questions, and some nits/suggestions.

This looks like it was a pretty substantial refactor, thanks for tackling it!

@austindrenski
Copy link
Contributor

@austindrenski sorry about that. However, I've been wanting to simply get rid of these length messages, or at the very least drastically reduce them - I'm really not convinced having this big text in every single one of our source files helps in any way (just one at the repo root should be enough?). What do you think?

That's totally fine by me. I got into the habit to match the pre-existing style here, but I'd be happy to see them omitted.

@austindrenski
Copy link
Contributor

Some additional notes:

  • Added some missing NTS translations

Once merged, we should make a note in #457 of the newly added translations.

@austindrenski
Copy link
Contributor

Not sure why the CI builds failed on repo access, but just restarted them and they seem to be running fine now.

@austindrenski
Copy link
Contributor

Travis failing with:

[xUnit.net 00:02:14.70]     Npgsql.EntityFrameworkCore.PostgreSQL.Query.SpatialQueryNpgsqlGeographyTest.Area(isAsync: True) [FAIL]
[xUnit.net 00:02:14.79]     Npgsql.EntityFrameworkCore.PostgreSQL.Query.SpatialQueryNpgsqlGeographyTest.Area(isAsync: False) [FAIL]
Failed   Npgsql.EntityFrameworkCore.PostgreSQL.Query.SpatialQueryNpgsqlGeographyTest.Area(isAsync: True)
Error Message:
 Npgsql.PostgresException : XX000: ptarray_area_spheroid: cannot handle ptarray that crosses equator

Copy link
Contributor

@austindrenski austindrenski left a comment

Choose a reason for hiding this comment

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

The new test fixtures are currently in separate files. Is that copy-over from the upstream project? If so, could we nest the fixtures within a #region Support at the bottom of relevant test class?

If you would prefer to keep these fixtures separate, should we look at separating out our existing nested fixtures? This may help with some of the fixture-proliferation you recently mentioned.

I don't have strong feelings either way, just thinking about consistency.

@@ -0,0 +1,76 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Copy link
Contributor

Choose a reason for hiding this comment

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

Omit per #674

Copy link
Member Author

Choose a reason for hiding this comment

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

Done, although I'm not too sure about the license status of these files which we copy-paste into the provider... Npgsql is licensed under the PostgreSQL license, which isn't the same as the Apache license which EF Core uses.

@ajcvickers, @divega anything to say here??

@roji
Copy link
Member Author

roji commented Oct 27, 2018

@austindrenski,

The new test fixtures are currently in separate files. Is that copy-over from the upstream project? If so, could we nest the fixtures within a #region Support at the bottom of relevant test class?

You're referring to SpatialQueryNpgsql{Geometry,Geography}Fixture, right? If so then yes, it's a copy-over from EFCore. As elsewhere, for those files which copy over, I think it's a good idea to maintain as much parity to help with later maintenance. When I just started work on the EF Core provider, I originally refactored and re-edited things my way, and that led to a lot of pain as upstream changes had to be tracked...

If you would prefer to keep these fixtures separate, should we look at separating out our existing nested fixtures? This may help with some of the fixture-proliferation you recently mentioned.

I wouldn't necessarily go that far. For our own test suites, I don't see a reason to impose external fixtures just because upstream test suites do so. I'd treat it on a case-by-case basis - where we have a big fixture that makes sense as a separate file, we can do that, otherwise we can leave them inside the test suite.

@roji
Copy link
Member Author

roji commented Oct 27, 2018

@austindrenski

Once merged, we should make a note in #457 of the newly added translations.

Done

@roji
Copy link
Member Author

roji commented Oct 27, 2018

Regarding the Travis build failures (ptarray_area_spheroid: cannot handle ptarray that crosses equator).

My first thought was that this is due to an old version of PostGIS or something similar. Strangely on Appveyor we install 2.4.4 and there aren't any failures there - but I still suspect some environmental/version issue. When I tried to upgrade I found that there are no public packages for PostGIS 2.5 for PostgreSQL 10 for trusty. I can't be 100% sure that an upgrade to PostGIS 2.5 would fix this, but I honestly don't want to fight Travis anymore - it's really behind on everything - running on trusty in this day and age is simply unacceptable.

So for me this is the last straw, and as we were about to move to either Appveyor for Linux or to Azure DevOps, I think it makes sense to drop Travis for this PR. @austindrenski @YohDeadfall any objections?

@austindrenski
Copy link
Contributor

Sounds good to me--no objections here.

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 roji merged commit e7bea84 into npgsql:dev Oct 29, 2018
@roji roji deleted the new-plugins branch October 29, 2018 17:08
@roji roji added cleanup and removed refactor labels May 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Switch to the new EF Core plugin model
3 participants