@@ -2060,7 +2060,8 @@ private function translate_qualified_identifier(
20602060 ?WP_Parser_Node $ object_node = null ,
20612061 ?WP_Parser_Node $ child_node = null
20622062 ): string {
2063- $ parts = array ();
2063+ $ parts = array ();
2064+ $ uses_reserved_prefix = false ;
20642065
20652066 // Database name.
20662067 $ is_information_schema = 'information_schema ' === $ this ->db_name ;
@@ -2091,16 +2092,38 @@ private function translate_qualified_identifier(
20912092 );
20922093 $ parts [] = $ this ->information_schema_builder ->get_table_name ( $ object_name );
20932094 } else {
2094- $ parts [] = $ this ->translate ( $ object_node );
2095+ $ quoted_object_name = $ this ->translate ( $ object_node );
2096+ $ object_name = $ this ->unquote_sqlite_identifier ( $ quoted_object_name );
2097+ if ( str_starts_with ( $ object_name , self ::RESERVED_PREFIX ) ) {
2098+ $ uses_reserved_prefix = true ;
2099+ }
2100+ $ parts [] = $ quoted_object_name ;
20952101 }
20962102 }
20972103
20982104 // Object child name (column, index, etc.).
20992105 if ( null !== $ child_node ) {
2100- $ parts [] = $ this ->translate ( $ child_node );
2106+ $ quoted_object_name = $ this ->translate ( $ child_node );
2107+ $ object_name = $ this ->unquote_sqlite_identifier ( $ quoted_object_name );
2108+ if ( str_starts_with ( $ object_name , self ::RESERVED_PREFIX ) ) {
2109+ $ uses_reserved_prefix = true ;
2110+ }
2111+ $ parts [] = $ quoted_object_name ;
2112+ }
2113+
2114+ $ identifier = implode ( '. ' , $ parts );
2115+
2116+ if ( true === $ uses_reserved_prefix ) {
2117+ throw $ this ->new_driver_exception (
2118+ sprintf (
2119+ "Invalid identifier %s, prefix '%s' is reserved " ,
2120+ $ identifier ,
2121+ self ::RESERVED_PREFIX
2122+ )
2123+ );
21012124 }
21022125
2103- return implode ( ' . ' , $ parts ) ;
2126+ return $ identifier ;
21042127 }
21052128
21062129 /**
0 commit comments