This repository has been archived by the owner on Jan 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 122
Fix AlterTable::dropConstraint() by allowing the use of decorator #247
Open
nanawel
wants to merge
10
commits into
zendframework:develop
Choose a base branch
from
nanawel:fix-mysql-drop-constraint
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+97
−14
Open
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
bfb73c8
Fix AlterTable::dropConstraint() by allowing the use of decorator (br…
nanawel e692ebc
Update doc
nanawel 529293a
Adaptation to support both \Zend\Db\Sql\Ddl\Constraint\ConstraintInte…
nanawel cd5a061
Remove unused use
nanawel f287cf2
Remove unused use
nanawel 471667f
Merge remote-tracking branch 'zend/develop' into fix-mysql-drop-const…
nanawel 308ac7b
Fix PHPCS error
nanawel 9ae5516
Fix PHPCS warning
nanawel 1d0432a
Merge remote-tracking branch 'zend/develop' into fix-mysql-drop-const…
nanawel 07419e8
Merge to match code style
nanawel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
namespace Zend\Db\Sql\Ddl; | ||
|
||
use Zend\Db\Adapter\Platform\PlatformInterface; | ||
use Zend\Db\Metadata\Object\ConstraintObject; | ||
use Zend\Db\Sql\AbstractSql; | ||
|
||
class AlterTable extends AbstractSql implements SqlInterface | ||
|
@@ -27,7 +28,7 @@ class AlterTable extends AbstractSql implements SqlInterface | |
protected $addColumns = []; | ||
|
||
/** | ||
* @var array | ||
* @var Constraint\ConstraintInterface[] | ||
*/ | ||
protected $addConstraints = []; | ||
|
||
|
@@ -42,7 +43,7 @@ class AlterTable extends AbstractSql implements SqlInterface | |
protected $dropColumns = []; | ||
|
||
/** | ||
* @var array | ||
* @var ConstraintObject[] | ||
*/ | ||
protected $dropConstraints = []; | ||
|
||
|
@@ -74,7 +75,7 @@ class AlterTable extends AbstractSql implements SqlInterface | |
], | ||
self::DROP_CONSTRAINTS => [ | ||
"%1\$s" => [ | ||
[1 => "DROP CONSTRAINT %1\$s,\n", 'combinedby' => ""], | ||
[2 => "DROP %1\$s %2\$s,\n", 'combinedby' => ""], | ||
] | ||
] | ||
]; | ||
|
@@ -138,12 +139,12 @@ public function dropColumn($name) | |
} | ||
|
||
/** | ||
* @param string $name | ||
* @param ConstraintObject $constraint | ||
* @return self Provides a fluent interface | ||
*/ | ||
public function dropConstraint($name) | ||
public function dropConstraint(ConstraintObject $constraint) | ||
{ | ||
$this->dropConstraints[] = $name; | ||
$this->dropConstraints[] = $constraint; | ||
|
||
return $this; | ||
} | ||
|
@@ -229,7 +230,10 @@ protected function processDropConstraints(PlatformInterface $adapterPlatform = n | |
{ | ||
$sqls = []; | ||
foreach ($this->dropConstraints as $constraint) { | ||
$sqls[] = $adapterPlatform->quoteIdentifier($constraint); | ||
$sqls[] = [ | ||
'CONSTRAINT', | ||
$adapterPlatform->quoteIdentifier($constraint->getName()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Until this #233 goes through that fixes bugs in quoteIdentifier vs quoteIdentifierChain this will break PostgreSQL and MSSQL. If lucky and that PR gets merged prior to this, then its fine. |
||
]; | ||
} | ||
|
||
return [$sqls]; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -248,4 +248,17 @@ private function compareColumnOptions($columnA, $columnB) | |
|
||
return $columnA - $columnB; | ||
} | ||
|
||
protected function processDropConstraints(PlatformInterface $adapterPlatform = null) | ||
{ | ||
$sqls = []; | ||
foreach ($this->dropConstraints as $constraint) { | ||
$sqls[] = [ | ||
$constraint->getType(), | ||
$adapterPlatform->quoteIdentifier($constraint->getName()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As above |
||
]; | ||
} | ||
|
||
return [$sqls]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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.
Do not modify generic syntax from abstract classes other adapters inherit from for engine specific fixes. Fixing one engine breaks assumptions of others within this library or others making custom adapters.