Skip to content

Commit

Permalink
Add unit test and enum support
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroenpf committed Jul 17, 2024
1 parent 84e5a41 commit 220fd6d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
24 changes: 21 additions & 3 deletions tests/WP_SQLite_Translator_Tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -704,13 +704,15 @@ public function testCreateTableSpatialIndex() {
$this->assertEquals( 1, $result );
}

public function testCreateTableWithDecimalColumn() {
public function testCreateTableWithMultiValueColumnTypeModifiers() {
$result = $this->assertQuery(
'CREATE TABLE wptests_users (
"CREATE TABLE wptests_users (
ID bigint(20) unsigned NOT NULL auto_increment,
decimal_column DECIMAL(10,2) NOT NULL DEFAULT 0,
float_column FLOAT(10,2) NOT NULL DEFAULT 0,
enum_column ENUM('a', 'b', 'c') NOT NULL DEFAULT 'a',
PRIMARY KEY (ID),
)'
)"
);
$this->assertEquals( '', $this->engine->get_error_message() );
$this->assertEquals( 1, $result );
Expand All @@ -735,6 +737,22 @@ public function testCreateTableWithDecimalColumn() {
'Default' => 0,
'Extra' => '',
),
(object) array(
'Field' => 'float_column',
'Type' => 'float(10,2)',
'Null' => 'NO',
'Key' => '',
'Default' => 0,
'Extra' => '',
),
(object) array(
'Field' => 'enum_column',
'Type' => "enum('a','b','c')",
'Null' => 'NO',
'Key' => '',
'Default' => 'a',
'Extra' => '',
),
),
$results
);
Expand Down
1 change: 1 addition & 0 deletions wp-includes/sqlite/class-wp-sqlite-translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class WP_SQLite_Translator {
'double' => 'real',
'decimal' => 'real',
'dec' => 'real',
'enum' => 'text',
'numeric' => 'real',
'fixed' => 'real',
'date' => 'text',
Expand Down

0 comments on commit 220fd6d

Please sign in to comment.