dbal icon indicating copy to clipboard operation
dbal copied to clipboard

Add explicit renameColumn method (4.x)

Open Tofandel opened this issue 1 year ago • 7 comments

Merges the changes of #6080 into 4.0.x

Tofandel avatar Jan 26 '24 13:01 Tofandel

Since we've reverted the feature, this is technically not a merge anymore. I've adjusted the PR title accordingly. Can you please rebase your changes onto 4.0.x? Currently the PR contains irrelevant changes that 4.0.x contains already.

derrabus avatar Jan 26 '24 15:01 derrabus

Hmmm, 4.0.x was released already? I though you would wait for this PR on both 3.9 and 4.0

Then this PR which includes breaking changes which were meant to be deprecated in 3.x cannot be released anymore in 4.x from my understanding and only in 5.x and the PR #6080 without the breaking changes need to be redone for 4.x?

This is way more work than I can put into this ATM

Tofandel avatar Feb 21 '24 15:02 Tofandel

Hmmm, 4.0.x was released already? I though you would wait for this PR on both 3.9 and 4.0

Sorry we didn't warn you about it, we had a lot on our plate and this apparently fell through the cracks.

Then this PR which includes breaking changes which were meant to be deprecated in 3.x cannot be released anymore in 4.x from my understanding and only in 5.x and the PR https://github.com/doctrine/dbal/pull/6080 without the breaking changes need to be redone for 4.x?

Yes, exactly. There is very little difference between 5.0.x and 4.1.x right now, so the most convenient time to do it is now. I think what you can do is:

  • retarget this to 5.0.x, which shouldn't be very hard because of how little conflicts there should be
  • open another PR that is a revert of @derrabus 's revert. I don't expect that to be a lot of work either.

greg0ire avatar Feb 21 '24 16:02 greg0ire

Should the revert be for 3.9 or 4.1 ?

If it's for 4.x we still have the same problem with tons of conflict with v4 so it's easier to start from this PR and simply revert the breaking changes using the old PR

I could open 3 PRs, one against 3.9 again without breaking change which is basically the old reverted PR, 4.1 which is this port still but without breaking changes and 5.0.x which is this PR

Tofandel avatar Feb 21 '24 17:02 Tofandel

Sorry, I'm kinda busy right now, but I haven forgotten this PR. Promise!

  • 4.1.x is the target for this PR.
  • I can revert my revert on 3.9 myself when I merge this one. Don't worry.
  • Breaking changes will need to go into 5.x.

derrabus avatar Feb 21 '24 18:02 derrabus

There hasn't been any activity on this pull request in the past 90 days, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 7 days. If you want to continue working on it, please leave a comment.

github-actions[bot] avatar May 22 '24 03:05 github-actions[bot]

And that's my fault, dear bot. Let's keep it open.

derrabus avatar May 22 '24 05:05 derrabus

Let's ship this. Apologies for this really way too long delay.

I decided that we will ship this feature with 4.1.0 only, without a backport to 3.x. Because we're very low on maintainers on this repository, I'd like to keep DBAL 3 super-stable which means we're not shipping new features on that branch. I hope this is okay for you.

derrabus avatar Aug 02 '24 09:08 derrabus

No problem with me, I'm also very busy and didn't have time to review this to make a PR for v4 and v5, though I do believe there were a few minor breaking changes in this PR (I think only in TableDiff, 2 methods removed) which might need a compatibility layer for v4 which is what I didn't have time to check but I already made it in the previous PR for v3 so it might just be a question of taking those 2 methods from the old PR and remove them in v5

Tofandel avatar Aug 02 '24 09:08 Tofandel

Here I took the code from the old PR and adapted it for v4

    /**
     * @deprecated Use {@see getChangedColumns()} instead.
     *
     * @return list<ColumnDiff>
     */
    public function getModifiedColumns(): array
    {
        Deprecation::triggerIfCalledFromOutside(
            'doctrine/dbal',
            'https://github.com/doctrine/dbal/pull/6280',
            '%s is deprecated, use `getChangedColumns()` instead.',
            __METHOD__,
        );

        return array_values(array_filter($this->getChangedColumns(), static function (ColumnDiff $diff) {
            return $diff->countChangedProperties() > ($diff->hasNameChanged() ? 1 : 0);
        }));
    }
    
    
    /**
     * @deprecated Use {@see getChangedColumns()} instead.
     *
     * @return array<string,Column>
     */
    public function getRenamedColumns(): array
    {
        Deprecation::triggerIfCalledFromOutside(
            'doctrine/dbal',
            'https://github.com/doctrine/dbal/pull/6280',
            '%s is deprecated, you should use `getChangedColumns()` instead.',
            __METHOD__,
        );
        $renamed = [];
        foreach ($this->getChangedColumns() as $diff) {
            if (! $diff->hasNameChanged()) {
                continue;
            }

            $oldColumnName           = $diff->getOldColumn()->getName();
            $renamed[$oldColumnName] = $diff->getNewColumn();
        }

        return $renamed;
    }

Tofandel avatar Aug 02 '24 09:08 Tofandel

Right, we're missing the deprecation layer now. Let me check if I can add it.

derrabus avatar Aug 02 '24 11:08 derrabus

See #6482

derrabus avatar Aug 02 '24 11:08 derrabus