-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Introduce table editor #6660
Introduce table editor #6660
Conversation
@@ -12,8 +12,7 @@ interface Name | |||
/** | |||
* Returns the string representation of the name. | |||
* | |||
* The consumers of this method should not rely on a specific return value. It should be used only for diagnostic | |||
* purposes. | |||
* If passed to the corresponding parser, the name should be parsed back to an equivalent object. |
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 contract enables this expression:
Line 867 in 7a25c5d
->setName($this->getObjectName()->toString()) |
public function edit(): TableEditor | ||
{ | ||
return self::editor() | ||
->setName($this->getObjectName()->toString()) |
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.
Even though getObjectName()
can throw NameIsNotInitialized
, this isn't a BC break because Table::edit()
is a new method not called from anywhere. It will be used to rename the table in 5.0.
7a25c5d
to
e51fd97
Compare
Motivation
The introduction of the table editor should facilitate the following improvements:
dbal/src/Schema/Schema.php
Lines 305 to 309 in e7e2615
addColumn()
but the primary key can be set only viasetPrimaryKey()
.Being able to get rid of the hack is why I'm introducing the editor now. I want to start deprecating end removing the name-related properties of
AbstractIdentifier
in favor of the recently introduced value objects, but this hack won't with the new properties because they are private (not protected).Implementation details
The editor (specifically, the class and method naming) is modeled after the table editor in Debezium.
I implemented the necessary minimum of the methods that would allow to rework the hack but then realized that it's a BC break. However, this API allows to replace the direct usage of the Table constructor in the library code with the builder, so I think we can introduce it as is.
I didn't touch the tests because
Additional changes
The first two commits make minor changes in the code that wasn't released yet.