diff --git a/typo3/sysext/core/Tests/Unit/Database/Schema/Parser/ColumnDefinitionAttributesTest.php b/typo3/sysext/core/Tests/Unit/Database/Schema/Parser/ColumnDefinitionAttributesTest.php index fbe9b94c98e06e533647aa62d74d37e4e7363bd6..1207ef8248736d7501d2d2a5ca3f73012f1ca557 100644 --- a/typo3/sysext/core/Tests/Unit/Database/Schema/Parser/ColumnDefinitionAttributesTest.php +++ b/typo3/sysext/core/Tests/Unit/Database/Schema/Parser/ColumnDefinitionAttributesTest.php @@ -30,307 +30,336 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase; final class ColumnDefinitionAttributesTest extends UnitTestCase { /** - * Each parameter array consists of the following values: - * - column definition attributes SQL fragment - * - allow null values - * - has default value - * - default value - * - auto increment column - * - create index on column - * - create unique index column - * - use column as primary key - * - comment - * - column format - * - storage + * @return array<string, array{ + * columnAttribute: string, + * allowNull: bool, + * hasDefaultValue: bool, + * defaultValue: mixed, + * autoIncrement: bool, + * createIndex: bool, + * createUniqueIndex: bool, + * isPrimaryKey: bool, + * comment: string|null, + * columnFormat: string|null, + * storage: string|null + * }> */ public static function canParseColumnDefinitionAttributesDataProvider(): array { return [ 'NULL' => [ - 'NULL', - true, - false, - null, - false, - false, - false, - false, - null, - null, - null, + 'columnAttribute' => 'NULL', + 'allowNull' => true, + 'hasDefaultValue' => false, + 'defaultValue' => null, + 'autoIncrement' => false, + 'createIndex' => false, + 'createUniqueIndex' => false, + 'isPrimaryKey' => false, + 'comment' => null, + 'columnFormat' => null, + 'storage' => null, ], 'NOT NULL' => [ - 'NOT NULL', - false, - false, - null, - false, - false, - false, - false, - null, - null, - null, + 'columnAttribute' => 'NOT NULL', + 'allowNull' => false, + 'hasDefaultValue' => false, + 'defaultValue' => null, + 'autoIncrement' => false, + 'createIndex' => false, + 'createUniqueIndex' => false, + 'isPrimaryKey' => false, + 'comment' => null, + 'columnFormat' => null, + 'storage' => null, ], 'DEFAULT' => [ - "DEFAULT '0'", - true, - true, - '0', - false, - false, - false, - false, - null, - null, - null, + 'columnAttribute' => "DEFAULT '0'", + 'allowNull' => true, + 'hasDefaultValue' => true, + 'defaultValue' => '0', + 'autoIncrement' => false, + 'createIndex' => false, + 'createUniqueIndex' => false, + 'isPrimaryKey' => false, + 'comment' => null, + 'columnFormat' => null, + 'storage' => null, ], 'AUTO_INCREMENT' => [ - 'AUTO_INCREMENT', - true, - false, - null, - true, - false, - false, - false, - null, - null, - null, + 'columnAttribute' => 'AUTO_INCREMENT', + 'allowNull' => true, + 'hasDefaultValue' => false, + 'defaultValue' => null, + 'autoIncrement' => true, + 'createIndex' => false, + 'createUniqueIndex' => false, + 'isPrimaryKey' => false, + 'comment' => null, + 'columnFormat' => null, + 'storage' => null, ], 'UNIQUE' => [ - 'UNIQUE', - true, - false, - null, - false, - false, - true, - false, - null, - null, - null, + 'columnAttribute' => 'UNIQUE', + 'allowNull' => true, + 'hasDefaultValue' => false, + 'defaultValue' => null, + 'autoIncrement' => false, + 'createIndex' => false, + 'createUniqueIndex' => true, + 'isPrimaryKey' => false, + 'comment' => null, + 'columnFormat' => null, + 'storage' => null, ], 'UNIQUE KEY' => [ - 'UNIQUE KEY', - true, - false, - null, - false, - false, - true, - false, - null, - null, - null, + 'columnAttribute' => 'UNIQUE KEY', + 'allowNull' => true, + 'hasDefaultValue' => false, + 'defaultValue' => null, + 'autoIncrement' => false, + 'createIndex' => false, + 'createUniqueIndex' => true, + 'isPrimaryKey' => false, + 'comment' => null, + 'columnFormat' => null, + 'storage' => null, ], 'PRIMARY' => [ - 'PRIMARY', - true, - false, - null, - false, - false, - false, - true, - null, - null, - null, + 'columnAttribute' => 'PRIMARY', + 'allowNull' => true, + 'hasDefaultValue' => false, + 'defaultValue' => null, + 'autoIncrement' => false, + 'createIndex' => false, + 'createUniqueIndex' => false, + 'isPrimaryKey' => true, + 'comment' => null, + 'columnFormat' => null, + 'storage' => null, ], 'PRIMARY KEY' => [ - 'PRIMARY KEY', - true, - false, - null, - false, - false, - false, - true, - null, - null, - null, + 'columnAttribute' => 'PRIMARY KEY', + 'allowNull' => true, + 'hasDefaultValue' => false, + 'defaultValue' => null, + 'autoIncrement' => false, + 'createIndex' => false, + 'createUniqueIndex' => false, + 'isPrimaryKey' => true, + 'comment' => null, + 'columnFormat' => null, + 'storage' => null, ], 'KEY' => [ - 'KEY', - true, - false, - null, - false, - true, - false, - false, - null, - null, - null, + 'columnAttribute' => 'KEY', + 'allowNull' => true, + 'hasDefaultValue' => false, + 'defaultValue' => null, + 'autoIncrement' => false, + 'createIndex' => true, + 'createUniqueIndex' => false, + 'isPrimaryKey' => false, + 'comment' => null, + 'columnFormat' => null, + 'storage' => null, ], 'COMMENT' => [ - "COMMENT 'aComment'", - true, - false, - null, - false, - false, - false, - false, - 'aComment', - null, - null, + 'columnAttribute' => "COMMENT 'aComment'", + 'allowNull' => true, + 'hasDefaultValue' => false, + 'defaultValue' => null, + 'autoIncrement' => false, + 'createIndex' => false, + 'createUniqueIndex' => false, + 'isPrimaryKey' => false, + 'comment' => 'aComment', + 'columnFormat' => null, + 'storage' => null, ], 'COLUMN_FORMAT FIXED' => [ - 'COLUMN_FORMAT FIXED', - true, - false, - null, - false, - false, - false, - false, - null, - 'fixed', - null, + 'columnAttribute' => 'COLUMN_FORMAT FIXED', + 'allowNull' => true, + 'hasDefaultValue' => false, + 'defaultValue' => null, + 'autoIncrement' => false, + 'createIndex' => false, + 'createUniqueIndex' => false, + 'isPrimaryKey' => false, + 'comment' => null, + 'columnFormat' => 'fixed', + 'storage' => null, ], 'COLUMN_FORMAT DYNAMIC' => [ - 'COLUMN_FORMAT DYNAMIC', - true, - false, - null, - false, - false, - false, - false, - null, - 'dynamic', - null, + 'columnAttribute' => 'COLUMN_FORMAT DYNAMIC', + 'allowNull' => true, + 'hasDefaultValue' => false, + 'defaultValue' => null, + 'autoIncrement' => false, + 'createIndex' => false, + 'createUniqueIndex' => false, + 'isPrimaryKey' => false, + 'comment' => null, + 'columnFormat' => 'dynamic', + 'storage' => null, ], 'COLUMN_FORMAT DEFAULT' => [ - 'COLUMN_FORMAT DEFAULT', - true, - false, - null, - false, - false, - false, - false, - null, - null, - null, + 'columnAttribute' => 'COLUMN_FORMAT DEFAULT', + 'allowNull' => true, + 'hasDefaultValue' => false, + 'defaultValue' => null, + 'autoIncrement' => false, + 'createIndex' => false, + 'createUniqueIndex' => false, + 'isPrimaryKey' => false, + 'comment' => null, + 'columnFormat' => null, + 'storage' => null, ], 'STORAGE DISK' => [ - 'STORAGE DISK', - true, - false, - null, - false, - false, - false, - false, - null, - null, - 'disk', + 'columnAttribute' => 'STORAGE DISK', + 'allowNull' => true, + 'hasDefaultValue' => false, + 'defaultValue' => null, + 'autoIncrement' => false, + 'createIndex' => false, + 'createUniqueIndex' => false, + 'isPrimaryKey' => false, + 'comment' => null, + 'columnFormat' => null, + 'storage' => 'disk', ], 'STORAGE MEMORY' => [ - 'STORAGE MEMORY', - true, - false, - null, - false, - false, - false, - false, - null, - null, - 'memory', + 'columnAttribute' => 'STORAGE MEMORY', + 'allowNull' => true, + 'hasDefaultValue' => false, + 'defaultValue' => null, + 'autoIncrement' => false, + 'createIndex' => false, + 'createUniqueIndex' => false, + 'isPrimaryKey' => false, + 'comment' => null, + 'columnFormat' => null, + 'storage' => 'memory', ], 'STORAGE DEFAULT' => [ - 'STORAGE DEFAULT', - true, - false, - null, - false, - false, - false, - false, - null, - null, - null, + 'columnAttribute' => 'STORAGE DEFAULT', + 'allowNull' => true, + 'hasDefaultValue' => false, + 'defaultValue' => null, + 'autoIncrement' => false, + 'createIndex' => false, + 'createUniqueIndex' => false, + 'isPrimaryKey' => false, + 'comment' => null, + 'columnFormat' => null, + 'storage' => null, ], "NOT NULL DEFAULT '0'" => [ - "NOT NULL DEFAULT '0'", - false, - true, - '0', - false, - false, - false, - false, - null, - null, - null, + 'columnAttribute' => "NOT NULL DEFAULT '0'", + 'allowNull' => false, + 'hasDefaultValue' => true, + 'defaultValue' => '0', + 'autoIncrement' => false, + 'createIndex' => false, + 'createUniqueIndex' => false, + 'isPrimaryKey' => false, + 'comment' => null, + 'columnFormat' => null, + 'storage' => null, ], 'NOT NULL AUTO_INCREMENT' => [ - 'NOT NULL AUTO_INCREMENT', - false, - false, - null, - true, - false, - false, - false, - null, - null, - null, + 'columnAttribute' => 'NOT NULL AUTO_INCREMENT', + 'allowNull' => false, + 'hasDefaultValue' => false, + 'defaultValue' => null, + 'autoIncrement' => true, + 'createIndex' => false, + 'createUniqueIndex' => false, + 'isPrimaryKey' => false, + 'comment' => null, + 'columnFormat' => null, + 'storage' => null, ], 'NULL DEFAULT NULL' => [ - 'NULL DEFAULT NULL', - true, - true, - null, - false, - false, - false, - false, - null, - null, - null, + 'columnAttribute' => 'NULL DEFAULT NULL', + 'allowNull' => true, + 'hasDefaultValue' => true, + 'defaultValue' => null, + 'autoIncrement' => false, + 'createIndex' => false, + 'createUniqueIndex' => false, + 'isPrimaryKey' => false, + 'comment' => null, + 'columnFormat' => null, + 'storage' => null, ], 'NOT NULL PRIMARY KEY' => [ - 'NOT NULL PRIMARY KEY', - false, - false, - null, - false, - false, - false, - true, - null, - null, - null, + 'columnAttribute' => 'NOT NULL PRIMARY KEY', + 'allowNull' => false, + 'hasDefaultValue' => false, + 'defaultValue' => null, + 'autoIncrement' => false, + 'createIndex' => false, + 'createUniqueIndex' => false, + 'isPrimaryKey' => true, + 'comment' => null, + 'columnFormat' => null, + 'storage' => null, ], "NULL DEFAULT 'dummy' UNIQUE" => [ - "NULL DEFAULT 'dummy' UNIQUE", - true, - true, - 'dummy', - false, - false, - true, - false, - null, - null, - null, + 'columnAttribute' => "NULL DEFAULT 'dummy' UNIQUE", + 'allowNull' => true, + 'hasDefaultValue' => true, + 'defaultValue' => 'dummy', + 'autoIncrement' => false, + 'createIndex' => false, + 'createUniqueIndex' => true, + 'isPrimaryKey' => false, + 'comment' => null, + 'columnFormat' => null, + 'storage' => null, ], "NOT NULL DEFAULT '0' COMMENT 'aComment with blanks' AUTO_INCREMENT PRIMARY KEY COLUMN_FORMAT DYNAMIC" => [ - "NOT NULL DEFAULT '0' COMMENT 'aComment with blanks' AUTO_INCREMENT PRIMARY KEY COLUMN_FORMAT DYNAMIC", - false, - true, - '0', - true, - false, - false, - true, - 'aComment with blanks', - 'dynamic', - null, + 'columnAttribute' => "NOT NULL DEFAULT '0' COMMENT 'aComment with blanks' AUTO_INCREMENT PRIMARY KEY COLUMN_FORMAT DYNAMIC", + 'allowNull' => false, + 'hasDefaultValue' => true, + 'defaultValue' => '0', + 'autoIncrement' => true, + 'createIndex' => false, + 'createUniqueIndex' => false, + 'isPrimaryKey' => true, + 'comment' => 'aComment with blanks', + 'columnFormat' => 'dynamic', + 'storage' => null, + ], + // @todo Parsing default values with quoted quotes throws a "Error: Expected ... GOT: 'can" exception, but + // should work. Enable dataset along with the bugfix. + //"DEFAULT 'quoted single-quote \' can be parsed'" => [ + // 'columnAttribute' => "DEFAULT 'quoted single-quote (\') can be parsed'", + // 'allowNull' => true, + // 'hasDefaultValue' => true, + // 'defaultValue' => "quoted single-quote (') is parsed properly", + // 'autoIncrement' => false, + // 'createIndex' => false, + // 'createUniqueIndex' => false, + // 'isPrimaryKey' => false, + // 'comment' => null, + // 'columnFormat' => null, + // 'storage' => null, + //], + "DEFAULT 'double-quote (\") can be parsed'" => [ + 'columnAttribute' => "DEFAULT 'quoted single-quote (\") can be parsed'", + 'allowNull' => true, + 'hasDefaultValue' => true, + 'defaultValue' => 'quoted single-quote (") can be parsed', + 'autoIncrement' => false, + 'createIndex' => false, + 'createUniqueIndex' => false, + 'isPrimaryKey' => false, + 'comment' => null, + 'columnFormat' => null, + 'storage' => null, ], ]; }