Suppressed a defective error message and restored/added the missing line breaks

parent a92fa151
......@@ -98,32 +98,40 @@ abstract class AbstractMySQLDriver implements ExceptionConverterDriver, VersionA
switch ($exception->getCode()) {
case self::ER_LOCK_DEADLOCK:
return new Exception\DeadlockException($message, $exception);
case self::ER_LOCK_WAIT_TIMEOUT:
return new Exception\LockWaitTimeoutException($message, $exception);
case self::ER_TABLE_EXISTS_ERROR:
return new Exception\TableExistsException($message, $exception);
case self::ER_BAD_TABLE_ERROR:
case self::ER_NO_SUCH_TABLE:
return new Exception\TableNotFoundException($message, $exception);
case self::ER_NO_REFERENCED_ROW:
case self::ER_ROW_IS_REFERENCED:
case self::ER_ROW_IS_REFERENCED_2:
case self::ER_NO_REFERENCED_ROW_2:
case self::ER_TRUNCATE_ILLEGAL_FK:
return new Exception\ForeignKeyConstraintViolationException($message, $exception);
case self::ER_DUP_ENTRY:
case self::ER_FOREIGN_DUPLICATE_KEY_OLD_UNUSED:
case self::ER_DUP_ENTRY_AUTOINCREMENT_CASE:
case self::ER_DUP_ENTRY_WITH_KEY_NAME:
return new Exception\UniqueConstraintViolationException($message, $exception);
case self::ER_BAD_FIELD_ERROR:
case self::ER_WRONG_COLUMN_NAME:
case self::ER_LOAD_DATA_INVALID_COLUMN:
return new Exception\InvalidFieldNameException($message, $exception);
case self::ER_NON_UNIQ_ERROR:
case self::ER_DUP_FIELDNAME:
case self::ER_FIELD_SPECIFIED_TWICE:
return new Exception\NonUniqueFieldNameException($message, $exception);
case self::ER_PARSE_ERROR:
case self::ER_SYNTAX_ERROR:
case self::ER_WARN_DEPRECATED_SYNTAX:
......@@ -137,6 +145,7 @@ abstract class AbstractMySQLDriver implements ExceptionConverterDriver, VersionA
case self::ER_WARN_DEPRECATED_SYNTAX_WITH_VER:
case self::ER_CONFLICT_FN_PARSE_ERROR:
return new Exception\SyntaxErrorException($message, $exception);
case self::ER_DBACCESS_DENIED_ERROR:
case self::ER_ACCESS_DENIED_ERROR:
case self::ER_NO_DB_ERROR:
......@@ -150,6 +159,7 @@ abstract class AbstractMySQLDriver implements ExceptionConverterDriver, VersionA
case self::CR_CONNECTION_ERROR:
case self::CR_UNKNOWN_HOST:
return new Exception\ConnectionException($message, $exception);
case self::ER_BAD_NULL_ERROR:
case self::ER_NULL_COLUMN_IN_INDEX:
case self::ER_INVALID_USE_OF_NULL:
......
......@@ -27,22 +27,30 @@ abstract class AbstractOracleDriver implements Driver, ExceptionConverterDriver
case 2299:
case 38911:
return new Exception\UniqueConstraintViolationException($message, $exception);
case 904:
return new Exception\InvalidFieldNameException($message, $exception);
case 918:
case 960:
return new Exception\NonUniqueFieldNameException($message, $exception);
case 923:
return new Exception\SyntaxErrorException($message, $exception);
case 942:
return new Exception\TableNotFoundException($message, $exception);
case 955:
return new Exception\TableExistsException($message, $exception);
case 1017:
case 12545:
return new Exception\ConnectionException($message, $exception);
case 1400:
return new Exception\NotNullConstraintViolationException($message, $exception);
case 2266:
case 2291:
case 2292:
......
......@@ -35,6 +35,7 @@ abstract class AbstractPostgreSQLDriver implements ExceptionConverterDriver, Ver
case '40001':
case '40P01':
return new Exception\DeadlockException($message, $exception);
case '0A000':
// Foreign key constraint violations during a TRUNCATE operation
// are considered "feature not supported" in PostgreSQL.
......@@ -43,20 +44,28 @@ abstract class AbstractPostgreSQLDriver implements ExceptionConverterDriver, Ver
}
break;
case '23502':
return new Exception\NotNullConstraintViolationException($message, $exception);
case '23503':
return new Exception\ForeignKeyConstraintViolationException($message, $exception);
case '23505':
return new Exception\UniqueConstraintViolationException($message, $exception);
case '42601':
return new Exception\SyntaxErrorException($message, $exception);
case '42702':
return new Exception\NonUniqueFieldNameException($message, $exception);
case '42703':
return new Exception\InvalidFieldNameException($message, $exception);
case '42P01':
return new Exception\TableNotFoundException($message, $exception);
case '42P07':
return new Exception\TableExistsException($message, $exception);
}
......
......@@ -33,31 +33,41 @@ abstract class AbstractSQLAnywhereDriver implements ExceptionConverterDriver, Ve
case -307:
case -684:
return new Exception\DeadlockException($message, $exception);
case -210:
case -1175:
case -1281:
return new Exception\LockWaitTimeoutException($message, $exception);
case -100:
case -103:
case -832:
return new Exception\ConnectionException($message, $exception);
case -143:
return new Exception\InvalidFieldNameException($message, $exception);
case -193:
case -196:
return new Exception\UniqueConstraintViolationException($message, $exception);
case -194:
case -198:
return new Exception\ForeignKeyConstraintViolationException($message, $exception);
case -144:
return new Exception\NonUniqueFieldNameException($message, $exception);
case -184:
case -195:
return new Exception\NotNullConstraintViolationException($message, $exception);
case -131:
return new Exception\SyntaxErrorException($message, $exception);
case -110:
return new Exception\TableExistsException($message, $exception);
case -141:
case -1041:
return new Exception\TableNotFoundException($message, $exception);
......@@ -79,10 +89,7 @@ abstract class AbstractSQLAnywhereDriver implements ExceptionConverterDriver, Ve
);
}
switch (true) {
default:
return new SQLAnywherePlatform();
}
return new SQLAnywherePlatform();
}
public function getDatabasePlatform() : AbstractPlatform
......
......@@ -227,10 +227,13 @@ final class DB2Statement implements IteratorAggregate, Statement
switch ($fetchMode) {
case FetchMode::COLUMN:
return $this->fetchColumn();
case FetchMode::MIXED:
return db2_fetch_both($this->stmt);
case FetchMode::ASSOCIATIVE:
return db2_fetch_assoc($this->stmt);
case FetchMode::CUSTOM_OBJECT:
$className = $this->defaultFetchClass;
$ctorArgs = $this->defaultFetchClassCtorArgs;
......@@ -247,10 +250,13 @@ final class DB2Statement implements IteratorAggregate, Statement
}
return $result;
case FetchMode::NUMERIC:
return db2_fetch_array($this->stmt);
case FetchMode::STANDARD_OBJECT:
return db2_fetch_object($this->stmt);
default:
throw new DB2Exception('Given Fetch-Style ' . $fetchMode . ' is not supported.');
}
......@@ -270,12 +276,14 @@ final class DB2Statement implements IteratorAggregate, Statement
}
break;
case FetchMode::COLUMN:
while (($row = $this->fetchColumn()) !== false) {
$rows[] = $row;
}
break;
default:
while (($row = $this->fetch($fetchMode)) !== false) {
$rows[] = $row;
......
......@@ -361,10 +361,13 @@ final class MysqliStatement implements IteratorAggregate, Statement
switch ($fetchMode) {
case FetchMode::ASSOCIATIVE:
return $assoc;
case FetchMode::MIXED:
return $assoc + $values;
case FetchMode::STANDARD_OBJECT:
return (object) $assoc;
default:
throw UnknownFetchMode::new($fetchMode);
}
......
......@@ -161,8 +161,10 @@ final class OCI8Statement implements IteratorAggregate, Statement
switch ($type) {
case ParameterType::BINARY:
return OCI_B_BIN;
case ParameterType::LARGE_OBJECT:
return OCI_B_BLOB;
default:
return SQLT_CHR;
}
......
......@@ -184,10 +184,13 @@ final class SQLAnywhereStatement implements IteratorAggregate, Statement
switch ($fetchMode) {
case FetchMode::COLUMN:
return $this->fetchColumn();
case FetchMode::ASSOCIATIVE:
return sasql_fetch_assoc($this->result);
case FetchMode::MIXED:
return sasql_fetch_array($this->result, SASQL_BOTH);
case FetchMode::CUSTOM_OBJECT:
$className = $this->defaultFetchClass;
$ctorArgs = $this->defaultFetchClassCtorArgs;
......@@ -204,10 +207,13 @@ final class SQLAnywhereStatement implements IteratorAggregate, Statement
}
return $result;
case FetchMode::NUMERIC:
return sasql_fetch_row($this->result);
case FetchMode::STANDARD_OBJECT:
return sasql_fetch_object($this->result);
default:
throw new SQLAnywhereException(sprintf('Fetch mode is not supported %d.', $fetchMode));
}
......
......@@ -2246,6 +2246,7 @@ abstract class AbstractPlatform
case 'RESTRICT':
case 'SET DEFAULT':
return $upper;
default:
throw new InvalidArgumentException(sprintf('Invalid foreign key action "%s".', $upper));
}
......@@ -2438,12 +2439,16 @@ abstract class AbstractPlatform
switch ($level) {
case TransactionIsolationLevel::READ_UNCOMMITTED:
return 'READ UNCOMMITTED';
case TransactionIsolationLevel::READ_COMMITTED:
return 'READ COMMITTED';
case TransactionIsolationLevel::REPEATABLE_READ:
return 'REPEATABLE READ';
case TransactionIsolationLevel::SERIALIZABLE:
return 'SERIALIZABLE';
default:
throw new InvalidArgumentException(sprintf('Invalid isolation level "%s".', $level));
}
......
......@@ -91,6 +91,7 @@ class OraclePlatform extends AbstractPlatform
}
return 'ADD_MONTHS(' . $date . ', ' . $operator . $interval . ')';
default:
$calculationClause = '';
......@@ -196,11 +197,14 @@ class OraclePlatform extends AbstractPlatform
switch ($level) {
case TransactionIsolationLevel::READ_UNCOMMITTED:
return 'READ UNCOMMITTED';
case TransactionIsolationLevel::READ_COMMITTED:
return 'READ COMMITTED';
case TransactionIsolationLevel::REPEATABLE_READ:
case TransactionIsolationLevel::SERIALIZABLE:
return 'SERIALIZABLE';
default:
return parent::_getTransactionIsolationLevelSQL($level);
}
......@@ -658,9 +662,11 @@ SQL
// NO ACTION cannot be declared explicitly,
// therefore returning empty string to indicate to OMIT the referential clause.
return '';
case 'CASCADE':
case 'SET NULL':
return $action;
default:
// SET DEFAULT is not supported, throw exception instead.
throw new InvalidArgumentException(sprintf('Invalid foreign key action "%s".', $action));
......
......@@ -51,10 +51,13 @@ class SQLAnywherePlatform extends AbstractPlatform
switch (true) {
case $lockMode === LockMode::NONE:
return $fromClause . ' WITH (NOLOCK)';
case $lockMode === LockMode::PESSIMISTIC_READ:
return $fromClause . ' WITH (UPDLOCK)';
case $lockMode === LockMode::PESSIMISTIC_WRITE:
return $fromClause . ' WITH (XLOCK)';
default:
return $fromClause;
}
......@@ -546,17 +549,15 @@ class SQLAnywherePlatform extends AbstractPlatform
case self::FOREIGN_KEY_MATCH_SIMPLE:
return 'SIMPLE';
break;
case self::FOREIGN_KEY_MATCH_FULL:
return 'FULL';
break;
case self::FOREIGN_KEY_MATCH_SIMPLE_UNIQUE:
return 'UNIQUE SIMPLE';
break;
case self::FOREIGN_KEY_MATCH_FULL_UNIQUE:
return 'UNIQUE FULL';
default:
throw new InvalidArgumentException(sprintf('Invalid foreign key match type "%s".', $type));
}
......@@ -991,8 +992,10 @@ SQL
switch ($mode) {
case TrimMode::LEADING:
return $this->getLtrimExpression($str);
case TrimMode::TRAILING:
return $this->getRtrimExpression($str);
default:
return 'TRIM(' . $str . ')';
}
......@@ -1003,8 +1006,10 @@ SQL
switch ($mode) {
case TrimMode::LEADING:
return 'SUBSTR(' . $str . ', PATINDEX(' . $pattern . ', ' . $str . '))';
case TrimMode::TRAILING:
return 'REVERSE(SUBSTR(REVERSE(' . $str . '), PATINDEX(' . $pattern . ', REVERSE(' . $str . '))))';
default:
return 'REVERSE(SUBSTR(REVERSE(SUBSTR(' . $str . ', PATINDEX(' . $pattern . ', ' . $str . '))), ' .
'PATINDEX(' . $pattern . ', REVERSE(SUBSTR(' . $str . ', PATINDEX(' . $pattern . ', ' . $str . '))))))';
......@@ -1157,12 +1162,16 @@ SQL
switch ($level) {
case TransactionIsolationLevel::READ_UNCOMMITTED:
return '0';
case TransactionIsolationLevel::READ_COMMITTED:
return '1';
case TransactionIsolationLevel::REPEATABLE_READ:
return '2';
case TransactionIsolationLevel::SERIALIZABLE:
return '3';
default:
throw new InvalidArgumentException(sprintf('Invalid isolation level %d.', $level));
}
......
......@@ -1001,8 +1001,10 @@ SQL
switch ($mode) {
case TrimMode::LEADING:
return 'LTRIM(' . $str . ')';
case TrimMode::TRAILING:
return 'RTRIM(' . $str . ')';
default:
return 'LTRIM(RTRIM(' . $str . '))';
}
......@@ -1349,10 +1351,13 @@ SQL
switch (true) {
case $lockMode === LockMode::NONE:
return $fromClause . ' WITH (NOLOCK)';
case $lockMode === LockMode::PESSIMISTIC_READ:
return $fromClause . ' WITH (HOLDLOCK, ROWLOCK)';
case $lockMode === LockMode::PESSIMISTIC_WRITE:
return $fromClause . ' WITH (UPDLOCK, ROWLOCK)';
default:
return $fromClause;
}
......
......@@ -44,8 +44,10 @@ class SqlitePlatform extends AbstractPlatform
switch ($type) {
case 'time':
return 'time(\'now\')';
case 'date':
return 'date(\'now\')';
case 'timestamp':
default:
return 'datetime(\'now\')';
......@@ -148,10 +150,12 @@ class SqlitePlatform extends AbstractPlatform
switch ($level) {
case TransactionIsolationLevel::READ_UNCOMMITTED:
return '0';
case TransactionIsolationLevel::READ_COMMITTED:
case TransactionIsolationLevel::REPEATABLE_READ:
case TransactionIsolationLevel::SERIALIZABLE:
return '1';
default:
return parent::_getTransactionIsolationLevelSQL($level);
}
......
......@@ -282,6 +282,7 @@ class QueryBuilder
case self::INSERT:
$sql = $this->getSQLForInsert();
break;
case self::DELETE:
$sql = $this->getSQLForDelete();
break;
......
......@@ -62,13 +62,16 @@ class DB2SchemaManager extends AbstractSchemaManager
case 'varchar':
$length = $tableColumn['length'];
break;
case 'character':
$length = $tableColumn['length'];
$fixed = true;
break;
case 'clob':
$length = $tableColumn['length'];
break;
case 'decimal':
case 'double':
case 'real':
......
......@@ -128,6 +128,7 @@ class MySqlSchemaManager extends AbstractSchemaManager
case 'binary':
$fixed = true;
break;
case 'float':
case 'double':
case 'real':
......@@ -140,24 +141,31 @@ class MySqlSchemaManager extends AbstractSchemaManager
}
break;
case 'tinytext':
$length = MySqlPlatform::LENGTH_LIMIT_TINYTEXT;
break;
case 'text':
$length = MySqlPlatform::LENGTH_LIMIT_TEXT;
break;
case 'mediumtext':
$length = MySqlPlatform::LENGTH_LIMIT_MEDIUMTEXT;
break;
case 'tinyblob':
$length = MySqlPlatform::LENGTH_LIMIT_TINYBLOB;
break;
case 'blob':
$length = MySqlPlatform::LENGTH_LIMIT_BLOB;
break;
case 'mediumblob':
$length = MySqlPlatform::LENGTH_LIMIT_MEDIUMBLOB;
break;
case 'tinyint':
case 'smallint':
case 'mediumint':
......@@ -231,8 +239,10 @@ class MySqlSchemaManager extends AbstractSchemaManager
switch ($columnDefault) {
case 'current_timestamp()':
return $platform->getCurrentTimestampSQL();
case 'curdate()':
return $platform->getCurrentDateSQL();
case 'curtime()':
return $platform->getCurrentTimeSQL();
}
......
......@@ -179,11 +179,13 @@ class OracleSchemaManager extends AbstractSchemaManager
}
break;
case 'varchar':
case 'varchar2':
case 'nvarchar2':
$length = (int) $tableColumn['char_length'];
break;
case 'char':
case 'nchar':
$length = (int) $tableColumn['char_length'];
......
......@@ -363,17 +363,20 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
$tableColumn['default'] = $this->fixVersion94NegativeNumericDefaultValue($tableColumn['default']);
$length = null;
break;
case 'int':
case 'int4':
case 'integer':
$tableColumn['default'] = $this->fixVersion94NegativeNumericDefaultValue($tableColumn['default']);
$length = null;
break;
case 'bigint':
case 'int8':
$tableColumn['default'] = $this->fixVersion94NegativeNumericDefaultValue($tableColumn['default']);
$length = null;
break;
case 'bool':
case 'boolean':
if ($tableColumn['default'] === 'true') {
......@@ -386,15 +389,18 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
$length = null;
break;
case 'text':
case '_varchar':
case 'varchar':
$tableColumn['default'] = $this->parseDefaultExpression($tableColumn['default']);
break;
case 'char':
case 'bpchar':
$fixed = true;
break;
case 'float':
case 'float4':
case 'float8':
......@@ -413,6 +419,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
}
break;
case 'year':
$length = null;
break;
......
......@@ -100,6 +100,7 @@ class SQLAnywhereSchemaManager extends AbstractSchemaManager
case 'char':
case 'nchar':
$fixed = true;
break;
}
switch ($type) {
......@@ -107,6 +108,7 @@ class SQLAnywhereSchemaManager extends AbstractSchemaManager
case 'float':
$precision = $tableColumn['length'];
$scale = $tableColumn['scale'];
break;
}
return new Column(
......
......@@ -97,6 +97,7 @@ class SQLServerSchemaManager extends AbstractSchemaManager
// Unicode data requires 2 bytes per character
$length /= 2;
break;
case 'varchar':
// TEXT type is returned as VARCHAR(MAX) with a length of -1
if ($length === -1) {
......
......@@ -19,8 +19,11 @@
<rule ref="Doctrine">
<exclude name="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming"/>
<exclude name="SlevomatCodingStandard.Classes.SuperfluousExceptionNaming"/>
<exclude name="SlevomatCodingStandard.ControlStructures.ControlStructureSpacing.IncorrectLinesCountAfterLastControlStructure"/>
<exclude name="SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants.DisallowedLateStaticBindingForConstant"/>
<exclude name="SlevomatCodingStandard.ControlStructures.ControlStructureSpacing.IncorrectLinesCountAfterLastControlStructure"/>
<!-- https://github.com/slevomat/coding-standard/issues/867 -->
<exclude name="SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing.IncorrectLinesCountAfterLastControlStructure"/>
<exclude name="Squiz.NamingConventions.ValidVariableName.PublicHasUnderscore"/>
</rule>
......
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