Completed
Push — 2.9 ( dac7d6...c7450a )
by Sergei
58:35 queued 41:25
created

testParseNullCreateOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Doctrine\Tests\DBAL\Functional\Schema;
4
5
use DateTime;
6
use Doctrine\DBAL\Platforms\MariaDb1027Platform;
7
use Doctrine\DBAL\Platforms\MySqlPlatform;
8
use Doctrine\DBAL\Schema\Comparator;
9
use Doctrine\DBAL\Schema\Schema;
10
use Doctrine\DBAL\Schema\Table;
11
use Doctrine\DBAL\Types\Type;
12
use Doctrine\Tests\Types\MySqlPointType;
13
use function implode;
14
use function sprintf;
15
16
class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
17
{
18
    protected function setUp()
19
    {
20
        parent::setUp();
21
22
        if (Type::hasType('point')) {
23
            return;
24
        }
25
26
        $this->resetSharedConn();
27
28
        Type::addType('point', MySqlPointType::class);
29
    }
30
31
    public function testSwitchPrimaryKeyColumns()
32
    {
33
        $tableOld = new Table('switch_primary_key_columns');
34
        $tableOld->addColumn('foo_id', 'integer');
35
        $tableOld->addColumn('bar_id', 'integer');
36
37
        $this->schemaManager->createTable($tableOld);
38
        $tableFetched = $this->schemaManager->listTableDetails('switch_primary_key_columns');
39
        $tableNew     = clone $tableFetched;
40
        $tableNew->setPrimaryKey(['bar_id', 'foo_id']);
41
42
        $comparator = new Comparator();
43
        $this->schemaManager->alterTable($comparator->diffTable($tableFetched, $tableNew));
44
45
        $table      = $this->schemaManager->listTableDetails('switch_primary_key_columns');
46
        $primaryKey = $table->getPrimaryKeyColumns();
47
48
        self::assertCount(2, $primaryKey);
49
        self::assertContains('bar_id', $primaryKey);
50
        self::assertContains('foo_id', $primaryKey);
51
    }
52
53
    public function testDiffTableBug()
54
    {
55
        $schema = new Schema();
56
        $table  = $schema->createTable('diffbug_routing_translations');
57
        $table->addColumn('id', 'integer');
58
        $table->addColumn('route', 'string');
59
        $table->addColumn('locale', 'string');
60
        $table->addColumn('attribute', 'string');
61
        $table->addColumn('localized_value', 'string');
62
        $table->addColumn('original_value', 'string');
63
        $table->setPrimaryKey(['id']);
64
        $table->addUniqueIndex(['route', 'locale', 'attribute']);
65
        $table->addIndex(['localized_value']); // this is much more selective than the unique index
66
67
        $this->schemaManager->createTable($table);
68
        $tableFetched = $this->schemaManager->listTableDetails('diffbug_routing_translations');
69
70
        $comparator = new Comparator();
71
        $diff       = $comparator->diffTable($tableFetched, $table);
72
73
        self::assertFalse($diff, 'no changes expected.');
74
    }
75
76
    public function testFulltextIndex()
77
    {
78
        $table = new Table('fulltext_index');
79
        $table->addColumn('text', 'text');
80
        $table->addIndex(['text'], 'f_index');
81
        $table->addOption('engine', 'MyISAM');
82
83
        $index = $table->getIndex('f_index');
84
        $index->addFlag('fulltext');
85
86
        $this->schemaManager->dropAndCreateTable($table);
87
88
        $indexes = $this->schemaManager->listTableIndexes('fulltext_index');
89
        self::assertArrayHasKey('f_index', $indexes);
90
        self::assertTrue($indexes['f_index']->hasFlag('fulltext'));
91
    }
92
93
    public function testSpatialIndex()
94
    {
95
        $table = new Table('spatial_index');
96
        $table->addColumn('point', 'point');
97
        $table->addIndex(['point'], 's_index');
98
        $table->addOption('engine', 'MyISAM');
99
100
        $index = $table->getIndex('s_index');
101
        $index->addFlag('spatial');
102
103
        $this->schemaManager->dropAndCreateTable($table);
104
105
        $indexes = $this->schemaManager->listTableIndexes('spatial_index');
106
        self::assertArrayHasKey('s_index', $indexes);
107
        self::assertTrue($indexes['s_index']->hasFlag('spatial'));
108
    }
109
110
    /**
111
     * @group DBAL-400
112
     */
113
    public function testAlterTableAddPrimaryKey()
114
    {
115
        $table = new Table('alter_table_add_pk');
116
        $table->addColumn('id', 'integer');
117
        $table->addColumn('foo', 'integer');
118
        $table->addIndex(['id'], 'idx_id');
119
120
        $this->schemaManager->createTable($table);
121
122
        $comparator = new Comparator();
123
        $diffTable  = clone $table;
124
125
        $diffTable->dropIndex('idx_id');
126
        $diffTable->setPrimaryKey(['id']);
127
128
        $this->schemaManager->alterTable($comparator->diffTable($table, $diffTable));
0 ignored issues
show
Bug introduced by
It seems like $comparator->diffTable($table, $diffTable) can also be of type false; however, parameter $tableDiff of Doctrine\DBAL\Schema\Abs...maManager::alterTable() does only seem to accept Doctrine\DBAL\Schema\TableDiff, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

128
        $this->schemaManager->alterTable(/** @scrutinizer ignore-type */ $comparator->diffTable($table, $diffTable));
Loading history...
129
130
        $table = $this->schemaManager->listTableDetails('alter_table_add_pk');
131
132
        self::assertFalse($table->hasIndex('idx_id'));
133
        self::assertTrue($table->hasPrimaryKey());
134
    }
135
136
    /**
137
     * @group DBAL-464
138
     */
139
    public function testDropPrimaryKeyWithAutoincrementColumn()
140
    {
141
        $table = new Table('drop_primary_key');
142
        $table->addColumn('id', 'integer', ['autoincrement' => true]);
143
        $table->addColumn('foo', 'integer');
144
        $table->setPrimaryKey(['id', 'foo']);
145
146
        $this->schemaManager->dropAndCreateTable($table);
147
148
        $diffTable = clone $table;
149
150
        $diffTable->dropPrimaryKey();
151
152
        $comparator = new Comparator();
153
154
        $this->schemaManager->alterTable($comparator->diffTable($table, $diffTable));
0 ignored issues
show
Bug introduced by
It seems like $comparator->diffTable($table, $diffTable) can also be of type false; however, parameter $tableDiff of Doctrine\DBAL\Schema\Abs...maManager::alterTable() does only seem to accept Doctrine\DBAL\Schema\TableDiff, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

154
        $this->schemaManager->alterTable(/** @scrutinizer ignore-type */ $comparator->diffTable($table, $diffTable));
Loading history...
155
156
        $table = $this->schemaManager->listTableDetails('drop_primary_key');
157
158
        self::assertFalse($table->hasPrimaryKey());
159
        self::assertFalse($table->getColumn('id')->getAutoincrement());
160
    }
161
162
    /**
163
     * @group DBAL-789
164
     */
165
    public function testDoesNotPropagateDefaultValuesForUnsupportedColumnTypes()
166
    {
167
        if ($this->schemaManager->getDatabasePlatform() instanceof MariaDb1027Platform) {
168
            $this->markTestSkipped(
169
                'MariaDb102Platform supports default values for BLOB and TEXT columns and will propagate values'
170
            );
171
        }
172
173
        $table = new Table('text_blob_default_value');
174
        $table->addColumn('def_text', 'text', ['default' => 'def']);
175
        $table->addColumn('def_text_null', 'text', ['notnull' => false, 'default' => 'def']);
176
        $table->addColumn('def_blob', 'blob', ['default' => 'def']);
177
        $table->addColumn('def_blob_null', 'blob', ['notnull' => false, 'default' => 'def']);
178
179
        $this->schemaManager->dropAndCreateTable($table);
180
181
        $onlineTable = $this->schemaManager->listTableDetails('text_blob_default_value');
182
183
        self::assertNull($onlineTable->getColumn('def_text')->getDefault());
184
        self::assertNull($onlineTable->getColumn('def_text_null')->getDefault());
185
        self::assertFalse($onlineTable->getColumn('def_text_null')->getNotnull());
186
        self::assertNull($onlineTable->getColumn('def_blob')->getDefault());
187
        self::assertNull($onlineTable->getColumn('def_blob_null')->getDefault());
188
        self::assertFalse($onlineTable->getColumn('def_blob_null')->getNotnull());
189
190
        $comparator = new Comparator();
191
192
        $this->schemaManager->alterTable($comparator->diffTable($table, $onlineTable));
193
194
        $onlineTable = $this->schemaManager->listTableDetails('text_blob_default_value');
195
196
        self::assertNull($onlineTable->getColumn('def_text')->getDefault());
197
        self::assertNull($onlineTable->getColumn('def_text_null')->getDefault());
198
        self::assertFalse($onlineTable->getColumn('def_text_null')->getNotnull());
199
        self::assertNull($onlineTable->getColumn('def_blob')->getDefault());
200
        self::assertNull($onlineTable->getColumn('def_blob_null')->getDefault());
201
        self::assertFalse($onlineTable->getColumn('def_blob_null')->getNotnull());
202
    }
203
204
    public function testColumnCollation()
205
    {
206
        $table                                  = new Table('test_collation');
207
        $table->addOption('collate', $collation = 'latin1_swedish_ci');
208
        $table->addOption('charset', 'latin1');
209
        $table->addColumn('id', 'integer');
210
        $table->addColumn('text', 'text');
211
        $table->addColumn('foo', 'text')->setPlatformOption('collation', 'latin1_swedish_ci');
212
        $table->addColumn('bar', 'text')->setPlatformOption('collation', 'utf8_general_ci');
213
        $this->schemaManager->dropAndCreateTable($table);
214
215
        $columns = $this->schemaManager->listTableColumns('test_collation');
216
217
        self::assertArrayNotHasKey('collation', $columns['id']->getPlatformOptions());
218
        self::assertEquals('latin1_swedish_ci', $columns['text']->getPlatformOption('collation'));
219
        self::assertEquals('latin1_swedish_ci', $columns['foo']->getPlatformOption('collation'));
220
        self::assertEquals('utf8_general_ci', $columns['bar']->getPlatformOption('collation'));
221
    }
222
223
    /**
224
     * @group DBAL-843
225
     */
226
    public function testListLobTypeColumns()
227
    {
228
        $tableName = 'lob_type_columns';
229
        $table     = new Table($tableName);
230
231
        $table->addColumn('col_tinytext', 'text', ['length' => MySqlPlatform::LENGTH_LIMIT_TINYTEXT]);
232
        $table->addColumn('col_text', 'text', ['length' => MySqlPlatform::LENGTH_LIMIT_TEXT]);
233
        $table->addColumn('col_mediumtext', 'text', ['length' => MySqlPlatform::LENGTH_LIMIT_MEDIUMTEXT]);
234
        $table->addColumn('col_longtext', 'text');
235
236
        $table->addColumn('col_tinyblob', 'text', ['length' => MySqlPlatform::LENGTH_LIMIT_TINYBLOB]);
237
        $table->addColumn('col_blob', 'blob', ['length' => MySqlPlatform::LENGTH_LIMIT_BLOB]);
238
        $table->addColumn('col_mediumblob', 'blob', ['length' => MySqlPlatform::LENGTH_LIMIT_MEDIUMBLOB]);
239
        $table->addColumn('col_longblob', 'blob');
240
241
        $this->schemaManager->dropAndCreateTable($table);
242
243
        $platform       = $this->schemaManager->getDatabasePlatform();
244
        $offlineColumns = $table->getColumns();
245
        $onlineColumns  = $this->schemaManager->listTableColumns($tableName);
246
247
        self::assertSame(
248
            $platform->getClobTypeDeclarationSQL($offlineColumns['col_tinytext']->toArray()),
249
            $platform->getClobTypeDeclarationSQL($onlineColumns['col_tinytext']->toArray())
250
        );
251
        self::assertSame(
252
            $platform->getClobTypeDeclarationSQL($offlineColumns['col_text']->toArray()),
253
            $platform->getClobTypeDeclarationSQL($onlineColumns['col_text']->toArray())
254
        );
255
        self::assertSame(
256
            $platform->getClobTypeDeclarationSQL($offlineColumns['col_mediumtext']->toArray()),
257
            $platform->getClobTypeDeclarationSQL($onlineColumns['col_mediumtext']->toArray())
258
        );
259
        self::assertSame(
260
            $platform->getClobTypeDeclarationSQL($offlineColumns['col_longtext']->toArray()),
261
            $platform->getClobTypeDeclarationSQL($onlineColumns['col_longtext']->toArray())
262
        );
263
264
        self::assertSame(
265
            $platform->getBlobTypeDeclarationSQL($offlineColumns['col_tinyblob']->toArray()),
266
            $platform->getBlobTypeDeclarationSQL($onlineColumns['col_tinyblob']->toArray())
267
        );
268
        self::assertSame(
269
            $platform->getBlobTypeDeclarationSQL($offlineColumns['col_blob']->toArray()),
270
            $platform->getBlobTypeDeclarationSQL($onlineColumns['col_blob']->toArray())
271
        );
272
        self::assertSame(
273
            $platform->getBlobTypeDeclarationSQL($offlineColumns['col_mediumblob']->toArray()),
274
            $platform->getBlobTypeDeclarationSQL($onlineColumns['col_mediumblob']->toArray())
275
        );
276
        self::assertSame(
277
            $platform->getBlobTypeDeclarationSQL($offlineColumns['col_longblob']->toArray()),
278
            $platform->getBlobTypeDeclarationSQL($onlineColumns['col_longblob']->toArray())
279
        );
280
    }
281
282
    /**
283
     * @group DBAL-423
284
     */
285
    public function testDiffListGuidTableColumn()
286
    {
287
        $offlineTable = new Table('list_guid_table_column');
288
        $offlineTable->addColumn('col_guid', 'guid');
289
290
        $this->schemaManager->dropAndCreateTable($offlineTable);
291
292
        $onlineTable = $this->schemaManager->listTableDetails('list_guid_table_column');
293
294
        $comparator = new Comparator();
295
296
        self::assertFalse(
297
            $comparator->diffTable($offlineTable, $onlineTable),
298
            'No differences should be detected with the offline vs online schema.'
299
        );
300
    }
301
302
    /**
303
     * @group DBAL-1082
304
     */
305
    public function testListDecimalTypeColumns()
306
    {
307
        $tableName = 'test_list_decimal_columns';
308
        $table     = new Table($tableName);
309
310
        $table->addColumn('col', 'decimal');
311
        $table->addColumn('col_unsigned', 'decimal', ['unsigned' => true]);
312
313
        $this->schemaManager->dropAndCreateTable($table);
314
315
        $columns = $this->schemaManager->listTableColumns($tableName);
316
317
        self::assertArrayHasKey('col', $columns);
318
        self::assertArrayHasKey('col_unsigned', $columns);
319
        self::assertFalse($columns['col']->getUnsigned());
320
        self::assertTrue($columns['col_unsigned']->getUnsigned());
321
    }
322
323
    /**
324
     * @group DBAL-1082
325
     */
326
    public function testListFloatTypeColumns()
327
    {
328
        $tableName = 'test_list_float_columns';
329
        $table     = new Table($tableName);
330
331
        $table->addColumn('col', 'float');
332
        $table->addColumn('col_unsigned', 'float', ['unsigned' => true]);
333
334
        $this->schemaManager->dropAndCreateTable($table);
335
336
        $columns = $this->schemaManager->listTableColumns($tableName);
337
338
        self::assertArrayHasKey('col', $columns);
339
        self::assertArrayHasKey('col_unsigned', $columns);
340
        self::assertFalse($columns['col']->getUnsigned());
341
        self::assertTrue($columns['col_unsigned']->getUnsigned());
342
    }
343
344
    public function testJsonColumnType() : void
345
    {
346
        $table = new Table('test_mysql_json');
347
        $table->addColumn('col_json', 'json');
348
        $this->schemaManager->dropAndCreateTable($table);
349
350
        $columns = $this->schemaManager->listTableColumns('test_mysql_json');
351
352
        self::assertSame(Type::JSON, $columns['col_json']->getType()->getName());
353
    }
354
355
    public function testColumnDefaultCurrentTimestamp() : void
356
    {
357
        $platform = $this->schemaManager->getDatabasePlatform();
358
359
        $table = new Table('test_column_defaults_current_timestamp');
360
361
        $currentTimeStampSql = $platform->getCurrentTimestampSQL();
362
363
        $table->addColumn('col_datetime', 'datetime', ['notnull' => true, 'default' => $currentTimeStampSql]);
364
        $table->addColumn('col_datetime_nullable', 'datetime', ['default' => $currentTimeStampSql]);
365
366
        $this->schemaManager->dropAndCreateTable($table);
367
368
        $onlineTable = $this->schemaManager->listTableDetails('test_column_defaults_current_timestamp');
369
        self::assertSame($currentTimeStampSql, $onlineTable->getColumn('col_datetime')->getDefault());
370
        self::assertSame($currentTimeStampSql, $onlineTable->getColumn('col_datetime_nullable')->getDefault());
371
372
        $comparator = new Comparator();
373
374
        $diff = $comparator->diffTable($table, $onlineTable);
375
        self::assertFalse($diff, 'Tables should be identical with column defaults.');
376
    }
377
378
    public function testColumnDefaultsAreValid()
379
    {
380
        $table = new Table('test_column_defaults_are_valid');
381
382
        $currentTimeStampSql = $this->schemaManager->getDatabasePlatform()->getCurrentTimestampSQL();
383
        $table->addColumn('col_datetime', 'datetime', ['default' => $currentTimeStampSql]);
384
        $table->addColumn('col_datetime_null', 'datetime', ['notnull' => false, 'default' => null]);
385
        $table->addColumn('col_int', 'integer', ['default' => 1]);
386
        $table->addColumn('col_neg_int', 'integer', ['default' => -1]);
387
        $table->addColumn('col_string', 'string', ['default' => 'A']);
388
        $table->addColumn('col_decimal', 'decimal', ['scale' => 3, 'precision' => 6, 'default' => -2.3]);
389
        $table->addColumn('col_date', 'date', ['default' => '2012-12-12']);
390
391
        $this->schemaManager->dropAndCreateTable($table);
392
393
        $this->connection->executeUpdate(
394
            'INSERT INTO test_column_defaults_are_valid () VALUES()'
395
        );
396
397
        $row = $this->connection->fetchAssoc(
398
            'SELECT *, DATEDIFF(CURRENT_TIMESTAMP(), col_datetime) as diff_seconds FROM test_column_defaults_are_valid'
399
        );
400
401
        self::assertInstanceOf(DateTime::class, DateTime::createFromFormat('Y-m-d H:i:s', $row['col_datetime']));
402
        self::assertNull($row['col_datetime_null']);
403
        self::assertSame('2012-12-12', $row['col_date']);
404
        self::assertSame('A', $row['col_string']);
405
        self::assertEquals(1, $row['col_int']);
406
        self::assertEquals(-1, $row['col_neg_int']);
407
        self::assertEquals('-2.300', $row['col_decimal']);
408
        self::assertLessThan(5, $row['diff_seconds']);
409
    }
410
411
    /**
412
     * MariaDB 10.2+ does support CURRENT_TIME and CURRENT_DATE as
413
     * column default values for time and date columns.
414
     * (Not supported on Mysql as of 5.7.19)
415
     *
416
     * Note that MariaDB 10.2+, when storing default in information_schema,
417
     * silently change CURRENT_TIMESTAMP as 'current_timestamp()',
418
     * CURRENT_TIME as 'currtime()' and CURRENT_DATE as 'currdate()'.
419
     * This test also ensure proper aliasing to not trigger a table diff.
420
     */
421
    public function testColumnDefaultValuesCurrentTimeAndDate() : void
422
    {
423
        if (! $this->schemaManager->getDatabasePlatform() instanceof MariaDb1027Platform) {
424
            $this->markTestSkipped('Only relevant for MariaDb102Platform.');
425
        }
426
427
        $platform = $this->schemaManager->getDatabasePlatform();
428
429
        $table = new Table('test_column_defaults_current_time_and_date');
430
431
        $currentTimestampSql = $platform->getCurrentTimestampSQL();
432
        $currentTimeSql      = $platform->getCurrentTimeSQL();
433
        $currentDateSql      = $platform->getCurrentDateSQL();
434
435
        $table->addColumn('col_datetime', 'datetime', ['default' => $currentTimestampSql]);
436
        $table->addColumn('col_date', 'date', ['default' => $currentDateSql]);
437
        $table->addColumn('col_time', 'time', ['default' => $currentTimeSql]);
438
439
        $this->schemaManager->dropAndCreateTable($table);
440
441
        $onlineTable = $this->schemaManager->listTableDetails('test_column_defaults_current_time_and_date');
442
443
        self::assertSame($currentTimestampSql, $onlineTable->getColumn('col_datetime')->getDefault());
444
        self::assertSame($currentDateSql, $onlineTable->getColumn('col_date')->getDefault());
445
        self::assertSame($currentTimeSql, $onlineTable->getColumn('col_time')->getDefault());
446
447
        $comparator = new Comparator();
448
449
        $diff = $comparator->diffTable($table, $onlineTable);
450
        self::assertFalse($diff, 'Tables should be identical with column defauts time and date.');
451
    }
452
453
    /**
454
     * Ensure default values (un-)escaping is properly done by mysql platforms.
455
     * The test is voluntarily relying on schema introspection due to current
456
     * doctrine limitations. Once #2850 is landed, this test can be removed.
457
     *
458
     * @see https://dev.mysql.com/doc/refman/5.7/en/string-literals.html
459
     */
460
    public function testEnsureDefaultsAreUnescapedFromSchemaIntrospection() : void
461
    {
462
        $platform = $this->schemaManager->getDatabasePlatform();
463
        $this->connection->query('DROP TABLE IF EXISTS test_column_defaults_with_create');
464
465
        $escapeSequences = [
466
            "\\0",          // An ASCII NUL (X'00') character
467
            "\\'",
468
            "''",    // Single quote
469
            '\\"',
470
            '""',    // Double quote
471
            '\\b',          // A backspace character
472
            '\\n',          // A new-line character
473
            '\\r',          // A carriage return character
474
            '\\t',          // A tab character
475
            '\\Z',          // ASCII 26 (Control+Z)
476
            '\\\\',         // A backslash (\) character
477
            '\\%',          // A percent (%) character
478
            '\\_',          // An underscore (_) character
479
        ];
480
481
        $default = implode('+', $escapeSequences);
482
483
        $sql = sprintf(
484
            'CREATE TABLE test_column_defaults_with_create(col1 VARCHAR(255) NULL DEFAULT %s)',
485
            $platform->quoteStringLiteral($default)
486
        );
487
        $this->connection->query($sql);
488
        $onlineTable = $this->schemaManager->listTableDetails('test_column_defaults_with_create');
489
        self::assertSame($default, $onlineTable->getColumn('col1')->getDefault());
490
    }
491
492
    public function testEnsureTableOptionsAreReflectedInMetadata() : void
493
    {
494
        $this->connection->query('DROP TABLE IF EXISTS test_table_metadata');
495
496
        $sql = <<<'SQL'
497
CREATE TABLE test_table_metadata(
498
  col1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY
499
)
500
COLLATE utf8_general_ci
501
ENGINE InnoDB
502
ROW_FORMAT COMPRESSED
503
COMMENT 'This is a test'
504
AUTO_INCREMENT=42
505
PARTITION BY HASH (col1)
506
SQL;
507
508
        $this->connection->query($sql);
509
        $onlineTable = $this->schemaManager->listTableDetails('test_table_metadata');
510
511
        self::assertEquals('InnoDB', $onlineTable->getOption('engine'));
512
        self::assertEquals('utf8_general_ci', $onlineTable->getOption('collation'));
513
        self::assertEquals(42, $onlineTable->getOption('autoincrement'));
514
        self::assertEquals('This is a test', $onlineTable->getOption('comment'));
515
        self::assertEquals([
516
            'row_format' => 'COMPRESSED',
517
            'partitioned' => true,
518
        ], $onlineTable->getOption('create_options'));
519
    }
520
521
    public function testEnsureTableWithoutOptionsAreReflectedInMetadata() : void
522
    {
523
        $this->connection->query('DROP TABLE IF EXISTS test_table_empty_metadata');
524
525
        $this->connection->query('CREATE TABLE test_table_empty_metadata(col1 INT NOT NULL)');
526
        $onlineTable = $this->schemaManager->listTableDetails('test_table_empty_metadata');
527
528
        self::assertNotEmpty($onlineTable->getOption('engine'));
529
        // collation could be set to default or not set, information_schema indicate a possibly null value
530
        self::assertFalse($onlineTable->hasOption('autoincrement'));
531
        self::assertEquals('', $onlineTable->getOption('comment'));
532
        self::assertEquals([], $onlineTable->getOption('create_options'));
533
    }
534
535
    public function testParseNullCreateOptions() : void
536
    {
537
        $table = $this->schemaManager->listTableDetails('sys.processlist');
538
539
        self::assertEquals([], $table->getOption('create_options'));
540
    }
541
}
542