composer update
This commit is contained in:
@@ -1,27 +1,11 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Schema;
|
||||
|
||||
use Doctrine\DBAL\DBALException;
|
||||
use Doctrine\DBAL\Driver\DriverException;
|
||||
use Doctrine\DBAL\Types\Type;
|
||||
use PDOException;
|
||||
use function count;
|
||||
use function in_array;
|
||||
use function preg_replace;
|
||||
@@ -33,13 +17,6 @@ use function trim;
|
||||
|
||||
/**
|
||||
* SQL Server Schema Manager.
|
||||
*
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
* @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
|
||||
* @author Juozas Kaziukenas <juozas@juokaz.com>
|
||||
* @author Steve Müller <st.mueller@dzh-online.de>
|
||||
* @since 2.0
|
||||
*/
|
||||
class SQLServerSchemaManager extends AbstractSchemaManager
|
||||
{
|
||||
@@ -84,19 +61,23 @@ class SQLServerSchemaManager extends AbstractSchemaManager
|
||||
*/
|
||||
protected function _getPortableTableColumnDefinition($tableColumn)
|
||||
{
|
||||
$dbType = strtok($tableColumn['type'], '(), ');
|
||||
$fixed = null;
|
||||
$length = (int) $tableColumn['length'];
|
||||
$dbType = strtok($tableColumn['type'], '(), ');
|
||||
$fixed = null;
|
||||
$length = (int) $tableColumn['length'];
|
||||
$default = $tableColumn['default'];
|
||||
|
||||
if (!isset($tableColumn['name'])) {
|
||||
if (! isset($tableColumn['name'])) {
|
||||
$tableColumn['name'] = '';
|
||||
}
|
||||
|
||||
while ($default != ($default2 = preg_replace("/^\((.*)\)$/", '$1', $default))) {
|
||||
$default = trim($default2, "'");
|
||||
if ($default !== null) {
|
||||
while ($default !== ($default2 = preg_replace('/^\((.*)\)$/', '$1', $default))) {
|
||||
$default = trim($default2, "'");
|
||||
|
||||
if ($default !== 'getdate()') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($default == 'getdate()') {
|
||||
$default = $this->_platform->getCurrentTimestampSQL();
|
||||
}
|
||||
}
|
||||
@@ -106,17 +87,17 @@ class SQLServerSchemaManager extends AbstractSchemaManager
|
||||
case 'nvarchar':
|
||||
case 'ntext':
|
||||
// Unicode data requires 2 bytes per character
|
||||
$length = $length / 2;
|
||||
$length /= 2;
|
||||
break;
|
||||
case 'varchar':
|
||||
// TEXT type is returned as VARCHAR(MAX) with a length of -1
|
||||
if ($length == -1) {
|
||||
if ($length === -1) {
|
||||
$dbType = 'text';
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if ('char' === $dbType || 'nchar' === $dbType || 'binary' === $dbType) {
|
||||
if ($dbType === 'char' || $dbType === 'nchar' || $dbType === 'binary') {
|
||||
$fixed = true;
|
||||
}
|
||||
|
||||
@@ -125,7 +106,7 @@ class SQLServerSchemaManager extends AbstractSchemaManager
|
||||
$tableColumn['comment'] = $this->removeDoctrineTypeFromComment($tableColumn['comment'], $type);
|
||||
|
||||
$options = [
|
||||
'length' => ($length == 0 || !in_array($type, ['text', 'string'])) ? null : $length,
|
||||
'length' => $length === 0 || ! in_array($type, ['text', 'string']) ? null : $length,
|
||||
'unsigned' => false,
|
||||
'fixed' => (bool) $fixed,
|
||||
'default' => $default !== 'NULL' ? $default : null,
|
||||
@@ -153,7 +134,7 @@ class SQLServerSchemaManager extends AbstractSchemaManager
|
||||
$foreignKeys = [];
|
||||
|
||||
foreach ($tableForeignKeys as $tableForeignKey) {
|
||||
if ( ! isset($foreignKeys[$tableForeignKey['ForeignKey']])) {
|
||||
if (! isset($foreignKeys[$tableForeignKey['ForeignKey']])) {
|
||||
$foreignKeys[$tableForeignKey['ForeignKey']] = [
|
||||
'local_columns' => [$tableForeignKey['ColumnName']],
|
||||
'foreign_table' => $tableForeignKey['ReferenceTableName'],
|
||||
@@ -161,11 +142,11 @@ class SQLServerSchemaManager extends AbstractSchemaManager
|
||||
'name' => $tableForeignKey['ForeignKey'],
|
||||
'options' => [
|
||||
'onUpdate' => str_replace('_', ' ', $tableForeignKey['update_referential_action_desc']),
|
||||
'onDelete' => str_replace('_', ' ', $tableForeignKey['delete_referential_action_desc'])
|
||||
]
|
||||
'onDelete' => str_replace('_', ' ', $tableForeignKey['delete_referential_action_desc']),
|
||||
],
|
||||
];
|
||||
} else {
|
||||
$foreignKeys[$tableForeignKey['ForeignKey']]['local_columns'][] = $tableForeignKey['ColumnName'];
|
||||
$foreignKeys[$tableForeignKey['ForeignKey']]['local_columns'][] = $tableForeignKey['ColumnName'];
|
||||
$foreignKeys[$tableForeignKey['ForeignKey']]['foreign_columns'][] = $tableForeignKey['ReferenceColumnName'];
|
||||
}
|
||||
}
|
||||
@@ -176,12 +157,12 @@ class SQLServerSchemaManager extends AbstractSchemaManager
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function _getPortableTableIndexesList($tableIndexRows, $tableName=null)
|
||||
protected function _getPortableTableIndexesList($tableIndexRows, $tableName = null)
|
||||
{
|
||||
foreach ($tableIndexRows as &$tableIndex) {
|
||||
$tableIndex['non_unique'] = (boolean) $tableIndex['non_unique'];
|
||||
$tableIndex['primary'] = (boolean) $tableIndex['primary'];
|
||||
$tableIndex['flags'] = $tableIndex['flags'] ? [$tableIndex['flags']] : null;
|
||||
$tableIndex['non_unique'] = (bool) $tableIndex['non_unique'];
|
||||
$tableIndex['primary'] = (bool) $tableIndex['primary'];
|
||||
$tableIndex['flags'] = $tableIndex['flags'] ? [$tableIndex['flags']] : null;
|
||||
}
|
||||
|
||||
return parent::_getPortableTableIndexesList($tableIndexRows, $tableName);
|
||||
@@ -247,18 +228,18 @@ class SQLServerSchemaManager extends AbstractSchemaManager
|
||||
|
||||
try {
|
||||
$tableIndexes = $this->_conn->fetchAll($sql);
|
||||
} catch (\PDOException $e) {
|
||||
if ($e->getCode() == "IMSSP") {
|
||||
} catch (PDOException $e) {
|
||||
if ($e->getCode() === 'IMSSP') {
|
||||
return [];
|
||||
} else {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
throw $e;
|
||||
} catch (DBALException $e) {
|
||||
if (strpos($e->getMessage(), 'SQLSTATE [01000, 15472]') === 0) {
|
||||
return [];
|
||||
} else {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return $this->_getPortableTableIndexesList($tableIndexes, $table);
|
||||
@@ -273,7 +254,13 @@ class SQLServerSchemaManager extends AbstractSchemaManager
|
||||
foreach ($tableDiff->removedColumns as $col) {
|
||||
$columnConstraintSql = $this->getColumnConstraintSQL($tableDiff->name, $col->getName());
|
||||
foreach ($this->_conn->fetchAll($columnConstraintSql) as $constraint) {
|
||||
$this->_conn->exec("ALTER TABLE $tableDiff->name DROP CONSTRAINT " . $constraint['Name']);
|
||||
$this->_conn->exec(
|
||||
sprintf(
|
||||
'ALTER TABLE %s DROP CONSTRAINT %s',
|
||||
$tableDiff->name,
|
||||
$constraint['Name']
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -296,8 +283,8 @@ class SQLServerSchemaManager extends AbstractSchemaManager
|
||||
ON Tab.[ID] = Sysobjects.[Parent_Obj]
|
||||
INNER JOIN sys.default_constraints DefCons ON DefCons.[object_id] = Sysobjects.[ID]
|
||||
INNER JOIN SysColumns Col ON Col.[ColID] = DefCons.[parent_column_id] AND Col.[ID] = Tab.[ID]
|
||||
WHERE Col.[Name] = " . $this->_conn->quote($column) ." AND Tab.[Name] = " . $this->_conn->quote($table) . "
|
||||
ORDER BY Col.[Name]";
|
||||
WHERE Col.[Name] = " . $this->_conn->quote($column) . ' AND Tab.[Name] = ' . $this->_conn->quote($table) . '
|
||||
ORDER BY Col.[Name]';
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user