-
Notifications
You must be signed in to change notification settings - Fork 49
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
DBAL v4, Middleware, Driver, Platform, and SchemaManager implementation #61
base: main
Are you sure you want to change the base?
Conversation
7c34d2b
to
c82761b
Compare
|
||
use Doctrine\DBAL\Platforms\AbstractPlatform; | ||
|
||
final class GeoJsonType extends GeographyType |
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.
Is this file in the wrong folder?
Would be cool to have this new type added too
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.
No, it is meant to be a fixture with respect to this PR.
Agreed it might be a nice feature, but beyond scope of this PR 😺
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.
fun fact: we started using it in our own project too, but altered to be a geometry
rather than a geography
:
ST_GeomFromGeoJSON(%s)::geometry
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.
Exactly one of the reasons i only provide very basic types. Even those are probably only starting points for your own application specific types 😉
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.
yeah, exactly (with the added fun of having Doctrine not discovering the class if you use hypens -
as type name 🤦 )
we got an "auto WSG84 converter" type, but that's a different story :-)
@jsor we have been using this fork with no issues for a while now, any progress/help-needed here? |
9866728
to
1b766d0
Compare
2bc5745
to
07e9d7a
Compare
This latest update should take care of the remaining deprecations to support DBAL v4 (and silence PHPUnit). Tests are passing locally. |
src/Driver/PostGISPlatform.php
Outdated
} | ||
|
||
/** @var ColumnDiff $columnDiff */ | ||
foreach ($diff->getModifiedColumns() as $columnDiff) { | ||
if ($columnDiff->hasChanged('srid')) { | ||
if ($columnDiff->getOldColumn()->getPlatformOption('srid') !== $columnDiff->getNewColumn()->getPlatformOption('srid')) { |
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.
This throws an exception when the 'srid' option is not defined (example: the column is not one from PosGis)
I would add something like this before the check:
if( ! $columnDiff->getNewColumn()->hasPlatformOption('srid')) {
continue;
}
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.
The error is thrown when running bin/console doctrine:schema:validate -v
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.
Thanks so much for the testing! Fix pushed.
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.
Thank you for the PR! 👍
Unfortunately DBAL v4 is not (yet) compatible with Symfony, thus my tests will be limited to v3 only from now on
👍 This branch works for me, I was able to upgrade an existing symfony project to DBAL 4, ORM 3. Thanks! |
src/Driver/PostGISPlatform.php
Outdated
if(!$columnDiff->getOldColumn()->hasPlatformOption('srid') && !$columnDiff->getNewColumn()->hasPlatformOption('srid')) { | ||
continue; | ||
} | ||
if ($columnDiff->getOldColumn()->getPlatformOption('srid') !== $columnDiff->getNewColumn()->getPlatformOption('srid')) { |
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.
This check doesn't seem to work in our case.
$columnDiff->getNewColumn()
has the srid
platform option, but $columnDiff->getOldColumn()
doesn't have it.
This makes it fail with the error Warning: Undefined array key "srid"
.
I don't know why $columnDiff->getOldColumn()
doesn't have the srid
platform option at this point, though.
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.
I've updated the logic, does that fix it for you?
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.
I just tested the new logic. It doesn't throw any error any more.
But it always detects a change, which wants to update the SRID. I guess, that's because srid
is not there in $columnDiff->getOldColumn()
. There's probably another issue, that this doesn't get populated.
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.
I've poked and prodded, but I can't reproduce. I hit something like this when I was first composing the PR … but now 😟
Do you have the time to generate a test case? I'll happily dig in from there!
cd67572
to
1dea92f
Compare
@GwendolenLynch in the documentation you write:
In the example you register ORMSchemaEventSubscriber, if someone just copies it it will fail. |
Also, I am getting this when I am adding ORM subscriber:
|
Thanks for your feedback, @tasselchof. I'm going to try to add some more tests to cover this. What versions of |
I've made a pull request to your branch with those fixes: GwendolenLynch#1. You can merge it to fix those and if I will find anything else - I will do another pull request. It's just one test if you wish to add it.
|
Hey guys! Are there any plans on merging this or should we rollback to DBAL v3? |
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.
A CHANGELOG.md or UPGRADE.md would be welcome to list the new classes and especially the BC of deleted or renamed class.
}, | ||
"require-dev": { | ||
"doctrine/orm": "^2.9", | ||
"doctrine/collections": "^2.0 || ^3.0", | ||
"doctrine/orm": "^2.19 || ^3.0", |
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.
I think we should add a conflict like : "doctrine/orm": "<2.18"
for Doctrine\ORM\Query\TokenType
Hello everyone, any news on this MR ? Are the changelog is the only thing missing for merging it ? |
From DBAL 3.2 the events systems is (mostly?) deprecated in favour of middleware, and custom schema manager + factory combination.
The main purpose of this PR is to migrate as much as possible to this:
Jsor\Doctrine\PostGIS\Driver\Driver
that extendsAbstractPostgreSQLDriver
Jsor\Doctrine\PostGIS\Driver\Middleware
that wraps the lower levelDriver
inside the PostGISDriver
Jsor\Doctrine\PostGIS\Driver\PostGISPlatform
wrapsDoctrine\DBAL\Platforms\PostgreSQLPlatform
and is instantiated by the PostGISDriver
Jsor\Doctrine\PostGIS\Schema\SchemaManager
now extendsDoctrine\DBAL\Schema\PostgreSQLSchemaManager
and handles schema managementJsor\Doctrine\PostGIS\Schema\SchemaManagerFactory
is an implementation ofDoctrine\DBAL\Schema\SchemaManagerFactory
SchemaManager
instance insideConnection
Jsor\Doctrine\PostGIS\Event\DBALSchemaEventSubscriber
moved toPostGISPlatform
Additionally:
@covers
on most tests to get a better view of coveragepsalm.xml
and it passesBonus: It is now possible to extend
Jsor\Doctrine\PostGIS\Types\GeographyType
orJsor\Doctrine\PostGIS\Types\GeometryType
and not have the schema tool throw a tantrum. SeePostGISPlatformTest
Feedback welcome, and I'm happy to add/adjust/drop relevant things.
Edit: Fixes #63