Completed
Push — master ( ff6cbd...ce4534 )
by Sergei
13:19 queued 13:15
created

testEnsureTableOptionsAreReflectedInMetadata()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 23
rs 9.6666
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
        Type::addType('point', MySqlPointType::class);
27
    }
28
29
    public function testSwitchPrimaryKeyColumns()
30
    {
31
        $tableOld = new Table('switch_primary_key_columns');
32
        $tableOld->addColumn('foo_id', 'integer');
33
        $tableOld->addColumn('bar_id', 'integer');
34
35
        $this->schemaManager->createTable($tableOld);
36
        $tableFetched = $this->schemaManager->listTableDetails('switch_primary_key_columns');
37
        $tableNew     = clone $tableFetched;
38
        $tableNew->setPrimaryKey(['bar_id', 'foo_id']);
39
40
        $comparator = new Comparator();
41
        $this->schemaManager->alterTable($comparator->diffTable($tableFetched, $tableNew));
42
43
        $table      = $this->schemaManager->listTableDetails('switch_primary_key_columns');
44
        $primaryKey = $table->getPrimaryKeyColumns();
45
46
        self::assertCount(2, $primaryKey);
47
        self::assertContains('bar_id', $primaryKey);
48
        self::assertContains('foo_id', $primaryKey);
49
    }
50
51
    public function testDiffTableBug()
52
    {
53
        $schema = new Schema();
54
        $table  = $schema->createTable('diffbug_routing_translations');
55
        $table->addColumn('id', 'integer');
56
        $table->addColumn('route', 'string');
57
        $table->addColumn('locale', 'string');
58
        $table->addColumn('attribute', 'string');
59
        $table->addColumn('localized_value', 'string');
60
        $table->addColumn('original_value', 'string');
61
        $table->setPrimaryKey(['id']);
62
        $table->addUniqueIndex(['route', 'locale', 'attribute']);
63
        $table->addIndex(['localized_value']); // this is much more selective than the unique index
64
65
        $this->schemaManager->createTable($table);
66
        $tableFetched = $this->schemaManager->listTableDetails('diffbug_routing_translations');
67
68
        $comparator = new Comparator();
69
        $diff       = $comparator->diffTable($tableFetched, $table);
70
71
        self::assertFalse($diff, 'no changes expected.');
72
    }
73
74
    public function testFulltextIndex()
75
    {
76
        $table = new Table('fulltext_index');
77
        $table->addColumn('text', 'text');
78
        $table->addIndex(['text'], 'f_index');
79
        $table->addOption('engine', 'MyISAM');
80
81
        $index = $table->getIndex('f_index');
82
        $index->addFlag('fulltext');
83
84
        $this->schemaManager->dropAndCreateTable($table);
85
86
        $indexes = $this->schemaManager->listTableIndexes('fulltext_index');
87
        self::assertArrayHasKey('f_index', $indexes);
88
        self::assertTrue($indexes['f_index']->hasFlag('fulltext'));
89
    }
90
91
    public function testSpatialIndex()
92
    {
93
        $table = new Table('spatial_index');
94
        $table->addColumn('point', 'point');
95
        $table->addIndex(['point'], 's_index');
96
        $table->addOption('engine', 'MyISAM');
97
98
        $index = $table->getIndex('s_index');
99
        $index->addFlag('spatial');
100
101
        $this->schemaManager->dropAndCreateTable($table);
102
103
        $indexes = $this->schemaManager->listTableIndexes('spatial_index');
104
        self::assertArrayHasKey('s_index', $indexes);
105
        self::assertTrue($indexes['s_index']->hasFlag('spatial'));
106
    }
107
108
    /**
109
     * @group DBAL-400
110
     */
111
    public function testAlterTableAddPrimaryKey()
112
    {
113
        $table = new Table('alter_table_add_pk');
114
        $table->addColumn('id', 'integer');
115
        $table->addColumn('foo', 'integer');
116
        $table->addIndex(['id'], 'idx_id');
117
118
        $this->schemaManager->createTable($table);
119
120
        $comparator = new Comparator();
121
        $diffTable  = clone $table;
122
123
        $diffTable->dropIndex('idx_id');
124
        $diffTable->setPrimaryKey(['id']);
125
126
        $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

126
        $this->schemaManager->alterTable(/** @scrutinizer ignore-type */ $comparator->diffTable($table, $diffTable));
Loading history...
127
128
        $table = $this->schemaManager->listTableDetails('alter_table_add_pk');
129
130
        self::assertFalse($table->hasIndex('idx_id'));
131
        self::assertTrue($table->hasPrimaryKey());
132
    }
133
134
    /**
135
     * @group DBAL-464
136
     */
137
    public function testDropPrimaryKeyWithAutoincrementColumn()
138
    {
139
        $table = new Table('drop_primary_key');
140
        $table->addColumn('id', 'integer', ['autoincrement' => true]);
141
        $table->addColumn('foo', 'integer');
142
        $table->setPrimaryKey(['id', 'foo']);
143
144
        $this->schemaManager->dropAndCreateTable($table);
145
146
        $diffTable = clone $table;
147
148
        $diffTable->dropPrimaryKey();
149
150
        $comparator = new Comparator();
151
152
        $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

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