Remove support for passing assets as names #4797
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
The current Platform and Schema APIs allow passing object names as strings or as objects themselves (sub-classes of
Asset
). For instance, in order to drop a table, the caller can pass the table name or theTable
object.While it may look handly from the API consumer perspective, it violates the Interface Segregation Principle. In the example above, the
getDropTableSQL()
method has to support accepting an object although it only needs the name of the object.Another problem is that this API is prone to being implemented inconsistently depending on the type of the actually passed argument. For instance:
ALTER TABLE tbl DROP PRIMARY KEY
only if the index is passed as an object since the information about whether the given index is the PK or not isn't encoded in the index name:dbal/src/Platforms/MySQLPlatform.php
Lines 897 to 901 in 27c26d2
Table
class will validate the columns of the foreign key against the referenced table only if the referenced table name is passed as an asset:dbal/src/Schema/Table.php
Lines 354 to 360 in f83121f
Another practical problem is that it cripples the Events API:
dbal/src/Event/SchemaDropTableEventArgs.php
Lines 34 to 37 in dc4ad2a
The consumer of the
SchemaDropTableEventArgs
class has to support receiving the table name expressed as either of thestring
andTable
.As part of prototyping #4772, I'd like to convert all
string $name
arguments intoName $name
. This is where the need to drop the support forAsset|string
arguments arose.TODO:
The deprecation should happen after the
Name
-based API is implemented or before 4.0.x is released (whatever happens first).