| Total Complexity | 76 |
| Total Lines | 967 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
Complex classes like AbstractMySQLPlatformTestCase often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use AbstractMySQLPlatformTestCase, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 18 | abstract class AbstractMySQLPlatformTestCase extends AbstractPlatformTestCase |
||
| 19 | { |
||
| 20 | /** @var MySqlPlatform */ |
||
| 21 | protected $platform; |
||
| 22 | |||
| 23 | public function testModifyLimitQueryWitoutLimit() : void |
||
| 24 | { |
||
| 25 | $sql = $this->platform->modifyLimitQuery('SELECT n FROM Foo', null, 10); |
||
| 26 | self::assertEquals('SELECT n FROM Foo LIMIT 18446744073709551615 OFFSET 10', $sql); |
||
| 27 | } |
||
| 28 | |||
| 29 | public function testGenerateMixedCaseTableCreate() : void |
||
| 30 | { |
||
| 31 | $table = new Table('Foo'); |
||
| 32 | $table->addColumn('Bar', 'integer'); |
||
| 33 | |||
| 34 | $sql = $this->platform->getCreateTableSQL($table); |
||
| 35 | self::assertEquals('CREATE TABLE Foo (Bar INT NOT NULL) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB', array_shift($sql)); |
||
| 36 | } |
||
| 37 | |||
| 38 | public function getGenerateTableSql() : string |
||
| 39 | { |
||
| 40 | return 'CREATE TABLE test (id INT AUTO_INCREMENT NOT NULL, test VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB'; |
||
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * @return string[] |
||
| 45 | */ |
||
| 46 | public function getGenerateTableWithMultiColumnUniqueIndexSql() : array |
||
| 47 | { |
||
| 48 | return ['CREATE TABLE test (foo VARCHAR(255) DEFAULT NULL, bar VARCHAR(255) DEFAULT NULL, UNIQUE INDEX UNIQ_D87F7E0C8C73652176FF8CAA (foo, bar)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB']; |
||
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * {@inheritDoc} |
||
| 53 | */ |
||
| 54 | public function getGenerateAlterTableSql() : array |
||
| 55 | { |
||
| 56 | return ["ALTER TABLE mytable RENAME TO userlist, ADD quota INT DEFAULT NULL, DROP foo, CHANGE bar baz VARCHAR(255) DEFAULT 'def' NOT NULL, CHANGE bloo bloo TINYINT(1) DEFAULT '0' NOT NULL"]; |
||
| 57 | } |
||
| 58 | |||
| 59 | public function testGeneratesSqlSnippets() : void |
||
| 60 | { |
||
| 61 | self::assertEquals('RLIKE', $this->platform->getRegexpExpression(), 'Regular expression operator is not correct'); |
||
| 62 | self::assertEquals('`', $this->platform->getIdentifierQuoteCharacter(), 'Quote character is not correct'); |
||
| 63 | self::assertEquals('CONCAT(column1, column2, column3)', $this->platform->getConcatExpression('column1', 'column2', 'column3'), 'Concatenation function is not correct'); |
||
| 64 | } |
||
| 65 | |||
| 66 | public function testGeneratesTransactionsCommands() : void |
||
| 67 | { |
||
| 68 | self::assertEquals( |
||
| 69 | 'SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED', |
||
| 70 | $this->platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::READ_UNCOMMITTED), |
||
| 71 | '' |
||
| 72 | ); |
||
| 73 | self::assertEquals( |
||
| 74 | 'SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED', |
||
| 75 | $this->platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::READ_COMMITTED) |
||
| 76 | ); |
||
| 77 | self::assertEquals( |
||
| 78 | 'SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ', |
||
| 79 | $this->platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::REPEATABLE_READ) |
||
| 80 | ); |
||
| 81 | self::assertEquals( |
||
| 82 | 'SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE', |
||
| 83 | $this->platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::SERIALIZABLE) |
||
| 84 | ); |
||
| 85 | } |
||
| 86 | |||
| 87 | public function testGeneratesDDLSnippets() : void |
||
| 88 | { |
||
| 89 | self::assertEquals('SHOW DATABASES', $this->platform->getListDatabasesSQL()); |
||
| 90 | self::assertEquals('CREATE DATABASE foobar', $this->platform->getCreateDatabaseSQL('foobar')); |
||
| 91 | self::assertEquals('DROP DATABASE foobar', $this->platform->getDropDatabaseSQL('foobar')); |
||
| 92 | self::assertEquals('DROP TABLE foobar', $this->platform->getDropTableSQL('foobar')); |
||
| 93 | } |
||
| 94 | |||
| 95 | public function testGeneratesTypeDeclarationForIntegers() : void |
||
| 96 | { |
||
| 97 | self::assertEquals( |
||
| 98 | 'INT', |
||
| 99 | $this->platform->getIntegerTypeDeclarationSQL([]) |
||
| 100 | ); |
||
| 101 | self::assertEquals( |
||
| 102 | 'INT AUTO_INCREMENT', |
||
| 103 | $this->platform->getIntegerTypeDeclarationSQL(['autoincrement' => true]) |
||
| 104 | ); |
||
| 105 | self::assertEquals( |
||
| 106 | 'INT AUTO_INCREMENT', |
||
| 107 | $this->platform->getIntegerTypeDeclarationSQL( |
||
| 108 | ['autoincrement' => true, 'primary' => true] |
||
| 109 | ) |
||
| 110 | ); |
||
| 111 | } |
||
| 112 | |||
| 113 | public function testPrefersIdentityColumns() : void |
||
| 114 | { |
||
| 115 | self::assertTrue($this->platform->prefersIdentityColumns()); |
||
| 116 | } |
||
| 117 | |||
| 118 | public function testSupportsIdentityColumns() : void |
||
| 119 | { |
||
| 120 | self::assertTrue($this->platform->supportsIdentityColumns()); |
||
| 121 | } |
||
| 122 | |||
| 123 | public function testDoesSupportSavePoints() : void |
||
| 124 | { |
||
| 125 | self::assertTrue($this->platform->supportsSavepoints()); |
||
| 126 | } |
||
| 127 | |||
| 128 | public function getGenerateIndexSql() : string |
||
| 129 | { |
||
| 130 | return 'CREATE INDEX my_idx ON mytable (user_name, last_login)'; |
||
| 131 | } |
||
| 132 | |||
| 133 | public function getGenerateUniqueIndexSql() : string |
||
| 134 | { |
||
| 135 | return 'CREATE UNIQUE INDEX index_name ON test (test, test2)'; |
||
| 136 | } |
||
| 137 | |||
| 138 | public function getGenerateForeignKeySql() : string |
||
| 139 | { |
||
| 140 | return 'ALTER TABLE test ADD FOREIGN KEY (fk_name_id) REFERENCES other_table (id)'; |
||
| 141 | } |
||
| 142 | |||
| 143 | /** |
||
| 144 | * @group DBAL-126 |
||
| 145 | */ |
||
| 146 | public function testUniquePrimaryKey() : void |
||
| 147 | { |
||
| 148 | $keyTable = new Table('foo'); |
||
| 149 | $keyTable->addColumn('bar', 'integer'); |
||
| 150 | $keyTable->addColumn('baz', 'string'); |
||
| 151 | $keyTable->setPrimaryKey(['bar']); |
||
| 152 | $keyTable->addUniqueIndex(['baz']); |
||
| 153 | |||
| 154 | $oldTable = new Table('foo'); |
||
| 155 | $oldTable->addColumn('bar', 'integer'); |
||
| 156 | $oldTable->addColumn('baz', 'string'); |
||
| 157 | |||
| 158 | $c = new Comparator(); |
||
| 159 | $diff = $c->diffTable($oldTable, $keyTable); |
||
| 160 | |||
| 161 | self::assertNotNull($diff); |
||
| 162 | |||
| 163 | $sql = $this->platform->getAlterTableSQL($diff); |
||
| 164 | |||
| 165 | self::assertEquals([ |
||
| 166 | 'ALTER TABLE foo ADD PRIMARY KEY (bar)', |
||
| 167 | 'CREATE UNIQUE INDEX UNIQ_8C73652178240498 ON foo (baz)', |
||
| 168 | ], $sql); |
||
| 169 | } |
||
| 170 | |||
| 171 | public function testModifyLimitQuery() : void |
||
| 175 | } |
||
| 176 | |||
| 177 | public function testModifyLimitQueryWithEmptyOffset() : void |
||
| 178 | { |
||
| 179 | $sql = $this->platform->modifyLimitQuery('SELECT * FROM user', 10); |
||
| 180 | self::assertEquals('SELECT * FROM user LIMIT 10', $sql); |
||
| 181 | } |
||
| 182 | |||
| 183 | /** |
||
| 184 | * @group DDC-118 |
||
| 185 | */ |
||
| 186 | public function testGetDateTimeTypeDeclarationSql() : void |
||
| 187 | { |
||
| 188 | self::assertEquals('DATETIME', $this->platform->getDateTimeTypeDeclarationSQL(['version' => false])); |
||
| 189 | self::assertEquals('TIMESTAMP', $this->platform->getDateTimeTypeDeclarationSQL(['version' => true])); |
||
| 190 | self::assertEquals('DATETIME', $this->platform->getDateTimeTypeDeclarationSQL([])); |
||
| 191 | } |
||
| 192 | |||
| 193 | /** |
||
| 194 | * {@inheritDoc} |
||
| 195 | */ |
||
| 196 | public function getCreateTableColumnCommentsSQL() : array |
||
| 197 | { |
||
| 198 | return ["CREATE TABLE test (id INT NOT NULL COMMENT 'This is a comment', PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB"]; |
||
| 199 | } |
||
| 200 | |||
| 201 | /** |
||
| 202 | * {@inheritDoc} |
||
| 203 | */ |
||
| 204 | public function getAlterTableColumnCommentsSQL() : array |
||
| 205 | { |
||
| 206 | return ["ALTER TABLE mytable ADD quota INT NOT NULL COMMENT 'A comment', CHANGE foo foo VARCHAR(255) NOT NULL, CHANGE bar baz VARCHAR(255) NOT NULL COMMENT 'B comment'"]; |
||
| 207 | } |
||
| 208 | |||
| 209 | /** |
||
| 210 | * {@inheritDoc} |
||
| 211 | */ |
||
| 212 | public function getCreateTableColumnTypeCommentsSQL() : array |
||
| 213 | { |
||
| 214 | return ["CREATE TABLE test (id INT NOT NULL, data LONGTEXT NOT NULL COMMENT '(DC2Type:array)', PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB"]; |
||
| 215 | } |
||
| 216 | |||
| 217 | /** |
||
| 218 | * @group DBAL-237 |
||
| 219 | */ |
||
| 220 | public function testChangeIndexWithForeignKeys() : void |
||
| 221 | { |
||
| 222 | $index = new Index('idx', ['col'], false); |
||
| 223 | $unique = new Index('uniq', ['col'], true); |
||
| 224 | |||
| 225 | $diff = new TableDiff('test', [], [], [], ['uniq' => $unique], [], ['idx' => $index]); |
||
| 226 | $sql = $this->platform->getAlterTableSQL($diff); |
||
| 227 | self::assertEquals(['ALTER TABLE test DROP INDEX idx, ADD UNIQUE INDEX uniq (col)'], $sql); |
||
| 228 | |||
| 229 | $diff = new TableDiff('test', [], [], [], ['idx' => $index], [], ['unique' => $unique]); |
||
| 230 | $sql = $this->platform->getAlterTableSQL($diff); |
||
| 231 | self::assertEquals(['ALTER TABLE test DROP INDEX uniq, ADD INDEX idx (col)'], $sql); |
||
| 232 | } |
||
| 233 | |||
| 234 | /** |
||
| 235 | * @return string[] |
||
| 236 | */ |
||
| 237 | protected function getQuotedColumnInPrimaryKeySQL() : array |
||
| 238 | { |
||
| 239 | return ['CREATE TABLE `quoted` (`create` VARCHAR(255) NOT NULL, PRIMARY KEY(`create`)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB']; |
||
| 240 | } |
||
| 241 | |||
| 242 | /** |
||
| 243 | * @return string[] |
||
| 244 | */ |
||
| 245 | protected function getQuotedColumnInIndexSQL() : array |
||
| 246 | { |
||
| 247 | return ['CREATE TABLE `quoted` (`create` VARCHAR(255) NOT NULL, INDEX IDX_22660D028FD6E0FB (`create`)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB']; |
||
| 248 | } |
||
| 249 | |||
| 250 | /** |
||
| 251 | * @return string[] |
||
| 252 | */ |
||
| 253 | protected function getQuotedNameInIndexSQL() : array |
||
| 254 | { |
||
| 255 | return ['CREATE TABLE test (column1 VARCHAR(255) NOT NULL, INDEX `key` (column1)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB']; |
||
| 256 | } |
||
| 257 | |||
| 258 | /** |
||
| 259 | * @return string[] |
||
| 260 | */ |
||
| 261 | protected function getQuotedColumnInForeignKeySQL() : array |
||
| 262 | { |
||
| 263 | return [ |
||
| 264 | 'CREATE TABLE `quoted` (`create` VARCHAR(255) NOT NULL, foo VARCHAR(255) NOT NULL, `bar` VARCHAR(255) NOT NULL) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB', |
||
| 265 | 'ALTER TABLE `quoted` ADD CONSTRAINT FK_WITH_RESERVED_KEYWORD FOREIGN KEY (`create`, foo, `bar`) REFERENCES `foreign` (`create`, bar, `foo-bar`)', |
||
| 266 | 'ALTER TABLE `quoted` ADD CONSTRAINT FK_WITH_NON_RESERVED_KEYWORD FOREIGN KEY (`create`, foo, `bar`) REFERENCES foo (`create`, bar, `foo-bar`)', |
||
| 267 | 'ALTER TABLE `quoted` ADD CONSTRAINT FK_WITH_INTENDED_QUOTATION FOREIGN KEY (`create`, foo, `bar`) REFERENCES `foo-bar` (`create`, bar, `foo-bar`)', |
||
| 268 | ]; |
||
| 269 | } |
||
| 270 | |||
| 271 | public function testCreateTableWithFulltextIndex() : void |
||
| 272 | { |
||
| 273 | $table = new Table('fulltext_table'); |
||
| 274 | $table->addOption('engine', 'MyISAM'); |
||
| 275 | $table->addColumn('text', 'text'); |
||
| 276 | $table->addIndex(['text'], 'fulltext_text'); |
||
| 277 | |||
| 278 | $index = $table->getIndex('fulltext_text'); |
||
| 279 | $index->addFlag('fulltext'); |
||
| 280 | |||
| 281 | $sql = $this->platform->getCreateTableSQL($table); |
||
| 282 | self::assertEquals(['CREATE TABLE fulltext_table (text LONGTEXT NOT NULL, FULLTEXT INDEX fulltext_text (text)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = MyISAM'], $sql); |
||
| 283 | } |
||
| 284 | |||
| 285 | public function testCreateTableWithSpatialIndex() : void |
||
| 286 | { |
||
| 287 | $table = new Table('spatial_table'); |
||
| 288 | $table->addOption('engine', 'MyISAM'); |
||
| 289 | $table->addColumn('point', 'text'); // This should be a point type |
||
| 290 | $table->addIndex(['point'], 'spatial_text'); |
||
| 291 | |||
| 292 | $index = $table->getIndex('spatial_text'); |
||
| 293 | $index->addFlag('spatial'); |
||
| 294 | |||
| 295 | $sql = $this->platform->getCreateTableSQL($table); |
||
| 296 | self::assertEquals(['CREATE TABLE spatial_table (point LONGTEXT NOT NULL, SPATIAL INDEX spatial_text (point)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = MyISAM'], $sql); |
||
| 297 | } |
||
| 298 | |||
| 299 | public function testClobTypeDeclarationSQL() : void |
||
| 300 | { |
||
| 301 | self::assertEquals('TINYTEXT', $this->platform->getClobTypeDeclarationSQL(['length' => 1])); |
||
| 302 | self::assertEquals('TINYTEXT', $this->platform->getClobTypeDeclarationSQL(['length' => 255])); |
||
| 303 | self::assertEquals('TEXT', $this->platform->getClobTypeDeclarationSQL(['length' => 256])); |
||
| 304 | self::assertEquals('TEXT', $this->platform->getClobTypeDeclarationSQL(['length' => 65535])); |
||
| 305 | self::assertEquals('MEDIUMTEXT', $this->platform->getClobTypeDeclarationSQL(['length' => 65536])); |
||
| 306 | self::assertEquals('MEDIUMTEXT', $this->platform->getClobTypeDeclarationSQL(['length' => 16777215])); |
||
| 307 | self::assertEquals('LONGTEXT', $this->platform->getClobTypeDeclarationSQL(['length' => 16777216])); |
||
| 308 | self::assertEquals('LONGTEXT', $this->platform->getClobTypeDeclarationSQL([])); |
||
| 309 | } |
||
| 310 | |||
| 311 | public function testBlobTypeDeclarationSQL() : void |
||
| 312 | { |
||
| 313 | self::assertEquals('TINYBLOB', $this->platform->getBlobTypeDeclarationSQL(['length' => 1])); |
||
| 314 | self::assertEquals('TINYBLOB', $this->platform->getBlobTypeDeclarationSQL(['length' => 255])); |
||
| 315 | self::assertEquals('BLOB', $this->platform->getBlobTypeDeclarationSQL(['length' => 256])); |
||
| 316 | self::assertEquals('BLOB', $this->platform->getBlobTypeDeclarationSQL(['length' => 65535])); |
||
| 317 | self::assertEquals('MEDIUMBLOB', $this->platform->getBlobTypeDeclarationSQL(['length' => 65536])); |
||
| 318 | self::assertEquals('MEDIUMBLOB', $this->platform->getBlobTypeDeclarationSQL(['length' => 16777215])); |
||
| 319 | self::assertEquals('LONGBLOB', $this->platform->getBlobTypeDeclarationSQL(['length' => 16777216])); |
||
| 320 | self::assertEquals('LONGBLOB', $this->platform->getBlobTypeDeclarationSQL([])); |
||
| 321 | } |
||
| 322 | |||
| 323 | /** |
||
| 324 | * @group DBAL-400 |
||
| 325 | */ |
||
| 326 | public function testAlterTableAddPrimaryKey() : void |
||
| 327 | { |
||
| 328 | $table = new Table('alter_table_add_pk'); |
||
| 329 | $table->addColumn('id', 'integer'); |
||
| 330 | $table->addColumn('foo', 'integer'); |
||
| 331 | $table->addIndex(['id'], 'idx_id'); |
||
| 332 | |||
| 333 | $comparator = new Comparator(); |
||
| 334 | $diffTable = clone $table; |
||
| 335 | |||
| 336 | $diffTable->dropIndex('idx_id'); |
||
| 337 | $diffTable->setPrimaryKey(['id']); |
||
| 338 | |||
| 339 | $diff = $comparator->diffTable($table, $diffTable); |
||
| 340 | |||
| 341 | self::assertNotNull($diff); |
||
| 342 | |||
| 343 | self::assertEquals( |
||
| 344 | ['DROP INDEX idx_id ON alter_table_add_pk', 'ALTER TABLE alter_table_add_pk ADD PRIMARY KEY (id)'], |
||
| 345 | $this->platform->getAlterTableSQL($diff) |
||
| 346 | ); |
||
| 347 | } |
||
| 348 | |||
| 349 | /** |
||
| 350 | * @group DBAL-1132 |
||
| 351 | */ |
||
| 352 | public function testAlterPrimaryKeyWithAutoincrementColumn() : void |
||
| 353 | { |
||
| 354 | $table = new Table('alter_primary_key'); |
||
| 355 | $table->addColumn('id', 'integer', ['autoincrement' => true]); |
||
| 356 | $table->addColumn('foo', 'integer'); |
||
| 357 | $table->setPrimaryKey(['id']); |
||
| 358 | |||
| 359 | $comparator = new Comparator(); |
||
| 360 | $diffTable = clone $table; |
||
| 361 | |||
| 362 | $diffTable->dropPrimaryKey(); |
||
| 363 | $diffTable->setPrimaryKey(['foo']); |
||
| 364 | |||
| 365 | $diff = $comparator->diffTable($table, $diffTable); |
||
| 366 | |||
| 367 | self::assertNotNull($diff); |
||
| 368 | |||
| 369 | self::assertEquals( |
||
| 370 | [ |
||
| 371 | 'ALTER TABLE alter_primary_key MODIFY id INT NOT NULL', |
||
| 372 | 'ALTER TABLE alter_primary_key DROP PRIMARY KEY', |
||
| 373 | 'ALTER TABLE alter_primary_key ADD PRIMARY KEY (foo)', |
||
| 374 | ], |
||
| 375 | $this->platform->getAlterTableSQL($diff) |
||
| 376 | ); |
||
| 377 | } |
||
| 378 | |||
| 379 | /** |
||
| 380 | * @group DBAL-464 |
||
| 381 | */ |
||
| 382 | public function testDropPrimaryKeyWithAutoincrementColumn() : void |
||
| 383 | { |
||
| 384 | $table = new Table('drop_primary_key'); |
||
| 385 | $table->addColumn('id', 'integer', ['autoincrement' => true]); |
||
| 386 | $table->addColumn('foo', 'integer'); |
||
| 387 | $table->addColumn('bar', 'integer'); |
||
| 388 | $table->setPrimaryKey(['id', 'foo']); |
||
| 389 | |||
| 390 | $comparator = new Comparator(); |
||
| 391 | $diffTable = clone $table; |
||
| 392 | |||
| 393 | $diffTable->dropPrimaryKey(); |
||
| 394 | |||
| 395 | $diff = $comparator->diffTable($table, $diffTable); |
||
| 396 | |||
| 397 | self::assertNotNull($diff); |
||
| 398 | |||
| 399 | self::assertEquals( |
||
| 400 | [ |
||
| 401 | 'ALTER TABLE drop_primary_key MODIFY id INT NOT NULL', |
||
| 402 | 'ALTER TABLE drop_primary_key DROP PRIMARY KEY', |
||
| 403 | ], |
||
| 404 | $this->platform->getAlterTableSQL($diff) |
||
| 405 | ); |
||
| 406 | } |
||
| 407 | |||
| 408 | /** |
||
| 409 | * @group DBAL-2302 |
||
| 410 | */ |
||
| 411 | public function testDropNonAutoincrementColumnFromCompositePrimaryKeyWithAutoincrementColumn() : void |
||
| 412 | { |
||
| 413 | $table = new Table('tbl'); |
||
| 414 | $table->addColumn('id', 'integer', ['autoincrement' => true]); |
||
| 415 | $table->addColumn('foo', 'integer'); |
||
| 416 | $table->addColumn('bar', 'integer'); |
||
| 417 | $table->setPrimaryKey(['id', 'foo']); |
||
| 418 | |||
| 419 | $comparator = new Comparator(); |
||
| 420 | $diffTable = clone $table; |
||
| 421 | |||
| 422 | $diffTable->dropPrimaryKey(); |
||
| 423 | $diffTable->setPrimaryKey(['id']); |
||
| 424 | |||
| 425 | $diff = $comparator->diffTable($table, $diffTable); |
||
| 426 | |||
| 427 | self::assertNotNull($diff); |
||
| 428 | |||
| 429 | self::assertSame( |
||
| 430 | [ |
||
| 431 | 'ALTER TABLE tbl MODIFY id INT NOT NULL', |
||
| 432 | 'ALTER TABLE tbl DROP PRIMARY KEY', |
||
| 433 | 'ALTER TABLE tbl ADD PRIMARY KEY (id)', |
||
| 434 | ], |
||
| 435 | $this->platform->getAlterTableSQL($diff) |
||
| 436 | ); |
||
| 437 | } |
||
| 438 | |||
| 439 | /** |
||
| 440 | * @group DBAL-2302 |
||
| 441 | */ |
||
| 442 | public function testAddNonAutoincrementColumnToPrimaryKeyWithAutoincrementColumn() : void |
||
| 443 | { |
||
| 444 | $table = new Table('tbl'); |
||
| 445 | $table->addColumn('id', 'integer', ['autoincrement' => true]); |
||
| 446 | $table->addColumn('foo', 'integer'); |
||
| 447 | $table->addColumn('bar', 'integer'); |
||
| 448 | $table->setPrimaryKey(['id']); |
||
| 449 | |||
| 450 | $comparator = new Comparator(); |
||
| 451 | $diffTable = clone $table; |
||
| 452 | |||
| 453 | $diffTable->dropPrimaryKey(); |
||
| 454 | $diffTable->setPrimaryKey(['id', 'foo']); |
||
| 455 | |||
| 456 | $diff = $comparator->diffTable($table, $diffTable); |
||
| 457 | |||
| 458 | self::assertNotNull($diff); |
||
| 459 | |||
| 460 | self::assertSame( |
||
| 461 | [ |
||
| 462 | 'ALTER TABLE tbl MODIFY id INT NOT NULL', |
||
| 463 | 'ALTER TABLE tbl DROP PRIMARY KEY', |
||
| 464 | 'ALTER TABLE tbl ADD PRIMARY KEY (id, foo)', |
||
| 465 | ], |
||
| 466 | $this->platform->getAlterTableSQL($diff) |
||
| 467 | ); |
||
| 468 | } |
||
| 469 | |||
| 470 | /** |
||
| 471 | * @group DBAL-586 |
||
| 472 | */ |
||
| 473 | public function testAddAutoIncrementPrimaryKey() : void |
||
| 474 | { |
||
| 475 | $keyTable = new Table('foo'); |
||
| 476 | $keyTable->addColumn('id', 'integer', ['autoincrement' => true]); |
||
| 477 | $keyTable->addColumn('baz', 'string'); |
||
| 478 | $keyTable->setPrimaryKey(['id']); |
||
| 479 | |||
| 480 | $oldTable = new Table('foo'); |
||
| 481 | $oldTable->addColumn('baz', 'string'); |
||
| 482 | |||
| 483 | $c = new Comparator(); |
||
| 484 | $diff = $c->diffTable($oldTable, $keyTable); |
||
| 485 | |||
| 486 | self::assertNotNull($diff); |
||
| 487 | |||
| 488 | $sql = $this->platform->getAlterTableSQL($diff); |
||
| 489 | |||
| 490 | self::assertEquals(['ALTER TABLE foo ADD id INT AUTO_INCREMENT NOT NULL, ADD PRIMARY KEY (id)'], $sql); |
||
| 491 | } |
||
| 492 | |||
| 493 | public function testNamedPrimaryKey() : void |
||
| 494 | { |
||
| 495 | $diff = new TableDiff('mytable'); |
||
| 496 | $diff->changedIndexes['foo_index'] = new Index('foo_index', ['foo'], true, true); |
||
| 497 | |||
| 498 | $sql = $this->platform->getAlterTableSQL($diff); |
||
| 499 | |||
| 500 | self::assertEquals([ |
||
| 501 | 'ALTER TABLE mytable DROP PRIMARY KEY', |
||
| 502 | 'ALTER TABLE mytable ADD PRIMARY KEY (foo)', |
||
| 503 | ], $sql); |
||
| 504 | } |
||
| 505 | |||
| 506 | public function testAlterPrimaryKeyWithNewColumn() : void |
||
| 507 | { |
||
| 508 | $table = new Table('yolo'); |
||
| 509 | $table->addColumn('pkc1', 'integer'); |
||
| 510 | $table->addColumn('col_a', 'integer'); |
||
| 511 | $table->setPrimaryKey(['pkc1']); |
||
| 512 | |||
| 513 | $comparator = new Comparator(); |
||
| 514 | $diffTable = clone $table; |
||
| 515 | |||
| 516 | $diffTable->addColumn('pkc2', 'integer'); |
||
| 517 | $diffTable->dropPrimaryKey(); |
||
| 518 | $diffTable->setPrimaryKey(['pkc1', 'pkc2']); |
||
| 519 | |||
| 520 | $diff = $comparator->diffTable($table, $diffTable); |
||
| 521 | |||
| 522 | self::assertNotNull($diff); |
||
| 523 | |||
| 524 | self::assertSame( |
||
| 525 | [ |
||
| 526 | 'ALTER TABLE yolo DROP PRIMARY KEY', |
||
| 527 | 'ALTER TABLE yolo ADD pkc2 INT NOT NULL', |
||
| 528 | 'ALTER TABLE yolo ADD PRIMARY KEY (pkc1, pkc2)', |
||
| 529 | ], |
||
| 530 | $this->platform->getAlterTableSQL($diff) |
||
| 531 | ); |
||
| 532 | } |
||
| 533 | |||
| 534 | public function testInitializesDoctrineTypeMappings() : void |
||
| 535 | { |
||
| 536 | self::assertTrue($this->platform->hasDoctrineTypeMappingFor('binary')); |
||
| 537 | self::assertSame('binary', $this->platform->getDoctrineTypeMapping('binary')); |
||
| 538 | |||
| 539 | self::assertTrue($this->platform->hasDoctrineTypeMappingFor('varbinary')); |
||
| 540 | self::assertSame('binary', $this->platform->getDoctrineTypeMapping('varbinary')); |
||
| 541 | } |
||
| 542 | |||
| 543 | public function testGetVariableLengthStringTypeDeclarationSQLNoLength() : void |
||
| 544 | { |
||
| 545 | $this->expectException(ColumnLengthRequired::class); |
||
| 546 | |||
| 547 | parent::testGetVariableLengthStringTypeDeclarationSQLNoLength(); |
||
| 548 | } |
||
| 549 | |||
| 550 | public function testGetVariableLengthBinaryTypeDeclarationSQLNoLength() : void |
||
| 551 | { |
||
| 552 | $this->expectException(ColumnLengthRequired::class); |
||
| 553 | |||
| 554 | parent::testGetVariableLengthBinaryTypeDeclarationSQLNoLength(); |
||
| 555 | } |
||
| 556 | |||
| 557 | public function testDoesNotPropagateForeignKeyCreationForNonSupportingEngines() : void |
||
| 558 | { |
||
| 559 | $table = new Table('foreign_table'); |
||
| 560 | $table->addColumn('id', 'integer'); |
||
| 561 | $table->addColumn('fk_id', 'integer'); |
||
| 562 | $table->addForeignKeyConstraint('foreign_table', ['fk_id'], ['id']); |
||
| 563 | $table->setPrimaryKey(['id']); |
||
| 564 | $table->addOption('engine', 'MyISAM'); |
||
| 565 | |||
| 566 | self::assertSame( |
||
| 567 | ['CREATE TABLE foreign_table (id INT NOT NULL, fk_id INT NOT NULL, INDEX IDX_5690FFE2A57719D0 (fk_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = MyISAM'], |
||
| 568 | $this->platform->getCreateTableSQL( |
||
| 569 | $table, |
||
| 570 | AbstractPlatform::CREATE_INDEXES|AbstractPlatform::CREATE_FOREIGNKEYS |
||
| 571 | ) |
||
| 572 | ); |
||
| 573 | |||
| 574 | $table = clone $table; |
||
| 575 | $table->addOption('engine', 'InnoDB'); |
||
| 576 | |||
| 577 | self::assertSame( |
||
| 578 | [ |
||
| 579 | 'CREATE TABLE foreign_table (id INT NOT NULL, fk_id INT NOT NULL, INDEX IDX_5690FFE2A57719D0 (fk_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB', |
||
| 580 | 'ALTER TABLE foreign_table ADD CONSTRAINT FK_5690FFE2A57719D0 FOREIGN KEY (fk_id) REFERENCES foreign_table (id)', |
||
| 581 | ], |
||
| 582 | $this->platform->getCreateTableSQL( |
||
| 583 | $table, |
||
| 584 | AbstractPlatform::CREATE_INDEXES|AbstractPlatform::CREATE_FOREIGNKEYS |
||
| 585 | ) |
||
| 586 | ); |
||
| 587 | } |
||
| 588 | |||
| 589 | public function testDoesNotPropagateForeignKeyAlterationForNonSupportingEngines() : void |
||
| 590 | { |
||
| 591 | $table = new Table('foreign_table'); |
||
| 592 | $table->addColumn('id', 'integer'); |
||
| 593 | $table->addColumn('fk_id', 'integer'); |
||
| 594 | $table->addForeignKeyConstraint('foreign_table', ['fk_id'], ['id']); |
||
| 595 | $table->setPrimaryKey(['id']); |
||
| 596 | $table->addOption('engine', 'MyISAM'); |
||
| 597 | |||
| 598 | $addedForeignKeys = [new ForeignKeyConstraint(['fk_id'], 'foo', ['id'], 'fk_add')]; |
||
| 599 | $changedForeignKeys = [new ForeignKeyConstraint(['fk_id'], 'bar', ['id'], 'fk_change')]; |
||
| 600 | $removedForeignKeys = [new ForeignKeyConstraint(['fk_id'], 'baz', ['id'], 'fk_remove')]; |
||
| 601 | |||
| 602 | $tableDiff = new TableDiff('foreign_table'); |
||
| 603 | $tableDiff->fromTable = $table; |
||
| 604 | $tableDiff->addedForeignKeys = $addedForeignKeys; |
||
| 605 | $tableDiff->changedForeignKeys = $changedForeignKeys; |
||
| 606 | $tableDiff->removedForeignKeys = $removedForeignKeys; |
||
| 607 | |||
| 608 | self::assertEmpty($this->platform->getAlterTableSQL($tableDiff)); |
||
| 609 | |||
| 610 | $table->addOption('engine', 'InnoDB'); |
||
| 611 | |||
| 612 | $tableDiff = new TableDiff('foreign_table'); |
||
| 613 | $tableDiff->fromTable = $table; |
||
| 614 | $tableDiff->addedForeignKeys = $addedForeignKeys; |
||
| 615 | $tableDiff->changedForeignKeys = $changedForeignKeys; |
||
| 616 | $tableDiff->removedForeignKeys = $removedForeignKeys; |
||
| 617 | |||
| 618 | self::assertSame( |
||
| 619 | [ |
||
| 620 | 'ALTER TABLE foreign_table DROP FOREIGN KEY fk_remove', |
||
| 621 | 'ALTER TABLE foreign_table DROP FOREIGN KEY fk_change', |
||
| 622 | 'ALTER TABLE foreign_table ADD CONSTRAINT fk_add FOREIGN KEY (fk_id) REFERENCES foo (id)', |
||
| 623 | 'ALTER TABLE foreign_table ADD CONSTRAINT fk_change FOREIGN KEY (fk_id) REFERENCES bar (id)', |
||
| 624 | ], |
||
| 625 | $this->platform->getAlterTableSQL($tableDiff) |
||
| 626 | ); |
||
| 627 | } |
||
| 628 | |||
| 629 | /** |
||
| 630 | * @return string[] |
||
| 631 | * |
||
| 632 | * @group DBAL-234 |
||
| 633 | */ |
||
| 634 | protected function getAlterTableRenameIndexSQL() : array |
||
| 635 | { |
||
| 636 | return [ |
||
| 637 | 'DROP INDEX idx_foo ON mytable', |
||
| 638 | 'CREATE INDEX idx_bar ON mytable (id)', |
||
| 639 | ]; |
||
| 640 | } |
||
| 641 | |||
| 642 | /** |
||
| 643 | * @return string[] |
||
| 644 | * |
||
| 645 | * @group DBAL-234 |
||
| 646 | */ |
||
| 647 | protected function getQuotedAlterTableRenameIndexSQL() : array |
||
| 654 | ]; |
||
| 655 | } |
||
| 656 | |||
| 657 | /** |
||
| 658 | * @return string[] |
||
| 659 | * |
||
| 660 | * @group DBAL-807 |
||
| 661 | */ |
||
| 662 | protected function getAlterTableRenameIndexInSchemaSQL() : array |
||
| 663 | { |
||
| 664 | return [ |
||
| 665 | 'DROP INDEX idx_foo ON myschema.mytable', |
||
| 666 | 'CREATE INDEX idx_bar ON myschema.mytable (id)', |
||
| 667 | ]; |
||
| 668 | } |
||
| 669 | |||
| 670 | /** |
||
| 671 | * @return string[] |
||
| 672 | * |
||
| 673 | * @group DBAL-807 |
||
| 674 | */ |
||
| 675 | protected function getQuotedAlterTableRenameIndexInSchemaSQL() : array |
||
| 676 | { |
||
| 677 | return [ |
||
| 678 | 'DROP INDEX `create` ON `schema`.`table`', |
||
| 679 | 'CREATE INDEX `select` ON `schema`.`table` (id)', |
||
| 680 | 'DROP INDEX `foo` ON `schema`.`table`', |
||
| 681 | 'CREATE INDEX `bar` ON `schema`.`table` (id)', |
||
| 682 | ]; |
||
| 683 | } |
||
| 684 | |||
| 685 | protected function getQuotesDropForeignKeySQL() : string |
||
| 686 | { |
||
| 687 | return 'ALTER TABLE `table` DROP FOREIGN KEY `select`'; |
||
| 688 | } |
||
| 689 | |||
| 690 | protected function getQuotesDropConstraintSQL() : string |
||
| 691 | { |
||
| 692 | return 'ALTER TABLE `table` DROP CONSTRAINT `select`'; |
||
| 693 | } |
||
| 694 | |||
| 695 | public function testDoesNotPropagateDefaultValuesForUnsupportedColumnTypes() : void |
||
| 696 | { |
||
| 697 | $table = new Table('text_blob_default_value'); |
||
| 698 | $table->addColumn('def_text', 'text', ['default' => 'def']); |
||
| 699 | $table->addColumn('def_text_null', 'text', ['notnull' => false, 'default' => 'def']); |
||
| 700 | $table->addColumn('def_blob', 'blob', ['default' => 'def']); |
||
| 701 | $table->addColumn('def_blob_null', 'blob', ['notnull' => false, 'default' => 'def']); |
||
| 702 | |||
| 703 | self::assertSame( |
||
| 704 | ['CREATE TABLE text_blob_default_value (def_text LONGTEXT NOT NULL, def_text_null LONGTEXT DEFAULT NULL, def_blob LONGBLOB NOT NULL, def_blob_null LONGBLOB DEFAULT NULL) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB'], |
||
| 705 | $this->platform->getCreateTableSQL($table) |
||
| 706 | ); |
||
| 707 | |||
| 708 | $diffTable = clone $table; |
||
| 709 | $diffTable->changeColumn('def_text', ['default' => null]); |
||
| 710 | $diffTable->changeColumn('def_text_null', ['default' => null]); |
||
| 711 | $diffTable->changeColumn('def_blob', ['default' => null]); |
||
| 712 | $diffTable->changeColumn('def_blob_null', ['default' => null]); |
||
| 713 | |||
| 714 | $comparator = new Comparator(); |
||
| 715 | |||
| 716 | $diff = $comparator->diffTable($table, $diffTable); |
||
| 717 | |||
| 718 | self::assertNotNull($diff); |
||
| 719 | |||
| 720 | self::assertEmpty($this->platform->getAlterTableSQL($diff)); |
||
| 721 | } |
||
| 722 | |||
| 723 | /** |
||
| 724 | * {@inheritdoc} |
||
| 725 | */ |
||
| 726 | protected function getQuotedAlterTableRenameColumnSQL() : array |
||
| 727 | { |
||
| 728 | return ['ALTER TABLE mytable ' . |
||
| 729 | "CHANGE unquoted1 unquoted INT NOT NULL COMMENT 'Unquoted 1', " . |
||
| 730 | "CHANGE unquoted2 `where` INT NOT NULL COMMENT 'Unquoted 2', " . |
||
| 731 | "CHANGE unquoted3 `foo` INT NOT NULL COMMENT 'Unquoted 3', " . |
||
| 732 | "CHANGE `create` reserved_keyword INT NOT NULL COMMENT 'Reserved keyword 1', " . |
||
| 733 | "CHANGE `table` `from` INT NOT NULL COMMENT 'Reserved keyword 2', " . |
||
| 734 | "CHANGE `select` `bar` INT NOT NULL COMMENT 'Reserved keyword 3', " . |
||
| 735 | "CHANGE quoted1 quoted INT NOT NULL COMMENT 'Quoted 1', " . |
||
| 736 | "CHANGE quoted2 `and` INT NOT NULL COMMENT 'Quoted 2', " . |
||
| 737 | "CHANGE quoted3 `baz` INT NOT NULL COMMENT 'Quoted 3'", |
||
| 738 | ]; |
||
| 739 | } |
||
| 740 | |||
| 741 | /** |
||
| 742 | * {@inheritdoc} |
||
| 743 | */ |
||
| 744 | protected function getQuotedAlterTableChangeColumnLengthSQL() : array |
||
| 745 | { |
||
| 746 | return ['ALTER TABLE mytable ' . |
||
| 747 | "CHANGE unquoted1 unquoted1 VARCHAR(255) NOT NULL COMMENT 'Unquoted 1', " . |
||
| 748 | "CHANGE unquoted2 unquoted2 VARCHAR(255) NOT NULL COMMENT 'Unquoted 2', " . |
||
| 749 | "CHANGE unquoted3 unquoted3 VARCHAR(255) NOT NULL COMMENT 'Unquoted 3', " . |
||
| 750 | "CHANGE `create` `create` VARCHAR(255) NOT NULL COMMENT 'Reserved keyword 1', " . |
||
| 751 | "CHANGE `table` `table` VARCHAR(255) NOT NULL COMMENT 'Reserved keyword 2', " . |
||
| 752 | "CHANGE `select` `select` VARCHAR(255) NOT NULL COMMENT 'Reserved keyword 3'", |
||
| 753 | ]; |
||
| 754 | } |
||
| 755 | |||
| 756 | /** |
||
| 757 | * @group DBAL-423 |
||
| 758 | */ |
||
| 759 | public function testReturnsGuidTypeDeclarationSQL() : void |
||
| 760 | { |
||
| 761 | self::assertSame('CHAR(36)', $this->platform->getGuidTypeDeclarationSQL([])); |
||
| 762 | } |
||
| 763 | |||
| 764 | /** |
||
| 765 | * {@inheritdoc} |
||
| 766 | */ |
||
| 767 | public function getAlterTableRenameColumnSQL() : array |
||
| 768 | { |
||
| 769 | return ["ALTER TABLE foo CHANGE bar baz INT DEFAULT 666 NOT NULL COMMENT 'rename test'"]; |
||
| 770 | } |
||
| 771 | |||
| 772 | /** |
||
| 773 | * {@inheritdoc} |
||
| 774 | */ |
||
| 775 | protected function getQuotesTableIdentifiersInAlterTableSQL() : array |
||
| 776 | { |
||
| 777 | return [ |
||
| 778 | 'ALTER TABLE `foo` DROP FOREIGN KEY fk1', |
||
| 779 | 'ALTER TABLE `foo` DROP FOREIGN KEY fk2', |
||
| 780 | 'ALTER TABLE `foo` RENAME TO `table`, ADD bloo INT NOT NULL, DROP baz, CHANGE bar bar INT DEFAULT NULL, ' . |
||
| 781 | 'CHANGE id war INT NOT NULL', |
||
| 782 | 'ALTER TABLE `table` ADD CONSTRAINT fk_add FOREIGN KEY (fk3) REFERENCES fk_table (id)', |
||
| 783 | 'ALTER TABLE `table` ADD CONSTRAINT fk2 FOREIGN KEY (fk2) REFERENCES fk_table2 (id)', |
||
| 784 | ]; |
||
| 785 | } |
||
| 786 | |||
| 787 | /** |
||
| 788 | * {@inheritdoc} |
||
| 789 | */ |
||
| 790 | protected function getCommentOnColumnSQL() : array |
||
| 796 | ]; |
||
| 797 | } |
||
| 798 | |||
| 799 | protected function getQuotesReservedKeywordInUniqueConstraintDeclarationSQL() : string |
||
| 800 | { |
||
| 801 | return 'CONSTRAINT `select` UNIQUE (foo)'; |
||
| 802 | } |
||
| 803 | |||
| 804 | protected function getQuotesReservedKeywordInIndexDeclarationSQL() : string |
||
| 805 | { |
||
| 806 | return 'INDEX `select` (foo)'; |
||
| 807 | } |
||
| 808 | |||
| 809 | protected function getQuotesReservedKeywordInTruncateTableSQL() : string |
||
| 810 | { |
||
| 811 | return 'TRUNCATE `select`'; |
||
| 812 | } |
||
| 813 | |||
| 814 | /** |
||
| 815 | * {@inheritdoc} |
||
| 816 | */ |
||
| 817 | protected function getAlterStringToFixedStringSQL() : array |
||
| 818 | { |
||
| 819 | return ['ALTER TABLE mytable CHANGE name name CHAR(2) NOT NULL']; |
||
| 820 | } |
||
| 821 | |||
| 822 | /** |
||
| 823 | * {@inheritdoc} |
||
| 824 | */ |
||
| 825 | protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL() : array |
||
| 826 | { |
||
| 827 | return [ |
||
| 828 | 'ALTER TABLE mytable DROP FOREIGN KEY fk_foo', |
||
| 829 | 'DROP INDEX idx_foo ON mytable', |
||
| 830 | 'CREATE INDEX idx_foo_renamed ON mytable (foo)', |
||
| 831 | 'ALTER TABLE mytable ADD CONSTRAINT fk_foo FOREIGN KEY (foo) REFERENCES foreign_table (id)', |
||
| 832 | ]; |
||
| 833 | } |
||
| 834 | |||
| 835 | /** |
||
| 836 | * {@inheritdoc} |
||
| 837 | */ |
||
| 838 | public static function getGeneratesDecimalTypeDeclarationSQL() : iterable |
||
| 839 | { |
||
| 840 | return [ |
||
| 841 | [[], 'NUMERIC(10, 0)'], |
||
| 842 | [['unsigned' => true], 'NUMERIC(10, 0) UNSIGNED'], |
||
| 843 | [['unsigned' => false], 'NUMERIC(10, 0)'], |
||
| 844 | [['precision' => 5], 'NUMERIC(5, 0)'], |
||
| 845 | [['scale' => 5], 'NUMERIC(10, 5)'], |
||
| 846 | [['precision' => 8, 'scale' => 2], 'NUMERIC(8, 2)'], |
||
| 847 | ]; |
||
| 848 | } |
||
| 849 | |||
| 850 | /** |
||
| 851 | * {@inheritdoc} |
||
| 852 | */ |
||
| 853 | public static function getGeneratesFloatDeclarationSQL() : iterable |
||
| 854 | { |
||
| 855 | return [ |
||
| 856 | [[], 'DOUBLE PRECISION'], |
||
| 857 | [['unsigned' => true], 'DOUBLE PRECISION UNSIGNED'], |
||
| 858 | [['unsigned' => false], 'DOUBLE PRECISION'], |
||
| 859 | [['precision' => 5], 'DOUBLE PRECISION'], |
||
| 860 | [['scale' => 5], 'DOUBLE PRECISION'], |
||
| 861 | [['precision' => 8, 'scale' => 2], 'DOUBLE PRECISION'], |
||
| 862 | ]; |
||
| 863 | } |
||
| 864 | |||
| 865 | /** |
||
| 866 | * @group DBAL-2436 |
||
| 867 | */ |
||
| 868 | public function testQuotesTableNameInListTableIndexesSQL() : void |
||
| 873 | ); |
||
| 874 | } |
||
| 875 | |||
| 876 | /** |
||
| 877 | * @group DBAL-2436 |
||
| 878 | */ |
||
| 879 | public function testQuotesDatabaseNameInListTableIndexesSQL() : void |
||
| 884 | ); |
||
| 885 | } |
||
| 886 | |||
| 887 | /** |
||
| 888 | * @group DBAL-2436 |
||
| 889 | */ |
||
| 890 | public function testQuotesDatabaseNameInListViewsSQL() : void |
||
| 891 | { |
||
| 892 | self::assertStringContainsStringIgnoringCase( |
||
| 893 | "'Foo''Bar\\\\'", |
||
| 894 | $this->platform->getListViewsSQL("Foo'Bar\\") |
||
| 895 | ); |
||
| 896 | } |
||
| 897 | |||
| 898 | /** |
||
| 899 | * @group DBAL-2436 |
||
| 900 | */ |
||
| 901 | public function testQuotesTableNameInListTableForeignKeysSQL() : void |
||
| 902 | { |
||
| 903 | self::assertStringContainsStringIgnoringCase( |
||
| 904 | "'Foo''Bar\\\\'", |
||
| 905 | $this->platform->getListTableForeignKeysSQL("Foo'Bar\\") |
||
| 906 | ); |
||
| 907 | } |
||
| 908 | |||
| 909 | /** |
||
| 910 | * @group DBAL-2436 |
||
| 911 | */ |
||
| 912 | public function testQuotesDatabaseNameInListTableForeignKeysSQL() : void |
||
| 913 | { |
||
| 914 | self::assertStringContainsStringIgnoringCase( |
||
| 915 | "'Foo''Bar\\\\'", |
||
| 916 | $this->platform->getListTableForeignKeysSQL('foo_table', "Foo'Bar\\") |
||
| 917 | ); |
||
| 918 | } |
||
| 919 | |||
| 920 | /** |
||
| 921 | * @group DBAL-2436 |
||
| 922 | */ |
||
| 923 | public function testQuotesTableNameInListTableColumnsSQL() : void |
||
| 924 | { |
||
| 925 | self::assertStringContainsStringIgnoringCase( |
||
| 926 | "'Foo''Bar\\\\'", |
||
| 927 | $this->platform->getListTableColumnsSQL("Foo'Bar\\") |
||
| 928 | ); |
||
| 929 | } |
||
| 930 | |||
| 931 | /** |
||
| 932 | * @group DBAL-2436 |
||
| 933 | */ |
||
| 934 | public function testQuotesDatabaseNameInListTableColumnsSQL() : void |
||
| 939 | ); |
||
| 940 | } |
||
| 941 | |||
| 942 | public function testListTableForeignKeysSQLEvaluatesDatabase() : void |
||
| 943 | { |
||
| 944 | $sql = $this->platform->getListTableForeignKeysSQL('foo'); |
||
| 945 | |||
| 946 | self::assertStringContainsString('DATABASE()', $sql); |
||
| 947 | |||
| 948 | $sql = $this->platform->getListTableForeignKeysSQL('foo', 'bar'); |
||
| 949 | |||
| 950 | self::assertStringContainsString('bar', $sql); |
||
| 951 | self::assertStringNotContainsString('DATABASE()', $sql); |
||
| 952 | } |
||
| 953 | |||
| 954 | public function testColumnCharsetDeclarationSQL() : void |
||
| 955 | { |
||
| 956 | self::assertSame( |
||
| 957 | 'CHARACTER SET ascii', |
||
| 958 | $this->platform->getColumnCharsetDeclarationSQL('ascii') |
||
| 959 | ); |
||
| 960 | } |
||
| 961 | |||
| 962 | public function testSupportsColumnCollation() : void |
||
| 963 | { |
||
| 964 | self::assertTrue($this->platform->supportsColumnCollation()); |
||
| 965 | } |
||
| 966 | |||
| 967 | public function testColumnCollationDeclarationSQL() : void |
||
| 968 | { |
||
| 969 | self::assertSame( |
||
| 970 | 'COLLATE `ascii_general_ci`', |
||
| 971 | $this->platform->getColumnCollationDeclarationSQL('ascii_general_ci') |
||
| 972 | ); |
||
| 973 | } |
||
| 974 | |||
| 975 | public function testGetCreateTableSQLWithColumnCollation() : void |
||
| 985 | ); |
||
| 986 | } |
||
| 987 | } |
||
| 988 |