Skip to content

Commit

Permalink
Add test that shows incorrect behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekn committed Dec 12, 2024
1 parent a2661f9 commit 3b75ccd
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/WP_SQLite_Translator_Tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,37 @@ public function testShowCreateTablePreservesDoubleUnderscoreKeyNames() {
);
}

public function testShowCreateTableLimitsKeyLengths() {
$this->assertQuery(
"CREATE TABLE _tmp__table (

Check failure on line 426 in tests/WP_SQLite_Translator_Tests.php

View workflow job for this annotation

GitHub Actions / Check code style

String "CREATE TABLE _tmp__table (\n `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,\n `order_id` bigint(20) unsigned DEFAULT NULL,\n `meta_key` varchar(255) DEFAULT NULL,\n `meta_value` text DEFAULT NULL,\n PRIMARY KEY (`id`),\n KEY `meta_key_value` (`meta_key`(100),`meta_value`(82)),\n KEY `order_id_meta_key_meta_value` (`order_id`,`meta_key`(100),`meta_value`(82))\n );" does not require double quotes; use single quotes instead
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`order_id` bigint(20) unsigned DEFAULT NULL,
`meta_key` varchar(255) DEFAULT NULL,
`meta_value` text DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `meta_key_value` (`meta_key`(100),`meta_value`(82)),
KEY `order_id_meta_key_meta_value` (`order_id`,`meta_key`(100),`meta_value`(82))
);"
);

$this->assertQuery(
'SHOW CREATE TABLE _tmp__table;'
);
$results = $this->engine->get_query_results();
$this->assertEquals(
'CREATE TABLE `_tmp__table` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`order_id` bigint(20) unsigned DEFAULT NULL,
`meta_key` varchar(255) DEFAULT NULL,
`meta_value` text DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `order_id_meta_key_meta_value` (`order_id`,`meta_key`(100),`meta_value`(82)),
KEY `meta_key_value` (`meta_key`(100),`meta_value`(82))
);',
$results[0]->{'Create Table'}
);
}

public function testShowCreateTableWithPrimaryKeyColumnsReverseOrdered() {
$this->assertQuery(
'CREATE TABLE `_tmp_table` (
Expand Down

0 comments on commit 3b75ccd

Please sign in to comment.