Skip to content

Commit aa659c7

Browse files
committed
Unify temp schema quotes, add DROP TEMPORARY TABLE test
1 parent 08043bc commit aa659c7

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

tests/WP_SQLite_Driver_Translation_Tests.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,19 @@ public function testCreateTemporaryTable(): void {
508508
);
509509
}
510510

511+
public function testDropTemporaryTable(): void {
512+
$this->assertQuery(
513+
'DROP TABLE `temp`.`t`',
514+
'DROP TEMPORARY TABLE t'
515+
);
516+
517+
// With IF NOT EXISTS.
518+
$this->assertQuery(
519+
'DROP TABLE IF EXISTS `temp`.`t`',
520+
'DROP TEMPORARY TABLE IF EXISTS t'
521+
);
522+
}
523+
511524
public function testAlterTableAddColumn(): void {
512525
$this->driver->query( 'CREATE TABLE t (id INT)' );
513526
$this->assertQuery(

wp-includes/sqlite-ast/class-wp-sqlite-driver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1195,7 +1195,7 @@ private function execute_drop_table_statement( WP_Parser_Node $node ): void {
11951195
// Replace table list with the current table reference.
11961196
if ( ! $is_token && 'tableRefList' === $child->rule_name ) {
11971197
// Add a "temp." schema prefix for temporary tables.
1198-
$prefix = $is_temporary ? '"temp".' : '';
1198+
$prefix = $is_temporary ? '`temp`.' : '';
11991199
$part = $prefix . $this->translate( $table_ref );
12001200
} else {
12011201
$part = $this->translate( $child );

0 commit comments

Comments
 (0)