Replace $field, $columnDef and other names with $column across the codebaase

parent 9ea5574e
......@@ -179,7 +179,7 @@ class MysqliStatement implements IteratorAggregate, Statement
// Bind row values _after_ storing the result. Otherwise, if mysqli is compiled with libmysql,
// it will have to allocate as much memory as it may be needed for the given column type
// (e.g. for a LONGBLOB field it's 4 gigabytes)
// (e.g. for a LONGBLOB column it's 4 gigabytes)
// @link https://bugs.php.net/bug.php?id=51386#1270673122
//
// Make sure that the values are bound after each execution. Otherwise, if closeCursor() has been
......
......@@ -47,22 +47,22 @@ class DB2Platform extends AbstractPlatform
/**
* {@inheritDoc}
*/
public function getVarcharTypeDeclarationSQL(array $field)
public function getVarcharTypeDeclarationSQL(array $column)
{
// for IBM DB2, the CHAR max length is less than VARCHAR default length
if (! isset($field['length']) && ! empty($field['fixed'])) {
$field['length'] = $this->getCharMaxLength();
if (! isset($column['length']) && ! empty($column['fixed'])) {
$column['length'] = $this->getCharMaxLength();
}
return parent::getVarcharTypeDeclarationSQL($field);
return parent::getVarcharTypeDeclarationSQL($column);
}
/**
* {@inheritDoc}
*/
public function getBlobTypeDeclarationSQL(array $field)
public function getBlobTypeDeclarationSQL(array $column)
{
// todo blob(n) with $field['length'];
// todo blob(n) with $column['length'];
return 'BLOB(1M)';
}
......@@ -124,9 +124,9 @@ class DB2Platform extends AbstractPlatform
/**
* {@inheritDoc}
*/
public function getClobTypeDeclarationSQL(array $field)
public function getClobTypeDeclarationSQL(array $column)
{
// todo clob(n) with $field['length'];
// todo clob(n) with $column['length'];
return 'CLOB(1M)';
}
......@@ -141,7 +141,7 @@ class DB2Platform extends AbstractPlatform
/**
* {@inheritDoc}
*/
public function getBooleanTypeDeclarationSQL(array $columnDef)
public function getBooleanTypeDeclarationSQL(array $column)
{
return 'SMALLINT';
}
......@@ -149,34 +149,34 @@ class DB2Platform extends AbstractPlatform
/**
* {@inheritDoc}
*/
public function getIntegerTypeDeclarationSQL(array $columnDef)
public function getIntegerTypeDeclarationSQL(array $column)
{
return 'INTEGER' . $this->_getCommonIntegerTypeDeclarationSQL($columnDef);
return 'INTEGER' . $this->_getCommonIntegerTypeDeclarationSQL($column);
}
/**
* {@inheritDoc}
*/
public function getBigIntTypeDeclarationSQL(array $columnDef)
public function getBigIntTypeDeclarationSQL(array $column)
{
return 'BIGINT' . $this->_getCommonIntegerTypeDeclarationSQL($columnDef);
return 'BIGINT' . $this->_getCommonIntegerTypeDeclarationSQL($column);
}
/**
* {@inheritDoc}
*/
public function getSmallIntTypeDeclarationSQL(array $columnDef)
public function getSmallIntTypeDeclarationSQL(array $column)
{
return 'SMALLINT' . $this->_getCommonIntegerTypeDeclarationSQL($columnDef);
return 'SMALLINT' . $this->_getCommonIntegerTypeDeclarationSQL($column);
}
/**
* {@inheritDoc}
*/
protected function _getCommonIntegerTypeDeclarationSQL(array $columnDef)
protected function _getCommonIntegerTypeDeclarationSQL(array $column)
{
$autoinc = '';
if (! empty($columnDef['autoincrement'])) {
if (! empty($column['autoincrement'])) {
$autoinc = ' GENERATED BY DEFAULT AS IDENTITY';
}
......@@ -230,9 +230,9 @@ class DB2Platform extends AbstractPlatform
/**
* {@inheritDoc}
*/
public function getDateTimeTypeDeclarationSQL(array $fieldDeclaration)
public function getDateTimeTypeDeclarationSQL(array $column)
{
if (isset($fieldDeclaration['version']) && $fieldDeclaration['version'] === true) {
if (isset($column['version']) && $column['version'] === true) {
return 'TIMESTAMP(0) WITH DEFAULT';
}
......@@ -242,7 +242,7 @@ class DB2Platform extends AbstractPlatform
/**
* {@inheritDoc}
*/
public function getDateTypeDeclarationSQL(array $fieldDeclaration)
public function getDateTypeDeclarationSQL(array $column)
{
return 'DATE';
}
......@@ -250,7 +250,7 @@ class DB2Platform extends AbstractPlatform
/**
* {@inheritDoc}
*/
public function getTimeTypeDeclarationSQL(array $fieldDeclaration)
public function getTimeTypeDeclarationSQL(array $column)
{
return 'TIME';
}
......@@ -750,19 +750,19 @@ class DB2Platform extends AbstractPlatform
/**
* {@inheritDoc}
*/
public function getDefaultValueDeclarationSQL($field)
public function getDefaultValueDeclarationSQL($column)
{
if (! empty($field['autoincrement'])) {
if (! empty($column['autoincrement'])) {
return '';
}
if (isset($field['version']) && $field['version']) {
if ((string) $field['type'] !== 'DateTime') {
$field['default'] = '1';
if (isset($column['version']) && $column['version']) {
if ((string) $column['type'] !== 'DateTime') {
$column['default'] = '1';
}
}
return parent::getDefaultValueDeclarationSQL($field);
return parent::getDefaultValueDeclarationSQL($column);
}
/**
......
......@@ -72,7 +72,7 @@ class DrizzlePlatform extends AbstractPlatform
/**
* {@inheritDoc}
*/
public function getBooleanTypeDeclarationSQL(array $field)
public function getBooleanTypeDeclarationSQL(array $column)
{
return 'BOOLEAN';
}
......@@ -80,18 +80,18 @@ class DrizzlePlatform extends AbstractPlatform
/**
* {@inheritDoc}
*/
public function getIntegerTypeDeclarationSQL(array $field)
public function getIntegerTypeDeclarationSQL(array $column)
{
return 'INT' . $this->_getCommonIntegerTypeDeclarationSQL($field);
return 'INT' . $this->_getCommonIntegerTypeDeclarationSQL($column);
}
/**
* {@inheritDoc}
*/
protected function _getCommonIntegerTypeDeclarationSQL(array $columnDef)
protected function _getCommonIntegerTypeDeclarationSQL(array $column)
{
$autoinc = '';
if (! empty($columnDef['autoincrement'])) {
if (! empty($column['autoincrement'])) {
$autoinc = ' AUTO_INCREMENT';
}
......@@ -101,17 +101,17 @@ class DrizzlePlatform extends AbstractPlatform
/**
* {@inheritDoc}
*/
public function getBigIntTypeDeclarationSQL(array $field)
public function getBigIntTypeDeclarationSQL(array $column)
{
return 'BIGINT' . $this->_getCommonIntegerTypeDeclarationSQL($field);
return 'BIGINT' . $this->_getCommonIntegerTypeDeclarationSQL($column);
}
/**
* {@inheritDoc}
*/
public function getSmallIntTypeDeclarationSQL(array $field)
public function getSmallIntTypeDeclarationSQL(array $column)
{
return 'INT' . $this->_getCommonIntegerTypeDeclarationSQL($field);
return 'INT' . $this->_getCommonIntegerTypeDeclarationSQL($column);
}
/**
......@@ -155,7 +155,7 @@ class DrizzlePlatform extends AbstractPlatform
/**
* {@inheritDoc}
*/
public function getClobTypeDeclarationSQL(array $field)
public function getClobTypeDeclarationSQL(array $column)
{
return 'TEXT';
}
......@@ -163,7 +163,7 @@ class DrizzlePlatform extends AbstractPlatform
/**
* {@inheritDoc}
*/
public function getBlobTypeDeclarationSQL(array $field)
public function getBlobTypeDeclarationSQL(array $column)
{
return 'BLOB';
}
......@@ -451,9 +451,9 @@ class DrizzlePlatform extends AbstractPlatform
/**
* {@inheritDoc}
*/
public function getDateTimeTypeDeclarationSQL(array $fieldDeclaration)
public function getDateTimeTypeDeclarationSQL(array $column)
{
if (isset($fieldDeclaration['version']) && $fieldDeclaration['version'] === true) {
if (isset($column['version']) && $column['version'] === true) {
return 'TIMESTAMP';
}
......@@ -463,7 +463,7 @@ class DrizzlePlatform extends AbstractPlatform
/**
* {@inheritDoc}
*/
public function getTimeTypeDeclarationSQL(array $fieldDeclaration)
public function getTimeTypeDeclarationSQL(array $column)
{
return 'TIME';
}
......@@ -471,7 +471,7 @@ class DrizzlePlatform extends AbstractPlatform
/**
* {@inheritDoc}
*/
public function getDateTypeDeclarationSQL(array $fieldDeclaration)
public function getDateTypeDeclarationSQL(array $column)
{
return 'DATE';
}
......
......@@ -16,7 +16,7 @@ final class MariaDb1027Platform extends MySqlPlatform
*
* @link https://mariadb.com/kb/en/library/json-data-type/
*/
public function getJsonTypeDeclarationSQL(array $field): string
public function getJsonTypeDeclarationSQL(array $column): string
{
return 'LONGTEXT';
}
......
......@@ -22,7 +22,7 @@ class MySQL57Platform extends MySqlPlatform
/**
* {@inheritdoc}
*/
public function getJsonTypeDeclarationSQL(array $field)
public function getJsonTypeDeclarationSQL(array $column)
{
return 'JSON';
}
......
......@@ -246,10 +246,10 @@ class MySqlPlatform extends AbstractPlatform
*
* {@inheritDoc}
*/
public function getClobTypeDeclarationSQL(array $field)
public function getClobTypeDeclarationSQL(array $column)
{
if (! empty($field['length']) && is_numeric($field['length'])) {
$length = $field['length'];
if (! empty($column['length']) && is_numeric($column['length'])) {
$length = $column['length'];
if ($length <= static::LENGTH_LIMIT_TINYTEXT) {
return 'TINYTEXT';
......@@ -270,9 +270,9 @@ class MySqlPlatform extends AbstractPlatform
/**
* {@inheritDoc}
*/
public function getDateTimeTypeDeclarationSQL(array $fieldDeclaration)
public function getDateTimeTypeDeclarationSQL(array $column)
{
if (isset($fieldDeclaration['version']) && $fieldDeclaration['version'] === true) {
if (isset($column['version']) && $column['version'] === true) {
return 'TIMESTAMP';
}
......@@ -282,7 +282,7 @@ class MySqlPlatform extends AbstractPlatform
/**
* {@inheritDoc}
*/
public function getDateTypeDeclarationSQL(array $fieldDeclaration)
public function getDateTypeDeclarationSQL(array $column)
{
return 'DATE';
}
......@@ -290,7 +290,7 @@ class MySqlPlatform extends AbstractPlatform
/**
* {@inheritDoc}
*/
public function getTimeTypeDeclarationSQL(array $fieldDeclaration)
public function getTimeTypeDeclarationSQL(array $column)
{
return 'TIME';
}
......@@ -298,21 +298,21 @@ class MySqlPlatform extends AbstractPlatform
/**
* {@inheritDoc}
*/
public function getBooleanTypeDeclarationSQL(array $field)
public function getBooleanTypeDeclarationSQL(array $column)
{
return 'TINYINT(1)';
}
/**
* Obtain DBMS specific SQL code portion needed to set the COLLATION
* of a field declaration to be used in statements like CREATE TABLE.
* of a column declaration to be used in statements like CREATE TABLE.
*
* @deprecated Deprecated since version 2.5, Use {@link self::getColumnCollationDeclarationSQL()} instead.
*
* @param string $collation name of the collation
*
* @return string DBMS specific SQL code portion needed to set the COLLATION
* of a field declaration.
* of a column declaration.
*/
public function getCollationFieldDeclaration($collation)
{
......@@ -470,14 +470,14 @@ SQL
/**
* {@inheritdoc}
*/
public function getDefaultValueDeclarationSQL($field)
public function getDefaultValueDeclarationSQL($column)
{
// Unset the default value if the given field definition does not allow default values.
if ($field['type'] instanceof TextType || $field['type'] instanceof BlobType) {
$field['default'] = null;
// Unset the default value if the given column definition does not allow default values.
if ($column['type'] instanceof TextType || $column['type'] instanceof BlobType) {
$column['default'] = null;
}
return parent::getDefaultValueDeclarationSQL($field);
return parent::getDefaultValueDeclarationSQL($column);
}
/**
......@@ -903,41 +903,41 @@ SQL
/**
* {@inheritDoc}
*/
public function getIntegerTypeDeclarationSQL(array $field)
public function getIntegerTypeDeclarationSQL(array $column)
{
return 'INT' . $this->_getCommonIntegerTypeDeclarationSQL($field);
return 'INT' . $this->_getCommonIntegerTypeDeclarationSQL($column);
}
/**
* {@inheritDoc}
*/
public function getBigIntTypeDeclarationSQL(array $field)
public function getBigIntTypeDeclarationSQL(array $column)
{
return 'BIGINT' . $this->_getCommonIntegerTypeDeclarationSQL($field);
return 'BIGINT' . $this->_getCommonIntegerTypeDeclarationSQL($column);
}
/**
* {@inheritDoc}
*/
public function getSmallIntTypeDeclarationSQL(array $field)
public function getSmallIntTypeDeclarationSQL(array $column)
{
return 'SMALLINT' . $this->_getCommonIntegerTypeDeclarationSQL($field);
return 'SMALLINT' . $this->_getCommonIntegerTypeDeclarationSQL($column);
}
/**
* {@inheritdoc}
*/
public function getFloatDeclarationSQL(array $field)
public function getFloatDeclarationSQL(array $column)
{
return 'DOUBLE PRECISION' . $this->getUnsignedDeclaration($field);
return 'DOUBLE PRECISION' . $this->getUnsignedDeclaration($column);
}
/**
* {@inheritdoc}
*/
public function getDecimalTypeDeclarationSQL(array $columnDef)
public function getDecimalTypeDeclarationSQL(array $column)
{
return parent::getDecimalTypeDeclarationSQL($columnDef) . $this->getUnsignedDeclaration($columnDef);
return parent::getDecimalTypeDeclarationSQL($column) . $this->getUnsignedDeclaration($column);
}
/**
......@@ -955,14 +955,14 @@ SQL
/**
* {@inheritDoc}
*/
protected function _getCommonIntegerTypeDeclarationSQL(array $columnDef)
protected function _getCommonIntegerTypeDeclarationSQL(array $column)
{
$autoinc = '';
if (! empty($columnDef['autoincrement'])) {
if (! empty($column['autoincrement'])) {
$autoinc = ' AUTO_INCREMENT';
}
return $this->getUnsignedDeclaration($columnDef) . $autoinc;
return $this->getUnsignedDeclaration($column) . $autoinc;
}
/**
......@@ -1147,10 +1147,10 @@ SQL
*
* {@inheritDoc}
*/
public function getBlobTypeDeclarationSQL(array $field)
public function getBlobTypeDeclarationSQL(array $column)
{
if (! empty($field['length']) && is_numeric($field['length'])) {
$length = $field['length'];
if (! empty($column['length']) && is_numeric($column['length'])) {
$length = $column['length'];
if ($length <= static::LENGTH_LIMIT_TINYBLOB) {
return 'TINYBLOB';
......
......@@ -259,7 +259,7 @@ class OraclePlatform extends AbstractPlatform
/**
* {@inheritDoc}
*/
public function getBooleanTypeDeclarationSQL(array $field)
public function getBooleanTypeDeclarationSQL(array $column)
{
return 'NUMBER(1)';
}
......@@ -267,7 +267,7 @@ class OraclePlatform extends AbstractPlatform
/**
* {@inheritDoc}
*/
public function getIntegerTypeDeclarationSQL(array $field)
public function getIntegerTypeDeclarationSQL(array $column)
{
return 'NUMBER(10)';
}
......@@ -275,7 +275,7 @@ class OraclePlatform extends AbstractPlatform
/**
* {@inheritDoc}
*/
public function getBigIntTypeDeclarationSQL(array $field)
public function getBigIntTypeDeclarationSQL(array $column)
{
return 'NUMBER(20)';
}
......@@ -283,7 +283,7 @@ class OraclePlatform extends AbstractPlatform
/**
* {@inheritDoc}
*/
public function getSmallIntTypeDeclarationSQL(array $field)
public function getSmallIntTypeDeclarationSQL(array $column)
{
return 'NUMBER(5)';
}
......@@ -291,7 +291,7 @@ class OraclePlatform extends AbstractPlatform
/**
* {@inheritDoc}
*/
public function getDateTimeTypeDeclarationSQL(array $fieldDeclaration)
public function getDateTimeTypeDeclarationSQL(array $column)
{
return 'TIMESTAMP(0)';
}
......@@ -299,7 +299,7 @@ class OraclePlatform extends AbstractPlatform
/**
* {@inheritDoc}
*/
public function getDateTimeTzTypeDeclarationSQL(array $fieldDeclaration)
public function getDateTimeTzTypeDeclarationSQL(array $column)
{
return 'TIMESTAMP(0) WITH TIME ZONE';
}
......@@ -307,7 +307,7 @@ class OraclePlatform extends AbstractPlatform
/**
* {@inheritDoc}
*/
public function getDateTypeDeclarationSQL(array $fieldDeclaration)
public function getDateTypeDeclarationSQL(array $column)
{
return 'DATE';
}
......@@ -315,7 +315,7 @@ class OraclePlatform extends AbstractPlatform
/**
* {@inheritDoc}
*/
public function getTimeTypeDeclarationSQL(array $fieldDeclaration)
public function getTimeTypeDeclarationSQL(array $column)
{
return 'DATE';
}
......@@ -323,7 +323,7 @@ class OraclePlatform extends AbstractPlatform
/**
* {@inheritDoc}
*/
protected function _getCommonIntegerTypeDeclarationSQL(array $columnDef)
protected function _getCommonIntegerTypeDeclarationSQL(array $column)
{
return '';
}
......@@ -356,7 +356,7 @@ class OraclePlatform extends AbstractPlatform
/**
* {@inheritDoc}
*/
public function getClobTypeDeclarationSQL(array $field)
public function getClobTypeDeclarationSQL(array $column)
{
return 'CLOB';
}
......@@ -923,26 +923,26 @@ SQL
/**
* {@inheritdoc}
*/
public function getColumnDeclarationSQL($name, array $field)
public function getColumnDeclarationSQL($name, array $column)
{
if (isset($field['columnDefinition'])) {
$columnDef = $this->getCustomTypeDeclarationSQL($field);
if (isset($column['columnDefinition'])) {
$columnDef = $this->getCustomTypeDeclarationSQL($column);
} else {
$default = $this->getDefaultValueDeclarationSQL($field);
$default = $this->getDefaultValueDeclarationSQL($column);
$notnull = '';
if (isset($field['notnull'])) {
$notnull = $field['notnull'] ? ' NOT NULL' : ' NULL';
if (isset($column['notnull'])) {
$notnull = $column['notnull'] ? ' NOT NULL' : ' NULL';
}
$unique = isset($field['unique']) && $field['unique'] ?
$unique = isset($column['unique']) && $column['unique'] ?
' ' . $this->getUniqueFieldDeclarationSQL() : '';
$check = isset($field['check']) && $field['check'] ?
' ' . $field['check'] : '';
$check = isset($column['check']) && $column['check'] ?
' ' . $column['check'] : '';
$typeDecl = $field['type']->getSQLDeclaration($field, $this);
$typeDecl = $column['type']->getSQLDeclaration($column, $this);
$columnDef = $typeDecl . $default . $notnull . $unique . $check;
}
......@@ -1205,7 +1205,7 @@ SQL
/**
* {@inheritDoc}
*/
public function getBlobTypeDeclarationSQL(array $field)
public function getBlobTypeDeclarationSQL(array $column)
{
return 'BLOB';
}
......
......@@ -14,7 +14,7 @@ class PostgreSQL92Platform extends PostgreSQL91Platform
/**
* {@inheritdoc}
*/
public function getJsonTypeDeclarationSQL(array $field)
public function getJsonTypeDeclarationSQL(array $column)
{
return 'JSON';
}
......@@ -22,13 +22,13 @@ class PostgreSQL92Platform extends PostgreSQL91Platform
/**
* {@inheritdoc}
*/
public function getSmallIntTypeDeclarationSQL(array $field)
public function getSmallIntTypeDeclarationSQL(array $column)
{
if (! empty($field['autoincrement'])) {
if (! empty($column['autoincrement'])) {
return 'SMALLSERIAL';
}
return parent::getSmallIntTypeDeclarationSQL($field);
return parent::getSmallIntTypeDeclarationSQL($column);
}
/**
......
......@@ -12,9 +12,9 @@ class PostgreSQL94Platform extends PostgreSQL92Platform
/**
* {@inheritdoc}
*/
public function getJsonTypeDeclarationSQL(array $field)
public function getJsonTypeDeclarationSQL(array $column)
{
if (! empty($field['jsonb'])) {
if (! empty($column['jsonb'])) {
return 'JSONB';
}
......
......@@ -944,7 +944,7 @@ SQL
/**
* {@inheritDoc}
*/
public function getBooleanTypeDeclarationSQL(array $field)
public function getBooleanTypeDeclarationSQL(array $column)
{
return 'BOOLEAN';
}
......@@ -952,9 +952,9 @@ SQL
/**
* {@inheritDoc}
*/
public function getIntegerTypeDeclarationSQL(array $field)
public function getIntegerTypeDeclarationSQL(array $column)
{
if (! empty($field['autoincrement'])) {
if (! empty($column['autoincrement'])) {
return 'SERIAL';
}
......@@ -964,9 +964,9 @@ SQL
/**
* {@inheritDoc}
*/
public function getBigIntTypeDeclarationSQL(array $field)
public function getBigIntTypeDeclarationSQL(array $column)
{
if (! empty($field['autoincrement'])) {
if (! empty($column['autoincrement'])) {
return 'BIGSERIAL';
}
......@@ -976,7 +976,7 @@ SQL
/**
* {@inheritDoc}
*/
public function getSmallIntTypeDeclarationSQL(array $field)
public function getSmallIntTypeDeclarationSQL(array $column)
{
return 'SMALLINT';
}
......@@ -984,7 +984,7 @@ SQL
/**
* {@inheritDoc}
*/
public function getGuidTypeDeclarationSQL(array $field)
public function getGuidTypeDeclarationSQL(array $column)
{
return 'UUID';
}
......@@ -992,7 +992,7 @@ SQL
/**
* {@inheritDoc}
*/
public function getDateTimeTypeDeclarationSQL(array $fieldDeclaration)
public function getDateTimeTypeDeclarationSQL(array $column)
{
return 'TIMESTAMP(0) WITHOUT TIME ZONE';
}
......@@ -1000,7 +1000,7 @@ SQL
/**
* {@inheritDoc}
*/
public function getDateTimeTzTypeDeclarationSQL(array $fieldDeclaration)
public function getDateTimeTzTypeDeclarationSQL(array $column)
{
return 'TIMESTAMP(0) WITH TIME ZONE';
}
......@@ -1008,7 +1008,7 @@ SQL
/**
* {@inheritDoc}
*/
public function getDateTypeDeclarationSQL(array $fieldDeclaration)
public function getDateTypeDeclarationSQL(array $column)
{
return 'DATE';
}
......@@ -1016,7 +1016,7 @@ SQL
/**
* {@inheritDoc}
*/
public function getTimeTypeDeclarationSQL(array $fieldDeclaration)
public function getTimeTypeDeclarationSQL(array $column)
{
return 'TIME(0) WITHOUT TIME ZONE';
}
......@@ -1034,7 +1034,7 @@ SQL
/**
* {@inheritDoc}
*/
protected function _getCommonIntegerTypeDeclarationSQL(array $columnDef)
protected function _getCommonIntegerTypeDeclarationSQL(array $column)
{
return '';
}
......@@ -1059,7 +1059,7 @@ SQL
/**
* {@inheritDoc}
*/
public function getClobTypeDeclarationSQL(array $field)
public function getClobTypeDeclarationSQL(array $column)
{
return 'TEXT';
}
......@@ -1204,7 +1204,7 @@ SQL
/**
* {@inheritDoc}
*/
public function getBlobTypeDeclarationSQL(array $field)
public function getBlobTypeDeclarationSQL(array $column)
{
return 'BYTEA';
}
......@@ -1212,23 +1212,23 @@ SQL
/**
* {@inheritdoc}
*/
public function getDefaultValueDeclarationSQL($field)
public function getDefaultValueDeclarationSQL($column)
{
if ($this->isSerialField($field)) {
if ($this->isSerialColumn($column)) {
return '';
}
return parent::getDefaultValueDeclarationSQL($field);
return parent::getDefaultValueDeclarationSQL($column);
}
/**
* @param mixed[] $field
* @param mixed[] $column
*/
private function isSerialField(array $field): bool
private function isSerialColumn(array $column): bool
{
return isset($field['type'], $field['autoincrement'])
&& $field['autoincrement'] === true
&& $this->isNumericType($field['type']);
return isset($column['type'], $column['autoincrement'])
&& $column['autoincrement'] === true
&& $this->isNumericType($column['type']);
}
/**
......
......@@ -42,7 +42,7 @@ class SQLAnywhere12Platform extends SQLAnywhere11Platform
/**
* {@inheritdoc}
*/
public function getDateTimeTzTypeDeclarationSQL(array $fieldDeclaration)
public function getDateTimeTzTypeDeclarationSQL(array $column)
{
return 'TIMESTAMP WITH TIME ZONE';
}
......
......@@ -298,11 +298,11 @@ class SQLAnywherePlatform extends AbstractPlatform
/**
* {@inheritdoc}
*/
public function getBigIntTypeDeclarationSQL(array $columnDef)
public function getBigIntTypeDeclarationSQL(array $column)
{
$columnDef['integer_type'] = 'BIGINT';
$column['integer_type'] = 'BIGINT';
return $this->_getCommonIntegerTypeDeclarationSQL($columnDef);
return $this->_getCommonIntegerTypeDeclarationSQL($column);
}
/**
......@@ -324,7 +324,7 @@ class SQLAnywherePlatform extends AbstractPlatform
/**
* {@inheritdoc}
*/
public function getBlobTypeDeclarationSQL(array $field)
public function getBlobTypeDeclarationSQL(array $column)
{
return 'LONG BINARY';
}
......@@ -337,9 +337,9 @@ class SQLAnywherePlatform extends AbstractPlatform
* Otherwise by just omitting the NOT NULL clause,
* SQL Anywhere will declare them NOT NULL nonetheless.
*/
public function getBooleanTypeDeclarationSQL(array $columnDef)
public function getBooleanTypeDeclarationSQL(array $column)
{
$nullClause = isset($columnDef['notnull']) && (bool) $columnDef['notnull'] === false ? ' NULL' : '';
$nullClause = isset($column['notnull']) && (bool) $column['notnull'] === false ? ' NULL' : '';
return 'BIT' . $nullClause;
}
......@@ -347,7 +347,7 @@ class SQLAnywherePlatform extends AbstractPlatform
/**
* {@inheritdoc}
*/
public function getClobTypeDeclarationSQL(array $field)
public function getClobTypeDeclarationSQL(array $column)
{
return 'TEXT';
}
......@@ -499,7 +499,7 @@ class SQLAnywherePlatform extends AbstractPlatform
/**
* {@inheritdoc}
*/
public function getDateTimeTypeDeclarationSQL(array $fieldDeclaration)
public function getDateTimeTypeDeclarationSQL(array $column)
{
return 'DATETIME';
}
......@@ -515,7 +515,7 @@ class SQLAnywherePlatform extends AbstractPlatform
/**
* {@inheritdoc}
*/
public function getDateTypeDeclarationSQL(array $fieldDeclaration)
public function getDateTypeDeclarationSQL(array $column)
{
return 'DATE';
}
......@@ -678,7 +678,7 @@ class SQLAnywherePlatform extends AbstractPlatform
/**
* {@inheritdoc}
*/
public function getGuidTypeDeclarationSQL(array $field)
public function getGuidTypeDeclarationSQL(array $column)
{
return 'UNIQUEIDENTIFIER';
}
......@@ -695,11 +695,11 @@ class SQLAnywherePlatform extends AbstractPlatform
/**
* {@inheritdoc}
*/
public function getIntegerTypeDeclarationSQL(array $columnDef)
public function getIntegerTypeDeclarationSQL(array $column)
{
$columnDef['integer_type'] = 'INT';
$column['integer_type'] = 'INT';
return $this->_getCommonIntegerTypeDeclarationSQL($columnDef);
return $this->_getCommonIntegerTypeDeclarationSQL($column);
}
/**
......@@ -1039,11 +1039,11 @@ SQL
/**
* {@inheritdoc}
*/
public function getSmallIntTypeDeclarationSQL(array $columnDef)
public function getSmallIntTypeDeclarationSQL(array $column)
{
$columnDef['integer_type'] = 'SMALLINT';
$column['integer_type'] = 'SMALLINT';
return $this->_getCommonIntegerTypeDeclarationSQL($columnDef);
return $this->_getCommonIntegerTypeDeclarationSQL($column);
}
/**
......@@ -1116,7 +1116,7 @@ SQL
/**
* {@inheritdoc}
*/
public function getTimeTypeDeclarationSQL(array $fieldDeclaration)
public function getTimeTypeDeclarationSQL(array $column)
{
return 'TIME';
}
......@@ -1236,12 +1236,12 @@ SQL
/**
* {@inheritdoc}
*/
protected function _getCommonIntegerTypeDeclarationSQL(array $columnDef)
protected function _getCommonIntegerTypeDeclarationSQL(array $column)
{
$unsigned = ! empty($columnDef['unsigned']) ? 'UNSIGNED ' : '';
$autoincrement = ! empty($columnDef['autoincrement']) ? ' IDENTITY' : '';
$unsigned = ! empty($column['unsigned']) ? 'UNSIGNED ' : '';
$autoincrement = ! empty($column['autoincrement']) ? ' IDENTITY' : '';
return $unsigned . $columnDef['integer_type'] . $autoincrement;
return $unsigned . $column['integer_type'] . $autoincrement;
}
/**
......
......@@ -29,7 +29,7 @@ class SQLServer2005Platform extends SQLServerPlatform
/**
* {@inheritDoc}
*/
public function getClobTypeDeclarationSQL(array $field)
public function getClobTypeDeclarationSQL(array $column)
{
return 'VARCHAR(MAX)';
}
......
......@@ -23,7 +23,7 @@ class SQLServer2008Platform extends SQLServer2005Platform
/**
* {@inheritDoc}
*/
public function getDateTimeTypeDeclarationSQL(array $fieldDeclaration)
public function getDateTimeTypeDeclarationSQL(array $column)
{
// 3 - microseconds precision length
// http://msdn.microsoft.com/en-us/library/ms187819.aspx
......@@ -33,7 +33,7 @@ class SQLServer2008Platform extends SQLServer2005Platform
/**
* {@inheritDoc}
*/
public function getDateTypeDeclarationSQL(array $fieldDeclaration)
public function getDateTypeDeclarationSQL(array $column)
{
return 'DATE';
}
......@@ -41,7 +41,7 @@ class SQLServer2008Platform extends SQLServer2005Platform
/**
* {@inheritDoc}
*/
public function getTimeTypeDeclarationSQL(array $fieldDeclaration)
public function getTimeTypeDeclarationSQL(array $column)
{
return 'TIME(0)';
}
......@@ -49,7 +49,7 @@ class SQLServer2008Platform extends SQLServer2005Platform
/**
* {@inheritDoc}
*/
public function getDateTimeTzTypeDeclarationSQL(array $fieldDeclaration)
public function getDateTimeTzTypeDeclarationSQL(array $column)
{
return 'DATETIMEOFFSET(6)';
}
......
......@@ -1161,31 +1161,31 @@ SQL
/**
* {@inheritDoc}
*/
public function getIntegerTypeDeclarationSQL(array $field)
public function getIntegerTypeDeclarationSQL(array $column)
{
return 'INT' . $this->_getCommonIntegerTypeDeclarationSQL($field);
return 'INT' . $this->_getCommonIntegerTypeDeclarationSQL($column);
}
/**
* {@inheritDoc}
*/
public function getBigIntTypeDeclarationSQL(array $field)
public function getBigIntTypeDeclarationSQL(array $column)
{
return 'BIGINT' . $this->_getCommonIntegerTypeDeclarationSQL($field);
return 'BIGINT' . $this->_getCommonIntegerTypeDeclarationSQL($column);
}
/**
* {@inheritDoc}
*/
public function getSmallIntTypeDeclarationSQL(array $field)
public function getSmallIntTypeDeclarationSQL(array $column)
{
return 'SMALLINT' . $this->_getCommonIntegerTypeDeclarationSQL($field);
return 'SMALLINT' . $this->_getCommonIntegerTypeDeclarationSQL($column);
}
/**
* {@inheritDoc}
*/
public function getGuidTypeDeclarationSQL(array $field)
public function getGuidTypeDeclarationSQL(array $column)
{
return 'UNIQUEIDENTIFIER';
}
......@@ -1217,7 +1217,7 @@ SQL
/**
* {@inheritDoc}
*/
public function getClobTypeDeclarationSQL(array $field)
public function getClobTypeDeclarationSQL(array $column)
{
return 'VARCHAR(MAX)';
}
......@@ -1225,15 +1225,15 @@ SQL
/**
* {@inheritDoc}
*/
protected function _getCommonIntegerTypeDeclarationSQL(array $columnDef)
protected function _getCommonIntegerTypeDeclarationSQL(array $column)
{
return ! empty($columnDef['autoincrement']) ? ' IDENTITY' : '';
return ! empty($column['autoincrement']) ? ' IDENTITY' : '';
}
/**
* {@inheritDoc}
*/
public function getDateTimeTypeDeclarationSQL(array $fieldDeclaration)
public function getDateTimeTypeDeclarationSQL(array $column)
{
return 'DATETIME';
}
......@@ -1241,7 +1241,7 @@ SQL
/**
* {@inheritDoc}
*/
public function getDateTypeDeclarationSQL(array $fieldDeclaration)
public function getDateTypeDeclarationSQL(array $column)
{
return 'DATETIME';
}
......@@ -1249,7 +1249,7 @@ SQL
/**
* {@inheritDoc}
*/
public function getTimeTypeDeclarationSQL(array $fieldDeclaration)
public function getTimeTypeDeclarationSQL(array $column)
{
return 'DATETIME';
}
......@@ -1257,7 +1257,7 @@ SQL
/**
* {@inheritDoc}
*/
public function getBooleanTypeDeclarationSQL(array $field)
public function getBooleanTypeDeclarationSQL(array $column)
{
return 'BIT';
}
......@@ -1607,7 +1607,7 @@ SQL
/**
* {@inheritDoc}
*/
public function getBlobTypeDeclarationSQL(array $field)
public function getBlobTypeDeclarationSQL(array $column)
{
return 'VARBINARY(MAX)';
}
......@@ -1617,23 +1617,23 @@ SQL
*
* Modifies column declaration order as it differs in Microsoft SQL Server.
*/
public function getColumnDeclarationSQL($name, array $field)
public function getColumnDeclarationSQL($name, array $column)
{
if (isset($field['columnDefinition'])) {
$columnDef = $this->getCustomTypeDeclarationSQL($field);
if (isset($column['columnDefinition'])) {
$columnDef = $this->getCustomTypeDeclarationSQL($column);
} else {
$collation = isset($field['collation']) && $field['collation'] ?
' ' . $this->getColumnCollationDeclarationSQL($field['collation']) : '';
$collation = isset($column['collation']) && $column['collation'] ?
' ' . $this->getColumnCollationDeclarationSQL($column['collation']) : '';
$notnull = isset($field['notnull']) && $field['notnull'] ? ' NOT NULL' : '';
$notnull = isset($column['notnull']) && $column['notnull'] ? ' NOT NULL' : '';
$unique = isset($field['unique']) && $field['unique'] ?
$unique = isset($column['unique']) && $column['unique'] ?
' ' . $this->getUniqueFieldDeclarationSQL() : '';
$check = isset($field['check']) && $field['check'] ?
' ' . $field['check'] : '';
$check = isset($column['check']) && $column['check'] ?
' ' . $column['check'] : '';
$typeDecl = $field['type']->getSQLDeclaration($field, $this);
$typeDecl = $column['type']->getSQLDeclaration($column, $this);
$columnDef = $typeDecl . $collation . $notnull . $unique . $check;
}
......
......@@ -201,7 +201,7 @@ class SqlitePlatform extends AbstractPlatform
/**
* {@inheritDoc}
*/
public function getBooleanTypeDeclarationSQL(array $field)
public function getBooleanTypeDeclarationSQL(array $column)
{
return 'BOOLEAN';
}
......@@ -209,71 +209,71 @@ class SqlitePlatform extends AbstractPlatform
/**
* {@inheritDoc}
*/
public function getIntegerTypeDeclarationSQL(array $field)
public function getIntegerTypeDeclarationSQL(array $column)
{
return 'INTEGER' . $this->_getCommonIntegerTypeDeclarationSQL($field);
return 'INTEGER' . $this->_getCommonIntegerTypeDeclarationSQL($column);
}
/**
* {@inheritDoc}
*/
public function getBigIntTypeDeclarationSQL(array $field)
public function getBigIntTypeDeclarationSQL(array $column)
{
// SQLite autoincrement is implicit for INTEGER PKs, but not for BIGINT fields.
if (! empty($field['autoincrement'])) {
return $this->getIntegerTypeDeclarationSQL($field);
// SQLite autoincrement is implicit for INTEGER PKs, but not for BIGINT columns
if (! empty($column['autoincrement'])) {
return $this->getIntegerTypeDeclarationSQL($column);
}
return 'BIGINT' . $this->_getCommonIntegerTypeDeclarationSQL($field);
return 'BIGINT' . $this->_getCommonIntegerTypeDeclarationSQL($column);
}
/**
* @param array<string, mixed> $field
* @param array<string, mixed> $column
*
* @return string
*/
public function getTinyIntTypeDeclarationSql(array $field)
public function getTinyIntTypeDeclarationSql(array $column)
{
// SQLite autoincrement is implicit for INTEGER PKs, but not for TINYINT fields.
if (! empty($field['autoincrement'])) {
return $this->getIntegerTypeDeclarationSQL($field);
// SQLite autoincrement is implicit for INTEGER PKs, but not for TINYINT columns
if (! empty($column['autoincrement'])) {
return $this->getIntegerTypeDeclarationSQL($column);
}
return 'TINYINT' . $this->_getCommonIntegerTypeDeclarationSQL($field);
return 'TINYINT' . $this->_getCommonIntegerTypeDeclarationSQL($column);
}
/**
* {@inheritDoc}
*/
public function getSmallIntTypeDeclarationSQL(array $field)
public function getSmallIntTypeDeclarationSQL(array $column)
{
// SQLite autoincrement is implicit for INTEGER PKs, but not for SMALLINT fields.
if (! empty($field['autoincrement'])) {
return $this->getIntegerTypeDeclarationSQL($field);
// SQLite autoincrement is implicit for INTEGER PKs, but not for SMALLINT columns
if (! empty($column['autoincrement'])) {
return $this->getIntegerTypeDeclarationSQL($column);
}
return 'SMALLINT' . $this->_getCommonIntegerTypeDeclarationSQL($field);
return 'SMALLINT' . $this->_getCommonIntegerTypeDeclarationSQL($column);
}
/**
* @param array<string, mixed> $field
* @param array<string, mixed> $column
*
* @return string
*/
public function getMediumIntTypeDeclarationSql(array $field)
public function getMediumIntTypeDeclarationSql(array $column)
{
// SQLite autoincrement is implicit for INTEGER PKs, but not for MEDIUMINT fields.
if (! empty($field['autoincrement'])) {
return $this->getIntegerTypeDeclarationSQL($field);
// SQLite autoincrement is implicit for INTEGER PKs, but not for MEDIUMINT columns
if (! empty($column['autoincrement'])) {
return $this->getIntegerTypeDeclarationSQL($column);
}
return 'MEDIUMINT' . $this->_getCommonIntegerTypeDeclarationSQL($field);
return 'MEDIUMINT' . $this->_getCommonIntegerTypeDeclarationSQL($column);
}
/**
* {@inheritDoc}
*/
public function getDateTimeTypeDeclarationSQL(array $fieldDeclaration)
public function getDateTimeTypeDeclarationSQL(array $column)
{
return 'DATETIME';
}
......@@ -281,7 +281,7 @@ class SqlitePlatform extends AbstractPlatform
/**
* {@inheritDoc}
*/
public function getDateTypeDeclarationSQL(array $fieldDeclaration)
public function getDateTypeDeclarationSQL(array $column)
{
return 'DATE';
}
......@@ -289,7 +289,7 @@ class SqlitePlatform extends AbstractPlatform
/**
* {@inheritDoc}
*/
public function getTimeTypeDeclarationSQL(array $fieldDeclaration)
public function getTimeTypeDeclarationSQL(array $column)
{
return 'TIME';
}
......@@ -297,14 +297,14 @@ class SqlitePlatform extends AbstractPlatform
/**
* {@inheritDoc}
*/
protected function _getCommonIntegerTypeDeclarationSQL(array $columnDef)
protected function _getCommonIntegerTypeDeclarationSQL(array $column)
{
// sqlite autoincrement is only possible for the primary key
if (! empty($columnDef['autoincrement'])) {
if (! empty($column['autoincrement'])) {
return ' PRIMARY KEY AUTOINCREMENT';
}
return ! empty($columnDef['unsigned']) ? ' UNSIGNED' : '';
return ! empty($column['unsigned']) ? ' UNSIGNED' : '';
}
/**
......@@ -430,7 +430,7 @@ class SqlitePlatform extends AbstractPlatform
/**
* {@inheritDoc}
*/
public function getClobTypeDeclarationSQL(array $field)
public function getClobTypeDeclarationSQL(array $column)
{
return 'CLOB';
}
......@@ -740,7 +740,7 @@ class SqlitePlatform extends AbstractPlatform
/**
* {@inheritDoc}
*/
public function getBlobTypeDeclarationSQL(array $field)
public function getBlobTypeDeclarationSQL(array $column)
{
return 'BLOB';
}
......@@ -1013,22 +1013,23 @@ class SqlitePlatform extends AbstractPlatform
continue;
}
$field = array_merge(['unique' => null, 'autoincrement' => null, 'default' => null], $column->toArray());
$type = $field['type'];
$definition = array_merge(['unique' => null, 'autoincrement' => null, 'default' => null], $column->toArray());
$type = $definition['type'];
switch (true) {
case isset($field['columnDefinition']) || $field['autoincrement'] || $field['unique']:
case $type instanceof Types\DateTimeType && $field['default'] === $this->getCurrentTimestampSQL():
case $type instanceof Types\DateType && $field['default'] === $this->getCurrentDateSQL():
case $type instanceof Types\TimeType && $field['default'] === $this->getCurrentTimeSQL():
case isset($definition['columnDefinition']) || $definition['autoincrement'] || $definition['unique']:
case $type instanceof Types\DateTimeType && $definition['default'] === $this->getCurrentTimestampSQL():
case $type instanceof Types\DateType && $definition['default'] === $this->getCurrentDateSQL():
case $type instanceof Types\TimeType && $definition['default'] === $this->getCurrentTimeSQL():
return false;
}
$field['name'] = $column->getQuotedName($this);
if ($type instanceof Types\StringType && $field['length'] === null) {
$field['length'] = 255;
$definition['name'] = $column->getQuotedName($this);
if ($type instanceof Types\StringType && $definition['length'] === null) {
$definition['length'] = 255;
}
$sql[] = 'ALTER TABLE ' . $table->getQuotedName($this) . ' ADD COLUMN ' . $this->getColumnDeclarationSQL($field['name'], $field);
$sql[] = 'ALTER TABLE ' . $table->getQuotedName($this) . ' ADD COLUMN ' . $this->getColumnDeclarationSQL($definition['name'], $definition);
}
if (! $this->onSchemaAlterTable($diff, $tableSql)) {
......
......@@ -209,7 +209,7 @@ class ExpressionBuilder
/**
* Creates an IS NULL expression with the given arguments.
*
* @param string $x The field in string format to be restricted by IS NULL.
* @param string $x The expression to be restricted by IS NULL.
*
* @return string
*/
......@@ -221,7 +221,7 @@ class ExpressionBuilder
/**
* Creates an IS NOT NULL expression with the given arguments.
*
* @param string $x The field in string format to be restricted by IS NOT NULL.
* @param string $x The expression to be restricted by IS NOT NULL.
*
* @return string
*/
......@@ -274,7 +274,7 @@ class ExpressionBuilder
/**
* Creates a NOT IN () comparison expression with the given arguments.
*
* @param string $x The field in string format to be inspected by NOT IN() comparison.
* @param string $x The expression to be inspected by NOT IN() comparison.
* @param string|string[] $y The placeholder or the array of values to be used by NOT IN() comparison.
*
* @return string
......
......@@ -145,7 +145,7 @@ abstract class AbstractSchemaManager
* Lists the columns for a given table.
*
* In contrast to other libraries and to the old version of Doctrine,
* this column definition does try to contain the 'primary' field for
* this column definition does try to contain the 'primary' column for
* the reason that it is not portable across different RDBMS. Use
* {@see listTableIndexes($tableName)} to retrieve the primary key
* of a table. Where a RDBMS specifies more details, these are held
......
......@@ -199,7 +199,7 @@ class Comparator
$table1Columns = $table1->getColumns();
$table2Columns = $table2->getColumns();
/* See if all the fields in table 1 exist in table 2 */
/* See if all the columns in table 1 exist in table 2 */
foreach ($table2Columns as $columnName => $column) {
if ($table1->hasColumn($columnName)) {
continue;
......@@ -209,7 +209,7 @@ class Comparator
$changes++;
}
/* See if there are any removed fields in table 2 */
/* See if there are any removed columns in table 2 */
foreach ($table1Columns as $columnName => $column) {
// See if column is removed in table 2.
if (! $table2->hasColumn($columnName)) {
......@@ -414,7 +414,7 @@ class Comparator
}
/**
* Returns the difference between the fields $field1 and $field2.
* Returns the difference between the columns
*
* If there are differences this method returns $field2, otherwise the
* boolean false.
......
......@@ -16,21 +16,21 @@ class TableDiff
public $newName = false;
/**
* All added fields.
* All added columns
*
* @var Column[]
*/
public $addedColumns;
/**
* All changed fields.
* All changed columns
*
* @var ColumnDiff[]
*/
public $changedColumns = [];
/**
* All removed fields.
* All removed columns
*
* @var Column[]
*/
......
......@@ -19,9 +19,9 @@ class ArrayType extends Type
/**
* {@inheritdoc}
*/
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
public function getSQLDeclaration(array $column, AbstractPlatform $platform)
{
return $platform->getClobTypeDeclarationSQL($fieldDeclaration);
return $platform->getClobTypeDeclarationSQL($column);
}
/**
......
......@@ -21,9 +21,9 @@ class BigIntType extends Type implements PhpIntegerMappingType
/**
* {@inheritdoc}
*/
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
public function getSQLDeclaration(array $column, AbstractPlatform $platform)
{
return $platform->getBigIntTypeDeclarationSQL($fieldDeclaration);
return $platform->getBigIntTypeDeclarationSQL($column);
}
/**
......
......@@ -20,9 +20,9 @@ class BinaryType extends Type
/**
* {@inheritdoc}
*/
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
public function getSQLDeclaration(array $column, AbstractPlatform $platform)
{
return $platform->getBinaryTypeDeclarationSQL($fieldDeclaration);
return $platform->getBinaryTypeDeclarationSQL($column);
}
/**
......
......@@ -20,9 +20,9 @@ class BlobType extends Type
/**
* {@inheritdoc}
*/
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
public function getSQLDeclaration(array $column, AbstractPlatform $platform)
{
return $platform->getBlobTypeDeclarationSQL($fieldDeclaration);
return $platform->getBlobTypeDeclarationSQL($column);
}
/**
......
......@@ -13,9 +13,9 @@ class BooleanType extends Type
/**
* {@inheritdoc}
*/
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
public function getSQLDeclaration(array $column, AbstractPlatform $platform)
{
return $platform->getBooleanTypeDeclarationSQL($fieldDeclaration);
return $platform->getBooleanTypeDeclarationSQL($column);
}
/**
......
......@@ -26,11 +26,11 @@ class DateIntervalType extends Type
/**
* {@inheritdoc}
*/
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
public function getSQLDeclaration(array $column, AbstractPlatform $platform)
{
$fieldDeclaration['length'] = 255;
$column['length'] = 255;
return $platform->getVarcharTypeDeclarationSQL($fieldDeclaration);
return $platform->getVarcharTypeDeclarationSQL($column);
}
/**
......
......@@ -24,9 +24,9 @@ class DateTimeType extends Type implements PhpDateTimeMappingType
/**
* {@inheritdoc}
*/
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
public function getSQLDeclaration(array $column, AbstractPlatform $platform)
{
return $platform->getDateTimeTypeDeclarationSQL($fieldDeclaration);
return $platform->getDateTimeTypeDeclarationSQL($column);
}
/**
......
......@@ -35,9 +35,9 @@ class DateTimeTzType extends Type implements PhpDateTimeMappingType
/**
* {@inheritdoc}
*/
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
public function getSQLDeclaration(array $column, AbstractPlatform $platform)
{
return $platform->getDateTimeTzTypeDeclarationSQL($fieldDeclaration);
return $platform->getDateTimeTzTypeDeclarationSQL($column);
}
/**
......
......@@ -22,9 +22,9 @@ class DateType extends Type
/**
* {@inheritdoc}
*/
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
public function getSQLDeclaration(array $column, AbstractPlatform $platform)
{
return $platform->getDateTypeDeclarationSQL($fieldDeclaration);
return $platform->getDateTypeDeclarationSQL($column);
}
/**
......
......@@ -20,9 +20,9 @@ class DecimalType extends Type
/**
* {@inheritdoc}
*/
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
public function getSQLDeclaration(array $column, AbstractPlatform $platform)
{
return $platform->getDecimalTypeDeclarationSQL($fieldDeclaration);
return $platform->getDecimalTypeDeclarationSQL($column);
}
/**
......
......@@ -17,9 +17,9 @@ class FloatType extends Type
/**
* {@inheritdoc}
*/
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
public function getSQLDeclaration(array $column, AbstractPlatform $platform)
{
return $platform->getFloatDeclarationSQL($fieldDeclaration);
return $platform->getFloatDeclarationSQL($column);
}
/**
......
......@@ -12,9 +12,9 @@ class GuidType extends StringType
/**
* {@inheritdoc}
*/
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
public function getSQLDeclaration(array $column, AbstractPlatform $platform)
{
return $platform->getGuidTypeDeclarationSQL($fieldDeclaration);
return $platform->getGuidTypeDeclarationSQL($column);
}
/**
......
......@@ -21,9 +21,9 @@ class IntegerType extends Type implements PhpIntegerMappingType
/**
* {@inheritdoc}
*/
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
public function getSQLDeclaration(array $column, AbstractPlatform $platform)
{
return $platform->getIntegerTypeDeclarationSQL($fieldDeclaration);
return $platform->getIntegerTypeDeclarationSQL($column);
}
/**
......
......@@ -21,9 +21,9 @@ class JsonType extends Type
/**
* {@inheritdoc}
*/
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
public function getSQLDeclaration(array $column, AbstractPlatform $platform)
{
return $platform->getJsonTypeDeclarationSQL($fieldDeclaration);
return $platform->getJsonTypeDeclarationSQL($column);
}
/**
......
......@@ -19,9 +19,9 @@ class ObjectType extends Type
/**
* {@inheritdoc}
*/
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
public function getSQLDeclaration(array $column, AbstractPlatform $platform)
{
return $platform->getClobTypeDeclarationSQL($fieldDeclaration);
return $platform->getClobTypeDeclarationSQL($column);
}
/**
......
......@@ -19,9 +19,9 @@ class SimpleArrayType extends Type
/**
* {@inheritdoc}
*/
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
public function getSQLDeclaration(array $column, AbstractPlatform $platform)
{
return $platform->getClobTypeDeclarationSQL($fieldDeclaration);
return $platform->getClobTypeDeclarationSQL($column);
}
/**
......
......@@ -21,9 +21,9 @@ class SmallIntType extends Type implements PhpIntegerMappingType
/**
* {@inheritdoc}
*/
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
public function getSQLDeclaration(array $column, AbstractPlatform $platform)
{
return $platform->getSmallIntTypeDeclarationSQL($fieldDeclaration);
return $platform->getSmallIntTypeDeclarationSQL($column);
}
/**
......
......@@ -12,9 +12,9 @@ class StringType extends Type
/**
* {@inheritdoc}
*/
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
public function getSQLDeclaration(array $column, AbstractPlatform $platform)
{
return $platform->getVarcharTypeDeclarationSQL($fieldDeclaration);
return $platform->getVarcharTypeDeclarationSQL($column);
}
/**
......
......@@ -15,9 +15,9 @@ class TextType extends Type
/**
* {@inheritdoc}
*/
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
public function getSQLDeclaration(array $column, AbstractPlatform $platform)
{
return $platform->getClobTypeDeclarationSQL($fieldDeclaration);
return $platform->getClobTypeDeclarationSQL($column);
}
/**
......
......@@ -22,9 +22,9 @@ class TimeType extends Type
/**
* {@inheritdoc}
*/
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
public function getSQLDeclaration(array $column, AbstractPlatform $platform)
{
return $platform->getTimeTypeDeclarationSQL($fieldDeclaration);
return $platform->getTimeTypeDeclarationSQL($column);
}
/**
......
......@@ -176,14 +176,14 @@ abstract class Type
}
/**
* Gets the SQL declaration snippet for a field of this type.
* Gets the SQL declaration snippet for a column of this type.
*
* @param mixed[] $fieldDeclaration The field declaration.
* @param mixed[] $column The column definition
* @param AbstractPlatform $platform The currently used database platform.
*
* @return string
*/
abstract public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform);
abstract public function getSQLDeclaration(array $column, AbstractPlatform $platform);
/**
* Gets the name of this type.
......
......@@ -28,8 +28,8 @@ class BlobTest extends DbalFunctionalTestCase
$table = new Table('blob_table');
$table->addColumn('id', 'integer');
$table->addColumn('clobfield', 'text');
$table->addColumn('blobfield', 'blob');
$table->addColumn('clobcolumn', 'text');
$table->addColumn('blobcolumn', 'blob');
$table->setPrimaryKey(['id']);
$sm = $this->connection->getSchemaManager();
......@@ -40,8 +40,8 @@ class BlobTest extends DbalFunctionalTestCase
{
$ret = $this->connection->insert('blob_table', [
'id' => 1,
'clobfield' => 'test',
'blobfield' => 'test',
'clobcolumn' => 'test',
'blobcolumn' => 'test',
], [
ParameterType::INTEGER,
ParameterType::STRING,
......@@ -61,8 +61,8 @@ class BlobTest extends DbalFunctionalTestCase
$longBlob = str_repeat('x', 4 * 8192); // send 4 chunks
$this->connection->insert('blob_table', [
'id' => 1,
'clobfield' => 'ignored',
'blobfield' => fopen('data://text/plain,' . $longBlob, 'r'),
'clobcolumn' => 'ignored',
'blobcolumn' => fopen('data://text/plain,' . $longBlob, 'r'),
], [
ParameterType::INTEGER,
ParameterType::STRING,
......@@ -76,8 +76,8 @@ class BlobTest extends DbalFunctionalTestCase
{
$this->connection->insert('blob_table', [
'id' => 1,
'clobfield' => 'test',
'blobfield' => 'test',
'clobcolumn' => 'test',
'blobcolumn' => 'test',
], [
ParameterType::INTEGER,
ParameterType::STRING,
......@@ -91,15 +91,15 @@ class BlobTest extends DbalFunctionalTestCase
{
$this->connection->insert('blob_table', [
'id' => 1,
'clobfield' => 'test',
'blobfield' => 'test',
'clobcolumn' => 'test',
'blobcolumn' => 'test',
], [
ParameterType::INTEGER,
ParameterType::STRING,
ParameterType::LARGE_OBJECT,
]);
$this->connection->update('blob_table', ['blobfield' => 'test2'], ['id' => 1], [
$this->connection->update('blob_table', ['blobcolumn' => 'test2'], ['id' => 1], [
ParameterType::LARGE_OBJECT,
ParameterType::INTEGER,
]);
......@@ -116,8 +116,8 @@ class BlobTest extends DbalFunctionalTestCase
$this->connection->insert('blob_table', [
'id' => 1,
'clobfield' => 'ignored',
'blobfield' => 'test',
'clobcolumn' => 'ignored',
'blobcolumn' => 'test',
], [
ParameterType::INTEGER,
ParameterType::STRING,
......@@ -126,7 +126,7 @@ class BlobTest extends DbalFunctionalTestCase
$this->connection->update('blob_table', [
'id' => 1,
'blobfield' => fopen('data://text/plain,test2', 'r'),
'blobcolumn' => fopen('data://text/plain,test2', 'r'),
], ['id' => 1], [
ParameterType::INTEGER,
ParameterType::LARGE_OBJECT,
......@@ -141,7 +141,7 @@ class BlobTest extends DbalFunctionalTestCase
$this->markTestIncomplete('The oci8 driver does not support stream resources as parameters');
}
$stmt = $this->connection->prepare("INSERT INTO blob_table(id, clobfield, blobfield) VALUES (1, 'ignored', ?)");
$stmt = $this->connection->prepare("INSERT INTO blob_table(id, clobcolumn, blobcolumn) VALUES (1, 'ignored', ?)");
$stream = null;
$stmt->bindParam(1, $stream, ParameterType::LARGE_OBJECT);
......@@ -156,7 +156,7 @@ class BlobTest extends DbalFunctionalTestCase
private function assertBlobContains(string $text): void
{
$rows = $this->connection->query('SELECT blobfield FROM blob_table')->fetchAll(FetchMode::COLUMN);
$rows = $this->connection->query('SELECT blobcolumn FROM blob_table')->fetchAll(FetchMode::COLUMN);
self::assertCount(1, $rows);
......
......@@ -236,7 +236,7 @@ class ExceptionTest extends DbalFunctionalTestCase
{
$schema = new Schema();
$table = $schema->createTable('bad_fieldname_table');
$table = $schema->createTable('bad_columnname_table');
$table->addColumn('id', 'integer', []);
foreach ($schema->toSql($this->connection->getDatabasePlatform()) as $sql) {
......@@ -244,7 +244,7 @@ class ExceptionTest extends DbalFunctionalTestCase
}
$this->expectException(Exception\InvalidFieldNameException::class);
$this->connection->insert('bad_fieldname_table', ['name' => 5]);
$this->connection->insert('bad_columnname_table', ['name' => 5]);
}
public function testNonUniqueFieldNameException(): void
......@@ -270,7 +270,7 @@ class ExceptionTest extends DbalFunctionalTestCase
{
$schema = new Schema();
$table = $schema->createTable('unique_field_table');
$table = $schema->createTable('unique_column_table');
$table->addColumn('id', 'integer');
$table->addUniqueIndex(['id']);
......@@ -278,9 +278,9 @@ class ExceptionTest extends DbalFunctionalTestCase
$this->connection->exec($sql);
}
$this->connection->insert('unique_field_table', ['id' => 5]);
$this->connection->insert('unique_column_table', ['id' => 5]);
$this->expectException(Exception\UniqueConstraintViolationException::class);
$this->connection->insert('unique_field_table', ['id' => 5]);
$this->connection->insert('unique_column_table', ['id' => 5]);
}
public function testSyntaxErrorException(): void
......
......@@ -138,13 +138,12 @@ class PortabilityTest extends DbalFunctionalTestCase
*
* @dataProvider fetchAllColumnProvider
*/
public function testFetchAllColumn(string $field, array $expected): void
public function testFetchAllColumn(string $column, array $expected): void
{
$conn = $this->getPortableConnection();
$stmt = $conn->query('SELECT ' . $field . ' FROM portability_table');
$stmt = $conn->query('SELECT ' . $column . ' FROM portability_table');
$column = $stmt->fetchAll(FetchMode::COLUMN);
self::assertEquals($expected, $column);
self::assertEquals($expected, $stmt->fetchAll(FetchMode::COLUMN));
}
/**
......
......@@ -516,7 +516,7 @@ class MoneyType extends Type
/**
* {@inheritDoc}
*/
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
public function getSQLDeclaration(array $column, AbstractPlatform $platform)
{
return 'MyMoney';
}
......
......@@ -350,8 +350,10 @@ abstract class AbstractPlatformTestCase extends DbalTestCase
public function testGetCustomColumnDeclarationSql(): void
{
$field = ['columnDefinition' => 'MEDIUMINT(6) UNSIGNED'];
self::assertEquals('foo MEDIUMINT(6) UNSIGNED', $this->platform->getColumnDeclarationSQL('foo', $field));
self::assertEquals(
'foo MEDIUMINT(6) UNSIGNED',
$this->platform->getColumnDeclarationSQL('foo', ['columnDefinition' => 'MEDIUMINT(6) UNSIGNED'])
);
}
public function testGetCreateTableSqlDispatchEvent(): void
......@@ -516,26 +518,22 @@ abstract class AbstractPlatformTestCase extends DbalTestCase
public function testGetDefaultValueDeclarationSQL(): void
{
// non-timestamp value will get single quotes
$field = [
self::assertEquals(" DEFAULT 'non_timestamp'", $this->platform->getDefaultValueDeclarationSQL([
'type' => Type::getType('string'),
'default' => 'non_timestamp',
];
self::assertEquals(" DEFAULT 'non_timestamp'", $this->platform->getDefaultValueDeclarationSQL($field));
]));
}
public function testGetDefaultValueDeclarationSQLDateTime(): void
{
// timestamps on datetime types should not be quoted
foreach (['datetime', 'datetimetz', 'datetime_immutable', 'datetimetz_immutable'] as $type) {
$field = [
'type' => Type::getType($type),
'default' => $this->platform->getCurrentTimestampSQL(),
];
self::assertSame(
' DEFAULT ' . $this->platform->getCurrentTimestampSQL(),
$this->platform->getDefaultValueDeclarationSQL($field)
$this->platform->getDefaultValueDeclarationSQL([
'type' => Type::getType($type),
'default' => $this->platform->getCurrentTimestampSQL(),
])
);
}
}
......@@ -543,14 +541,12 @@ abstract class AbstractPlatformTestCase extends DbalTestCase
public function testGetDefaultValueDeclarationSQLForIntegerTypes(): void
{
foreach (['bigint', 'integer', 'smallint'] as $type) {
$field = [
'type' => Type::getType($type),
'default' => 1,
];
self::assertEquals(
' DEFAULT 1',
$this->platform->getDefaultValueDeclarationSQL($field)
$this->platform->getDefaultValueDeclarationSQL([
'type' => Type::getType($type),
'default' => 1,
])
);
}
}
......@@ -559,14 +555,12 @@ abstract class AbstractPlatformTestCase extends DbalTestCase
{
$currentDateSql = $this->platform->getCurrentDateSQL();
foreach (['date', 'date_immutable'] as $type) {
$field = [
'type' => Type::getType($type),
'default' => $currentDateSql,
];
self::assertSame(
' DEFAULT ' . $currentDateSql,
$this->platform->getDefaultValueDeclarationSQL($field)
$this->platform->getDefaultValueDeclarationSQL([
'type' => Type::getType($type),
'default' => $currentDateSql,
])
);
}
}
......
......@@ -469,10 +469,10 @@ abstract class AbstractSQLServerPlatformTestCase extends AbstractPlatformTestCas
public function testModifyLimitSubquerySimple(): void
{
$querySql = 'SELECT DISTINCT id_0 FROM '
. '(SELECT k0_.id AS id_0, k0_.field AS field_1 '
. 'FROM key_table k0_ WHERE (k0_.where_field IN (1))) dctrn_result';
$alteredSql = 'SELECT DISTINCT TOP 20 id_0 FROM (SELECT k0_.id AS id_0, k0_.field AS field_1 '
. 'FROM key_table k0_ WHERE (k0_.where_field IN (1))) dctrn_result';
. '(SELECT k0_.id AS id_0, k0_.column AS column_1 '
. 'FROM key_table k0_ WHERE (k0_.where_column IN (1))) dctrn_result';
$alteredSql = 'SELECT DISTINCT TOP 20 id_0 FROM (SELECT k0_.id AS id_0, k0_.column AS column_1 '
. 'FROM key_table k0_ WHERE (k0_.where_column IN (1))) dctrn_result';
$sql = $this->platform->modifyLimitQuery($querySql, 20);
$this->expectCteWithMaxRowNum($alteredSql, 20, $sql);
}
......@@ -1445,14 +1445,12 @@ abstract class AbstractSQLServerPlatformTestCase extends AbstractPlatformTestCas
{
$currentDateSql = $this->platform->getCurrentDateSQL();
foreach (['date', 'date_immutable'] as $type) {
$field = [
'type' => Type::getType($type),
'default' => $currentDateSql,
];
self::assertSame(
' DEFAULT CONVERT(date, GETDATE())',
$this->platform->getDefaultValueDeclarationSQL($field)
$this->platform->getDefaultValueDeclarationSQL([
'type' => Type::getType($type),
'default' => $currentDateSql,
])
);
}
}
......
......@@ -326,10 +326,10 @@ class SQLServer2012PlatformTest extends AbstractSQLServerPlatformTestCase
public function testModifyLimitSubquerySimple(): void
{
$querySql = 'SELECT DISTINCT id_0 FROM '
. '(SELECT k0_.id AS id_0, k0_.field AS field_1 '
. 'FROM key_table k0_ WHERE (k0_.where_field IN (1))) dctrn_result';
$alteredSql = 'SELECT DISTINCT id_0 FROM (SELECT k0_.id AS id_0, k0_.field AS field_1 '
. 'FROM key_table k0_ WHERE (k0_.where_field IN (1))) dctrn_result ORDER BY 1 OFFSET 0 ROWS FETCH NEXT 20 ROWS ONLY';
. '(SELECT k0_.id AS id_0, k0_.column AS column_1 '
. 'FROM key_table k0_ WHERE (k0_.where_column IN (1))) dctrn_result';
$alteredSql = 'SELECT DISTINCT id_0 FROM (SELECT k0_.id AS id_0, k0_.column AS column_1 '
. 'FROM key_table k0_ WHERE (k0_.where_column IN (1))) dctrn_result ORDER BY 1 OFFSET 0 ROWS FETCH NEXT 20 ROWS ONLY';
$sql = $this->platform->modifyLimitQuery($querySql, 20);
self::assertEquals($alteredSql, $sql);
}
......
......@@ -58,10 +58,10 @@ class SQLParserUtilsTest extends DbalTestCase
['SELECT [d.ns:col_name] FROM my_table d WHERE [d.date] >= :param1', false, [57 => 'param1']], // Ticket DBAL-552
['SELECT * FROM foo WHERE jsonb_exists_any(foo.bar, ARRAY[:foo])', false, [56 => 'foo']], // Ticket GH-2295
['SELECT * FROM foo WHERE jsonb_exists_any(foo.bar, array[:foo])', false, [56 => 'foo']],
['SELECT table.field1, ARRAY[\'3\'] FROM schema.table table WHERE table.f1 = :foo AND ARRAY[\'3\']', false, [73 => 'foo']],
['SELECT table.field1, ARRAY[\'3\']::integer[] FROM schema.table table WHERE table.f1 = :foo AND ARRAY[\'3\']::integer[]', false, [84 => 'foo']],
['SELECT table.field1, ARRAY[:foo] FROM schema.table table WHERE table.f1 = :bar AND ARRAY[\'3\']', false, [27 => 'foo', 74 => 'bar']],
['SELECT table.field1, ARRAY[:foo]::integer[] FROM schema.table table WHERE table.f1 = :bar AND ARRAY[\'3\']::integer[]', false, [27 => 'foo', 85 => 'bar']],
['SELECT table.column1, ARRAY[\'3\'] FROM schema.table table WHERE table.f1 = :foo AND ARRAY[\'3\']', false, [74 => 'foo']],
['SELECT table.column1, ARRAY[\'3\']::integer[] FROM schema.table table WHERE table.f1 = :foo AND ARRAY[\'3\']::integer[]', false, [85 => 'foo']],
['SELECT table.column1, ARRAY[:foo] FROM schema.table table WHERE table.f1 = :bar AND ARRAY[\'3\']', false, [28 => 'foo', 75 => 'bar']],
['SELECT table.column1, ARRAY[:foo]::integer[] FROM schema.table table WHERE table.f1 = :bar AND ARRAY[\'3\']::integer[]', false, [28 => 'foo', 86 => 'bar']],
[
<<<'SQLDATA'
SELECT * FROM foo WHERE
......
......@@ -20,7 +20,7 @@ class CommentedType extends Type
/**
* {@inheritDoc}
*/
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
public function getSQLDeclaration(array $column, AbstractPlatform $platform)
{
return strtoupper($this->getName());
}
......
......@@ -20,7 +20,7 @@ class MySqlPointType extends Type
/**
* {@inheritDoc}
*/
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
public function getSQLDeclaration(array $column, AbstractPlatform $platform)
{
return strtoupper($this->getName());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment