Skip to content

Commit ff7c0c5

Browse files
committed
Use "sqlite_master" rather than "sqlite_schema" for compatibility with SQLite < 3.33.0
1 parent e1db05a commit ff7c0c5

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

tests/WP_SQLite_Driver_Translation_Tests.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1939,7 +1939,7 @@ private function assertQuery( $expected, string $query ): void {
19391939
array_filter(
19401940
$executed_queries,
19411941
function ( $query ) {
1942-
return "SELECT 1 FROM sqlite_temp_schema WHERE type = 'table' AND name = ?" !== $query;
1942+
return "SELECT 1 FROM sqlite_temp_master WHERE type = 'table' AND name = ?" !== $query;
19431943
}
19441944
)
19451945
);

wp-includes/sqlite-ast/class-wp-sqlite-information-schema-builder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,10 +378,10 @@ public function get_table_name( bool $table_is_temporary, string $information_sc
378378
public function temporary_table_exists( string $table_name ): bool {
379379
/*
380380
* We could search in the "{$this->temporary_table_prefix}tables" table,
381-
* but it may not exist yet, so using "sqlite_temp_schema" is simpler.
381+
* but it may not exist yet, so using "sqlite_temp_master" is simpler.
382382
*/
383383
$stmt = $this->connection->query(
384-
"SELECT 1 FROM sqlite_temp_schema WHERE type = 'table' AND name = ?",
384+
"SELECT 1 FROM sqlite_temp_master WHERE type = 'table' AND name = ?",
385385
array( $table_name )
386386
);
387387
return $stmt->fetchColumn() === '1';

wp-includes/sqlite-ast/class-wp-sqlite-information-schema-reconstructor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ private function get_sqlite_table_names(): array {
127127
return $this->driver->execute_sqlite_query(
128128
"
129129
SELECT name
130-
FROM sqlite_schema
130+
FROM sqlite_master
131131
WHERE type = 'table'
132132
AND name != ?
133133
AND name NOT LIKE ? ESCAPE '\'
@@ -367,7 +367,7 @@ private function generate_column_definition( string $table_name, array $column_i
367367
$is_auto_increment = false;
368368
if ( '0' !== $column_info['pk'] ) {
369369
$is_auto_increment = $this->driver->execute_sqlite_query(
370-
'SELECT 1 FROM sqlite_schema WHERE tbl_name = ? AND sql LIKE ?',
370+
'SELECT 1 FROM sqlite_master WHERE tbl_name = ? AND sql LIKE ?',
371371
array( $table_name, '%AUTOINCREMENT%' )
372372
)->fetchColumn();
373373

0 commit comments

Comments
 (0)