Skip to content

Start migration to TableEditor API - #12523

Open
greg0ire wants to merge 2 commits into
doctrine:3.7.xfrom
greg0ire:track-cols
Open

Start migration to TableEditor API#12523
greg0ire wants to merge 2 commits into
doctrine:3.7.xfrom
greg0ire:track-cols

Conversation

@greg0ire

@greg0ire greg0ire commented Jul 1, 2026

Copy link
Copy Markdown
Member

The TableEditor API has no equivalent for this. Avoiding that call should allow migrating to that API.

@greg0ire
greg0ire marked this pull request as draft July 1, 2026 18:06
@greg0ire greg0ire changed the title Remove call to Table::hasColumn() Start migration to TableEditor API Jul 1, 2026
@greg0ire
greg0ire force-pushed the track-cols branch 2 times, most recently from 89e0f44 to 9dfbf97 Compare July 3, 2026 06:39
Comment thread src/Tools/SchemaTool.php
self::addPrimaryKeyConstraint($table, $pkColumns);
if ($tableOrEditor instanceof TableEditor) {
$tableOrEditor = $tableOrEditor->create();
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is why this PR is called "start migration to TableEditor API"

By making sure I end up with a table beyond this point, I make this big PR hopefully not too big.

@morozov morozov Jul 4, 2026

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 just came here to comment on this block: after it, $tableOrEditor is guaranteed to be a table, so it may be worth assigning the result to Table $table and revert the following changes that replace $table with $tableOrEditor.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Will do, it will be less confusing.

Comment thread src/Tools/SchemaTool.php

foreach ($platformOptions as $key => $value) {
if (! in_array($key, $knownPlatformOptions, true)) {
$column->setPlatformOption($key, $value);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@morozov do you think this is useful? If not, should the deprecation message be improved to indicate that calling that method with e.g. foo achieves nothing and will cause an error in 5.0.x? I'm asking because ORM has a test ensuring foo is preserved:

public function testAttributeOptionsArgument(): void
{
$em = $this->getTestEntityManager();
$schemaTool = new SchemaTool($em);
$schema = $schemaTool->getSchemaFromMetadata(
[$em->getClassMetadata(TestEntityWithAttributeOptionsArgument::class)],
);
$table = $schema->getTable('TestEntityWithAttributeOptionsArgument');
foreach ([$table->getOptions(), $table->getColumn('test')->getPlatformOptions()] as $options) {
self::assertArrayHasKey('foo', $options);
self::assertSame('bar', $options['foo']);
self::assertArrayHasKey('baz', $options);
self::assertSame(['key' => 'val'], $options['baz']);
}
}

I'm wondering if I should remove this piece of code entirely, or trigger a deprecation if we enter it.

@morozov morozov Jul 4, 2026

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.

@morozov do you think this is useful?

In theory it may be useful: someone may have a custom platform with an option not known to the ORM. In practice, I don't think so.

If not, should the deprecation message be improved to indicate that calling that method with e.g. foo achieves nothing and will cause an error in 5.0.x?

I'm not following. The entire Column::setPlatformOption() is deprecated and will be removed in 5.0.x for exactly that reason: ColumnEditor provides a well-typed API for supported parameters.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Oh so right now, it might achieve something, but in the future, you won't even be able to call it with foo.

Comment thread src/Tools/SchemaTool.php Outdated
@greg0ire
greg0ire marked this pull request as ready for review July 3, 2026 20:19
Comment thread src/Tools/SchemaTool.php Outdated
Comment thread src/Tools/SchemaTool.php Outdated
@morozov

morozov commented Jul 4, 2026

Copy link
Copy Markdown
Member

The change looks directionally right (I've only reviewed half the PR, and mostly found just nits).

For the issues raised in the comments above, I'd step back and look at the code in question in isolation from the migration to editors, to see if the code itself looks sane (in the two cases above, it doesn't). Then I'd address those issues separately and get back to the migration — this is the process I've been following during the API rework in DBAL itself.

The TableEditor API has no equivalent for this. Avoiding that call
should allow migrating to that API.
@greg0ire
greg0ire force-pushed the track-cols branch 2 times, most recently from 01cc480 to 42c9d12 Compare August 6, 2026 07:45
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