From 2a9b988750cafad83d6cf21a8a776ff8a236faac Mon Sep 17 00:00:00 2001 From: Thomas Dion Date: Wed, 13 Mar 2024 12:31:18 +0100 Subject: [PATCH 1/3] [1.x] Use platform options instead of deprecated custom schema options --- src/Event/ORMSchemaEventSubscriber.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Event/ORMSchemaEventSubscriber.php b/src/Event/ORMSchemaEventSubscriber.php index acb83d9e..2d9db92d 100644 --- a/src/Event/ORMSchemaEventSubscriber.php +++ b/src/Event/ORMSchemaEventSubscriber.php @@ -27,11 +27,11 @@ public function postGenerateSchemaTable(GenerateSchemaTableEventArgs $args) } $normalized = $column->getType()->getNormalizedPostGISColumnOptions( - $column->getCustomSchemaOptions() + $column->getPlatformOptions() ); foreach ($normalized as $name => $value) { - $column->setCustomSchemaOption($name, $value); + $column->setPlatformOption($name, $value); } } From c87a15a856fd6298cb8dd8183fc6af394a48d2fa Mon Sep 17 00:00:00 2001 From: Thomas Dion Date: Wed, 13 Mar 2024 12:38:25 +0100 Subject: [PATCH 2/3] [1.x] Replace all calls to deprecated custom schema option methods --- src/Event/DBALSchemaEventSubscriber.php | 8 +-- tests/Event/DBALSchemaEventSubscriberTest.php | 60 +++++++++---------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/Event/DBALSchemaEventSubscriber.php b/src/Event/DBALSchemaEventSubscriber.php index 30202f2e..3e2c1495 100644 --- a/src/Event/DBALSchemaEventSubscriber.php +++ b/src/Event/DBALSchemaEventSubscriber.php @@ -253,7 +253,7 @@ public function onSchemaAlterTableChangeColumn(SchemaAlterTableChangeColumnEvent } if ($columnDiff->hasChanged('geometry_type')) { - throw new \RuntimeException('The geometry_type of a spatial column cannot be changed (Requested changing type from "' . strtoupper($columnDiff->fromColumn->getCustomSchemaOption('geometry_type')) . '" to "' . strtoupper($column->getCustomSchemaOption('geometry_type')) . '" for column "' . $column->getName() . '" in table "' . $table->getName() . '")'); + throw new \RuntimeException('The geometry_type of a spatial column cannot be changed (Requested changing type from "' . strtoupper($columnDiff->fromColumn->getPlatformOption('geometry_type')) . '" to "' . strtoupper($column->getPlatformOption('geometry_type')) . '" for column "' . $column->getName() . '" in table "' . $table->getName() . '")'); } if ($columnDiff->hasChanged('srid')) { @@ -261,7 +261,7 @@ public function onSchemaAlterTableChangeColumn(SchemaAlterTableChangeColumnEvent "SELECT UpdateGeometrySRID('%s', '%s', %d)", $table->getName(), $column->getName(), - $column->getCustomSchemaOption('srid') + $column->getPlatformOption('srid') )); } } @@ -315,8 +315,8 @@ public function onSchemaColumnDefinition(SchemaColumnDefinitionEventArgs $args) $column = new Column($tableColumn['field'], PostGISType::getType($tableColumn['type']), $options); $column - ->setCustomSchemaOption('geometry_type', $info['type']) - ->setCustomSchemaOption('srid', $info['srid']) + ->setPlatformOption('geometry_type', $info['type']) + ->setPlatformOption('srid', $info['srid']) ; $args diff --git a/tests/Event/DBALSchemaEventSubscriberTest.php b/tests/Event/DBALSchemaEventSubscriberTest.php index 98190af1..4b6196cb 100644 --- a/tests/Event/DBALSchemaEventSubscriberTest.php +++ b/tests/Event/DBALSchemaEventSubscriberTest.php @@ -39,67 +39,67 @@ protected function createTableSchema() $table->addColumn('tsvector', 'tsvector', ['notnull' => true]); $table->addColumn('geometry', 'geometry', ['notnull' => true]) - ->setCustomSchemaOptions([ + ->setPlatformOptions([ 'geometry_type' => 'GEOMETRY', 'srid' => 0, ]); $table->addColumn('point', 'geometry', ['notnull' => true]) - ->setCustomSchemaOptions([ + ->setPlatformOptions([ 'geometry_type' => 'POINT', 'srid' => 0, ]); $table->addColumn('point_2d', 'geometry', ['notnull' => true]) - ->setCustomSchemaOptions([ + ->setPlatformOptions([ 'geometry_type' => 'POINT', 'srid' => 3785, ]); $table->addColumn('point_3dz', 'geometry', ['notnull' => true]) - ->setCustomSchemaOptions([ + ->setPlatformOptions([ 'geometry_type' => 'POINTZ', 'srid' => 3785, ]); $table->addColumn('point_3dm', 'geometry', ['notnull' => true]) - ->setCustomSchemaOptions([ + ->setPlatformOptions([ 'geometry_type' => 'POINTM', 'srid' => 3785, ]); $table->addColumn('point_4d', 'geometry', ['notnull' => true]) - ->setCustomSchemaOptions([ + ->setPlatformOptions([ 'geometry_type' => 'POINTZM', 'srid' => 3785, ]); $table->addColumn('point_2d_nullable', 'geometry', ['notnull' => false]) - ->setCustomSchemaOptions([ + ->setPlatformOptions([ 'geometry_type' => 'POINT', 'srid' => 3785, ]); $table->addColumn('point_2d_nosrid', 'geometry', ['notnull' => true]) - ->setCustomSchemaOptions([ + ->setPlatformOptions([ 'geometry_type' => 'POINT', 'srid' => 0, ]); $table->addColumn('geography', 'geography', ['notnull' => true]) - ->setCustomSchemaOptions([ + ->setPlatformOptions([ 'geometry_type' => 'GEOMETRY', 'srid' => 4326, ]); $table->addColumn('point_geography_2d', 'geography', ['notnull' => true]) - ->setCustomSchemaOptions([ + ->setPlatformOptions([ 'geometry_type' => 'POINT', 'srid' => 4326, ]); $table->addColumn('point_geography_2d_srid', 'geography', ['notnull' => true]) - ->setCustomSchemaOptions([ + ->setPlatformOptions([ 'geometry_type' => 'POINT', 'srid' => 4326, ]); @@ -174,8 +174,8 @@ public function testListTableColumns() $this->assertEquals(null, $columns['point']->getDefault()); $this->assertInternalType('array', $columns['point']->getPlatformOptions()); - $this->assertEquals('POINT', $columns['point']->getCustomSchemaOption('geometry_type')); - $this->assertEquals(0, $columns['point']->getCustomSchemaOption('srid')); + $this->assertEquals('POINT', $columns['point']->getPlatformOption('geometry_type')); + $this->assertEquals(0, $columns['point']->getPlatformOption('srid')); // --- @@ -187,8 +187,8 @@ public function testListTableColumns() $this->assertEquals(null, $columns['point_2d']->getDefault()); $this->assertInternalType('array', $columns['point_2d']->getPlatformOptions()); - $this->assertEquals('POINT', $columns['point_2d']->getCustomSchemaOption('geometry_type')); - $this->assertEquals(3785, $columns['point_2d']->getCustomSchemaOption('srid')); + $this->assertEquals('POINT', $columns['point_2d']->getPlatformOption('geometry_type')); + $this->assertEquals(3785, $columns['point_2d']->getPlatformOption('srid')); // --- @@ -200,8 +200,8 @@ public function testListTableColumns() $this->assertEquals(null, $columns['point_3dz']->getDefault()); $this->assertInternalType('array', $columns['point_3dz']->getPlatformOptions()); - $this->assertEquals('POINTZ', $columns['point_3dz']->getCustomSchemaOption('geometry_type')); - $this->assertEquals(3785, $columns['point_3dz']->getCustomSchemaOption('srid')); + $this->assertEquals('POINTZ', $columns['point_3dz']->getPlatformOption('geometry_type')); + $this->assertEquals(3785, $columns['point_3dz']->getPlatformOption('srid')); // --- @@ -213,8 +213,8 @@ public function testListTableColumns() $this->assertEquals(null, $columns['point_3dm']->getDefault()); $this->assertInternalType('array', $columns['point_3dm']->getPlatformOptions()); - $this->assertEquals('POINTM', $columns['point_3dm']->getCustomSchemaOption('geometry_type')); - $this->assertEquals(3785, $columns['point_3dm']->getCustomSchemaOption('srid')); + $this->assertEquals('POINTM', $columns['point_3dm']->getPlatformOption('geometry_type')); + $this->assertEquals(3785, $columns['point_3dm']->getPlatformOption('srid')); // --- @@ -226,8 +226,8 @@ public function testListTableColumns() $this->assertEquals(null, $columns['point_4d']->getDefault()); $this->assertInternalType('array', $columns['point_4d']->getPlatformOptions()); - $this->assertEquals('POINTZM', $columns['point_4d']->getCustomSchemaOption('geometry_type')); - $this->assertEquals(3785, $columns['point_4d']->getCustomSchemaOption('srid')); + $this->assertEquals('POINTZM', $columns['point_4d']->getPlatformOption('geometry_type')); + $this->assertEquals(3785, $columns['point_4d']->getPlatformOption('srid')); // --- @@ -239,8 +239,8 @@ public function testListTableColumns() //$this->assertEquals('NULL::geometry', $columns['point_2d_nullable']->getDefault()); $this->assertInternalType('array', $columns['point_2d_nullable']->getPlatformOptions()); - $this->assertEquals('POINT', $columns['point_2d_nullable']->getCustomSchemaOption('geometry_type')); - $this->assertEquals(3785, $columns['point_2d_nullable']->getCustomSchemaOption('srid')); + $this->assertEquals('POINT', $columns['point_2d_nullable']->getPlatformOption('geometry_type')); + $this->assertEquals(3785, $columns['point_2d_nullable']->getPlatformOption('srid')); // --- @@ -252,8 +252,8 @@ public function testListTableColumns() $this->assertEquals(null, $columns['point_2d_nosrid']->getDefault()); $this->assertInternalType('array', $columns['point_2d_nosrid']->getPlatformOptions()); - $this->assertEquals('POINT', $columns['point_2d_nosrid']->getCustomSchemaOption('geometry_type')); - $this->assertEquals(0, $columns['point_2d_nosrid']->getCustomSchemaOption('srid')); + $this->assertEquals('POINT', $columns['point_2d_nosrid']->getPlatformOption('geometry_type')); + $this->assertEquals(0, $columns['point_2d_nosrid']->getPlatformOption('srid')); // --- @@ -265,8 +265,8 @@ public function testListTableColumns() $this->assertEquals(null, $columns['point_geography_2d']->getDefault()); $this->assertInternalType('array', $columns['point_geography_2d']->getPlatformOptions()); - $this->assertEquals('POINT', $columns['point_geography_2d']->getCustomSchemaOption('geometry_type')); - $this->assertEquals(4326, $columns['point_geography_2d']->getCustomSchemaOption('srid')); + $this->assertEquals('POINT', $columns['point_geography_2d']->getPlatformOption('geometry_type')); + $this->assertEquals(4326, $columns['point_geography_2d']->getPlatformOption('srid')); // --- @@ -278,8 +278,8 @@ public function testListTableColumns() $this->assertEquals(null, $columns['point_geography_2d_srid']->getDefault()); $this->assertInternalType('array', $columns['point_geography_2d_srid']->getPlatformOptions()); - $this->assertEquals('POINT', $columns['point_geography_2d_srid']->getCustomSchemaOption('geometry_type')); - $this->assertEquals(4326, $columns['point_geography_2d_srid']->getCustomSchemaOption('srid')); + $this->assertEquals('POINT', $columns['point_geography_2d_srid']->getPlatformOption('geometry_type')); + $this->assertEquals(4326, $columns['point_geography_2d_srid']->getPlatformOption('srid')); } public function testDiffListTableColumns() @@ -445,7 +445,7 @@ public function testAlterTableScenario() $table = $this->sm->listTableDetails('points'); $this->assertFalse($table->hasColumn('point')); $this->assertTrue($table->hasColumn('linestring')); - $this->assertEquals(4326, $table->getColumn('point_3dm')->getCustomSchemaOption('srid')); + $this->assertEquals(4326, $table->getColumn('point_3dm')->getPlatformOption('srid')); $tableDiff = new \Doctrine\DBAL\Schema\TableDiff('points'); $tableDiff->fromTable = $table; From b177c7065704f1efd44a8366eda083c7ba11c05d Mon Sep 17 00:00:00 2001 From: Thomas Dion Date: Wed, 13 Mar 2024 12:39:28 +0100 Subject: [PATCH 3/3] [1.x] Update test setup --- tests/Event/DBALSchemaEventSubscriberTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Event/DBALSchemaEventSubscriberTest.php b/tests/Event/DBALSchemaEventSubscriberTest.php index 4b6196cb..2fc12fc1 100644 --- a/tests/Event/DBALSchemaEventSubscriberTest.php +++ b/tests/Event/DBALSchemaEventSubscriberTest.php @@ -436,9 +436,9 @@ public function testAlterTableScenario() $tableDiff = new \Doctrine\DBAL\Schema\TableDiff('points'); $tableDiff->fromTable = $table; - $tableDiff->addedColumns['linestring'] = new \Doctrine\DBAL\Schema\Column('linestring', Type::getType('geometry'), ['customSchemaOptions' => ['geometry_type' => 'linestring', 'srid' => 3785]]); + $tableDiff->addedColumns['linestring'] = new \Doctrine\DBAL\Schema\Column('linestring', Type::getType('geometry'), ['platformOptions' => ['geometry_type' => 'linestring', 'srid' => 3785]]); $tableDiff->removedColumns['point'] = $table->getColumn('point'); - $tableDiff->changedColumns[] = new ColumnDiff('point_3dm', new \Doctrine\DBAL\Schema\Column('point_3dm', Type::getType('geometry'), ['customSchemaOptions' => ['srid' => 4326]]), ['srid'], $table->getColumn('point_3dm')); + $tableDiff->changedColumns[] = new ColumnDiff('point_3dm', new \Doctrine\DBAL\Schema\Column('point_3dm', Type::getType('geometry'), ['platformOptions' => ['srid' => 4326]]), ['srid'], $table->getColumn('point_3dm')); $this->sm->alterTable($tableDiff); @@ -507,7 +507,7 @@ public function testAlterTableThrowsExceptionForChangedSpatialType() $tableDiff = new \Doctrine\DBAL\Schema\TableDiff('points'); $tableDiff->fromTable = $table; - $tableDiff->changedColumns[] = new ColumnDiff('point_2d', new \Doctrine\DBAL\Schema\Column('point_2d', Type::getType('geometry'), ['customSchemaOptions' => ['geometry_type' => 'LINESTRING']]), ['geometry_type'], $table->getColumn('point_2d')); + $tableDiff->changedColumns[] = new ColumnDiff('point_2d', new \Doctrine\DBAL\Schema\Column('point_2d', Type::getType('geometry'), ['platformOptions' => ['geometry_type' => 'LINESTRING']]), ['geometry_type'], $table->getColumn('point_2d')); $this->sm->alterTable($tableDiff); }