Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
JanJakes committed Dec 19, 2024
1 parent 8af4cb5 commit 0be19ab
Show file tree
Hide file tree
Showing 4 changed files with 263 additions and 126 deletions.
74 changes: 37 additions & 37 deletions tests/WP_SQLite_Driver_Tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ public function testCreateTable() {
),
(object) array(
'Field' => 'user_status',
'Type' => 'int',
'Type' => 'int(11)',
'Null' => 'NO',
'Key' => '',
'Default' => '0',
Expand Down Expand Up @@ -848,8 +848,8 @@ enum_column ENUM('a', 'b', 'c') NOT NULL DEFAULT 'a',
'Type' => 'bigint(20) unsigned',
'Null' => 'NO',
'Key' => 'PRI',
'Default' => '0',
'Extra' => '',
'Default' => null,
'Extra' => 'auto_increment',
),
(object) array(
'Field' => 'decimal_column',
Expand Down Expand Up @@ -969,7 +969,7 @@ public function testAlterTableAddAndDropColumn() {
),
(object) array(
'Field' => 'column2',
'Type' => 'int',
'Type' => 'int(11)',
'Null' => 'YES',
'Key' => '',
'Default' => null,
Expand Down Expand Up @@ -1049,10 +1049,10 @@ public function testColumnWithOnUpdate() {
array(
(object) array(
'Field' => 'id',
'Type' => 'int',
'Type' => 'int(11)',
'Null' => 'NO',
'Key' => '',
'Default' => '0',
'Default' => null,
'Extra' => '',
),
(object) array(
Expand All @@ -1061,7 +1061,7 @@ public function testColumnWithOnUpdate() {
'Null' => 'YES',
'Key' => '',
'Default' => null,
'Extra' => '',
'Extra' => 'on update CURRENT_TIMESTAMP',
),
),
$results
Expand All @@ -1076,10 +1076,10 @@ public function testColumnWithOnUpdate() {
array(
(object) array(
'Field' => 'id',
'Type' => 'int',
'Type' => 'int(11)',
'Null' => 'NO',
'Key' => '',
'Default' => '0',
'Default' => null,
'Extra' => '',
),
(object) array(
Expand All @@ -1088,15 +1088,15 @@ public function testColumnWithOnUpdate() {
'Null' => 'YES',
'Key' => '',
'Default' => null,
'Extra' => '',
'Extra' => 'on update CURRENT_TIMESTAMP',
),
(object) array(
'Field' => 'updated_at',
'Type' => 'timestamp',
'Null' => 'YES',
'Key' => '',
'Default' => null,
'Extra' => '',
'Extra' => 'on update CURRENT_TIMESTAMP',
),
),
$results
Expand Down Expand Up @@ -1147,7 +1147,7 @@ public function testColumnWithOnUpdate() {
array(
(object) array(
'Field' => 'id',
'Type' => 'int',
'Type' => 'int(11)',
'Null' => 'NO',
'Key' => '',
'Default' => '0',
Expand Down Expand Up @@ -1218,10 +1218,10 @@ public function testChangeColumnWithOnUpdate() {
array(
(object) array(
'Field' => 'id',
'Type' => 'int',
'Type' => 'int(11)',
'Null' => 'NO',
'Key' => '',
'Default' => '0',
'Default' => null,
'Extra' => '',
),
(object) array(
Expand Down Expand Up @@ -1251,10 +1251,10 @@ public function testChangeColumnWithOnUpdate() {
array(
(object) array(
'Field' => 'id',
'Type' => 'int',
'Type' => 'int(11)',
'Null' => 'NO',
'Key' => '',
'Default' => '0',
'Default' => null,
'Extra' => '',
),
(object) array(
Expand All @@ -1263,7 +1263,7 @@ public function testChangeColumnWithOnUpdate() {
'Null' => 'YES',
'Key' => '',
'Default' => null,
'Extra' => '',
'Extra' => 'on update CURRENT_TIMESTAMP',
),
),
$results
Expand All @@ -1283,10 +1283,10 @@ public function testChangeColumnWithOnUpdate() {
array(
(object) array(
'Field' => 'id',
'Type' => 'int',
'Type' => 'int(11)',
'Null' => 'NO',
'Key' => '',
'Default' => '0',
'Default' => null,
'Extra' => '',
),
(object) array(
Expand Down Expand Up @@ -1325,7 +1325,7 @@ public function testAlterTableWithColumnFirstAndAfter() {
array(
(object) array(
'Field' => 'id',
'Type' => 'int',
'Type' => 'int(11)',
'Null' => 'NO',
'Key' => '',
'Default' => null,
Expand Down Expand Up @@ -1360,7 +1360,7 @@ public function testAlterTableWithColumnFirstAndAfter() {
array(
(object) array(
'Field' => 'id',
'Type' => 'int',
'Type' => 'int(11)',
'Null' => 'NO',
'Key' => '',
'Default' => null,
Expand Down Expand Up @@ -1403,7 +1403,7 @@ public function testAlterTableWithColumnFirstAndAfter() {
array(
(object) array(
'Field' => 'id',
'Type' => 'int',
'Type' => 'int(11)',
'Null' => 'NO',
'Key' => '',
'Default' => '0',
Expand Down Expand Up @@ -1446,7 +1446,7 @@ public function testAlterTableWithColumnFirstAndAfter() {
array(
(object) array(
'Field' => 'id',
'Type' => 'int',
'Type' => 'int(11)',
'Null' => 'NO',
'Key' => '',
'Default' => '0',
Expand Down Expand Up @@ -1500,7 +1500,7 @@ public function testAlterTableWithMultiColumnFirstAndAfter() {
array(
(object) array(
'Field' => 'id',
'Type' => 'int',
'Type' => 'int(11)',
'Null' => 'NO',
'Key' => '',
'Default' => null,
Expand Down Expand Up @@ -1546,31 +1546,31 @@ public function testAlterTableWithMultiColumnFirstAndAfter() {
array(
(object) array(
'Field' => 'id',
'Type' => 'int',
'Type' => 'int(11)',
'Null' => 'NO',
'Key' => '',
'Default' => null,
'Extra' => '',
),
(object) array(
'Field' => 'new1',
'Type' => 'int',
'Type' => 'int(11)',
'Null' => 'NO',
'Key' => '',
'Default' => null,
'Extra' => '',
),
(object) array(
'Field' => 'new2',
'Type' => 'int',
'Type' => 'int(11)',
'Null' => 'NO',
'Key' => '',
'Default' => '',
'Extra' => '',
),
(object) array(
'Field' => 'new3',
'Type' => 'int',
'Type' => 'int(11)',
'Null' => 'NO',
'Key' => '',
'Default' => '',
Expand Down Expand Up @@ -2167,15 +2167,14 @@ public function testNestedTransactionWorkComplexModify() {
$fields = $this->engine->get_query_results();

$this->assertEquals(
$fields,
array(
(object) array(
'Field' => 'ID',
'Type' => 'integer',
'Type' => 'int',
'Null' => 'NO',
'Key' => 'PRI',
'Default' => '0',
'Extra' => '',
'Default' => null,
'Extra' => 'auto_increment',
),
(object) array(
'Field' => 'option_name',
Expand All @@ -2193,7 +2192,8 @@ public function testNestedTransactionWorkComplexModify() {
'Default' => '',
'Extra' => '',
),
)
),
$fields
);
}

Expand Down Expand Up @@ -2408,15 +2408,15 @@ public function testDescribeAccurate() {
array(
(object) array(
'Field' => 'object_id',
'Type' => 'bigint unsigned',
'Type' => 'bigint(20) unsigned',
'Null' => 'NO',
'Key' => 'PRI',
'Default' => '0',
'Extra' => '',
),
(object) array(
'Field' => 'term_taxonomy_id',
'Type' => 'bigint unsigned',
'Type' => 'bigint(20) unsigned',
'Null' => 'NO',
'Key' => 'PRI',
'Default' => '0',
Expand All @@ -2426,7 +2426,7 @@ public function testDescribeAccurate() {
'Field' => 'term_name',
'Type' => 'varchar(11)',
'Null' => 'NO',
'Key' => '',
'Key' => 'MUL',
'Default' => '0',
'Extra' => '',
),
Expand Down Expand Up @@ -2457,7 +2457,7 @@ public function testAlterTableAddColumnChangesMySQLDataType() {
array(
(object) array(
'Field' => 'object_id',
'Type' => 'bigint unsigned',
'Type' => 'bigint(20) unsigned',
'Null' => 'NO',
'Key' => '',
'Default' => '0',
Expand Down
21 changes: 21 additions & 0 deletions tests/WP_SQLite_Driver_Translation_Tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,27 @@ public function testAlterTableAddColumn(): void {
);
}

public function testAlterTableAddColumnWithNotNull(): void {
$this->assertQuery(
'ALTER TABLE "t" ADD COLUMN "a" INTEGER NOT NULL',
'ALTER TABLE t ADD a INT NOT NULL'
);
}

public function testAlterTableAddColumnWithDefault(): void {
$this->assertQuery(
'ALTER TABLE "t" ADD COLUMN "a" INTEGER DEFAULT 0',
'ALTER TABLE t ADD a INT DEFAULT 0'
);
}

public function testAlterTableAddColumnWithNotNullAndDefault(): void {
$this->assertQuery(
'ALTER TABLE "t" ADD COLUMN "a" INTEGER NOT NULL DEFAULT 0',
'ALTER TABLE t ADD a INT NOT NULL DEFAULT 0'
);
}

public function testAlterTableAddMultipleColumns(): void {
$this->driver->get_pdo()->exec( 'CREATE TABLE t (id INT)' );
$this->assertQuery(
Expand Down
Loading

0 comments on commit 0be19ab

Please sign in to comment.