Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6071,7 +6071,7 @@ function ( $column ) use ( $is_strict_mode, $insert_map ) {
return false;
}
$is_nullable = 'YES' === $column['IS_NULLABLE'];
$has_default = $column['COLUMN_DEFAULT'];
$has_default = null !== $column['COLUMN_DEFAULT'];
$is_generated = str_contains( $column['EXTRA'], 'auto_increment' );
return ! ( $is_nullable || $has_default || $is_generated );
}
Expand Down
8 changes: 8 additions & 0 deletions packages/mysql-on-sqlite/tests/WP_MySQL_On_SQLite_Tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -8626,6 +8626,14 @@ public function testNonStrictSqlModeNotNullWithDefault(): void {
$result = $this->assertQuery( 'SELECT * FROM t3' );
$this->assertCount( 1, $result );
$this->assertSame( '', $result[0]->value );

// No value saves DEFAULT '0' (issue #552):
$this->assertQuery( "CREATE TABLE t4 (id INT NOT NULL, label VARCHAR(10) NOT NULL DEFAULT '0', count INT NOT NULL DEFAULT 0)" );
$this->assertQuery( 'INSERT INTO t4 (id) VALUES (1)' );
$result = $this->assertQuery( 'SELECT * FROM t4 WHERE id = 1' );
$this->assertCount( 1, $result );
$this->assertSame( '0', $result[0]->label );
$this->assertSame( '0', $result[0]->count );
}

public function testNonStrictModeWithDefaultCurrentTimestamp(): void {
Expand Down
Loading