We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ad8256a commit 0387361Copy full SHA for 0387361
1 file changed
wp-includes/sqlite-ast/class-wp-sqlite-driver.php
@@ -1386,7 +1386,15 @@ private function execute_truncate_table_statement( WP_Parser_Node $node ): void
1386
$quoted_table_name = $this->quote_sqlite_identifier( $table_name );
1387
1388
$this->execute_sqlite_query( "DELETE FROM $quoted_table_name" );
1389
- $this->execute_sqlite_query( 'DELETE FROM sqlite_sequence WHERE name = ?', array( $table_name ) );
+ try {
1390
+ $this->execute_sqlite_query( 'DELETE FROM sqlite_sequence WHERE name = ?', array( $table_name ) );
1391
+ } catch ( PDOException $e ) {
1392
+ if ( str_contains( $e->getMessage(), 'no such table' ) ) {
1393
+ // The table might not exist if no sequences are used in the DB.
1394
+ } else {
1395
+ throw $e;
1396
+ }
1397
1398
$this->set_result_from_affected_rows();
1399
}
1400
0 commit comments