Skip to content
This repository was archived by the owner on Sep 11, 2026. It is now read-only.

Commit 7eea5e7

Browse files
batonacclaude
andcommitted
Merge avunu/d1-support into turso-support
Brings in upstream's Release 3.0.2 and the schema-reconstruction fix (WordPress#506). The only conflicts were the plugin header, where the release bumped the version and this branch raised the PHP floor: both survive -- Version 3.0.2, Requires PHP 8.0. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2 parents e75d0fa + c977328 commit 7eea5e7

5 files changed

Lines changed: 71 additions & 6 deletions

File tree

‎packages/mysql-on-sqlite/src/sqlite/class-wp-sqlite-information-schema-reconstructor.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,13 +380,13 @@ private function generate_column_definition( string $table_name, array $column_i
380380
$definition[] = $mysql_type;
381381

382382
// NULL/NOT NULL.
383-
if ( '1' === $column_info['notnull'] ) {
383+
if ( 1 === (int) $column_info['notnull'] ) {
384384
$definition[] = 'NOT NULL';
385385
}
386386

387387
// Auto increment.
388388
$is_auto_increment = false;
389-
if ( '0' !== $column_info['pk'] ) {
389+
if ( 0 !== (int) $column_info['pk'] ) {
390390
$is_auto_increment = $this->driver->execute_sqlite_query(
391391
'SELECT 1 FROM sqlite_master WHERE tbl_name = ? AND sql LIKE ?',
392392
array( $table_name, '%AUTOINCREMENT%' )
@@ -424,7 +424,7 @@ private function generate_key_definition( string $table_name, array $key_info, a
424424
$definition[] = 'FULLTEXT KEY';
425425
} elseif ( 'SPATIAL' === $cached_type ) {
426426
$definition[] = 'SPATIAL KEY';
427-
} elseif ( 'UNIQUE' === $cached_type || '1' === $key_info['unique'] ) {
427+
} elseif ( 'UNIQUE' === $cached_type || 1 === (int) $key_info['unique'] ) {
428428
$definition[] = 'UNIQUE KEY';
429429
} else {
430430
$definition[] = 'KEY';

‎packages/mysql-on-sqlite/src/version.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
*
1010
* This constant needs to be updated on plugin release!
1111
*/
12-
define( 'SQLITE_DRIVER_VERSION', '3.0.1' );
12+
define( 'SQLITE_DRIVER_VERSION', '3.0.2' );

‎packages/mysql-on-sqlite/tests/WP_SQLite_Information_Schema_Reconstructor_Tests.php‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,64 @@ public function testReconstructTable(): void {
181181
);
182182
}
183183

184+
/**
185+
* @dataProvider stringifyFetchesProvider
186+
*/
187+
public function testStringifyFetchesDoesNotAffectReconstruction( bool $enabled ): void {
188+
$this->engine->setAttribute( PDO::ATTR_STRINGIFY_FETCHES, $enabled );
189+
190+
$this->engine->get_connection()->query(
191+
"CREATE TABLE t (
192+
id INTEGER PRIMARY KEY AUTOINCREMENT,
193+
name TEXT NOT NULL UNIQUE,
194+
note TEXT DEFAULT 'default',
195+
score INTEGER
196+
)"
197+
);
198+
$this->engine->get_connection()->query( 'CREATE INDEX t__score ON t (score)' );
199+
200+
$this->reconstructor->ensure_correct_information_schema();
201+
202+
// Use consistent result types when checking the reconstructed metadata.
203+
$this->engine->setAttribute( PDO::ATTR_STRINGIFY_FETCHES, true );
204+
205+
$this->assertSame(
206+
array(
207+
array( 'id', 'NO', null, 'auto_increment' ),
208+
array( 'name', 'NO', null, '' ),
209+
array( 'note', 'YES', 'default', '' ),
210+
array( 'score', 'YES', null, '' ),
211+
),
212+
$this->engine->query(
213+
"SELECT COLUMN_NAME, IS_NULLABLE, COLUMN_DEFAULT, EXTRA
214+
FROM INFORMATION_SCHEMA.COLUMNS
215+
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 't'
216+
ORDER BY ORDINAL_POSITION"
217+
)->fetchAll( PDO::FETCH_NUM )
218+
);
219+
220+
$this->assertSame(
221+
array(
222+
array( 'PRIMARY', 'id', '0' ),
223+
array( 'name', 'name', '0' ),
224+
array( 'score', 'score', '1' ),
225+
),
226+
$this->engine->query(
227+
"SELECT INDEX_NAME, COLUMN_NAME, NON_UNIQUE
228+
FROM INFORMATION_SCHEMA.STATISTICS
229+
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 't'
230+
ORDER BY COLUMN_NAME"
231+
)->fetchAll( PDO::FETCH_NUM )
232+
);
233+
}
234+
235+
public function stringifyFetchesProvider(): array {
236+
return array(
237+
'stringification disabled' => array( false ),
238+
'stringification enabled' => array( true ),
239+
);
240+
}
241+
184242
public function testReconstructWpTable(): void {
185243
// Create a WP table with any columns.
186244
$this->engine->get_connection()->query( 'CREATE TABLE wp_posts ( id INTEGER )' );

‎packages/plugin-sqlite-database-integration/load.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: SQLite Database Integration
44
* Description: SQLite database driver drop-in.
55
* Author: The WordPress Team
6-
* Version: 3.0.1
6+
* Version: 3.0.2
77
* Requires PHP: 8.0
88
* Network: true
99
* License: GPL-2.0-or-later

‎packages/plugin-sqlite-database-integration/readme.txt‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Contributors: wordpressdotorg, aristath, janjakes, zieladam, berislav.grgic
44
Requires at least: 6.4
55
Tested up to: 7.1
66
Requires PHP: 8.0
7-
Stable tag: 3.0.1
7+
Stable tag: 3.0.2
88
License: GPLv2 or later
99
License URI: https://www.gnu.org/licenses/gpl-2.0.html
1010
Tags: sqlite, database
@@ -66,6 +66,13 @@ Yes. The plugin replaces the default MySQL-based database layer with an SQLite-b
6666

6767
== Changelog ==
6868

69+
= 3.0.2 =
70+
71+
* Fix schema reconstruction with native numeric results ([#506](https://github.com/WordPress/sqlite-database-integration/pull/506))
72+
* Fix lexer edge cases and string handling ([#505](https://github.com/WordPress/sqlite-database-integration/pull/505))
73+
* Preserve index prefix lengths and order in `SHOW CREATE TABLE` primary keys ([#500](https://github.com/WordPress/sqlite-database-integration/pull/500))
74+
* Align savepoint handling with MySQL semantics ([#496](https://github.com/WordPress/sqlite-database-integration/pull/496))
75+
6976
= 3.0.1 =
7077

7178
* Mark the plugin as compatible with WordPress 7.1 ([#497](https://github.com/WordPress/sqlite-database-integration/pull/497))

0 commit comments

Comments
 (0)