@@ -2791,6 +2791,17 @@ private function translate_string_literal( WP_Parser_Node $node ): string {
27912791 private function translate_pure_identifier ( WP_Parser_Node $ node ): string {
27922792 $ token = $ node ->get_first_child_token ();
27932793 $ value = $ token ->get_value ();
2794+
2795+ if ( str_starts_with ( $ value , self ::RESERVED_PREFIX ) ) {
2796+ throw $ this ->new_driver_exception (
2797+ sprintf (
2798+ "Invalid identifier '%s', prefix '%s' is reserved " ,
2799+ $ value ,
2800+ self ::RESERVED_PREFIX
2801+ )
2802+ );
2803+ }
2804+
27942805 return '` ' . str_replace ( '` ' , '`` ' , $ value ) . '` ' ;
27952806 }
27962807
@@ -2811,8 +2822,7 @@ private function translate_qualified_identifier(
28112822 ?WP_Parser_Node $ object_node = null ,
28122823 ?WP_Parser_Node $ child_node = null
28132824 ): string {
2814- $ parts = array ();
2815- $ uses_reserved_prefix = false ;
2825+ $ parts = array ();
28162826
28172827 // Database name.
28182828 $ is_information_schema = 'information_schema ' === $ this ->db_name ;
@@ -2861,38 +2871,16 @@ private function translate_qualified_identifier(
28612871 );
28622872 $ parts [] = $ this ->information_schema_builder ->get_table_name ( false , $ object_name );
28632873 } else {
2864- $ quoted_object_name = $ this ->translate ( $ object_node );
2865- $ object_name = $ this ->unquote_sqlite_identifier ( $ quoted_object_name );
2866- if ( str_starts_with ( $ object_name , self ::RESERVED_PREFIX ) ) {
2867- $ uses_reserved_prefix = true ;
2868- }
2869- $ parts [] = $ quoted_object_name ;
2874+ $ parts [] = $ this ->translate ( $ object_node );
28702875 }
28712876 }
28722877
28732878 // Object child name (column, index, etc.).
28742879 if ( null !== $ child_node ) {
2875- $ quoted_object_name = $ this ->translate ( $ child_node );
2876- $ object_name = $ this ->unquote_sqlite_identifier ( $ quoted_object_name );
2877- if ( str_starts_with ( $ object_name , self ::RESERVED_PREFIX ) ) {
2878- $ uses_reserved_prefix = true ;
2879- }
2880- $ parts [] = $ quoted_object_name ;
2881- }
2882-
2883- $ identifier = implode ( '. ' , $ parts );
2884-
2885- if ( true === $ uses_reserved_prefix ) {
2886- throw $ this ->new_driver_exception (
2887- sprintf (
2888- "Invalid identifier %s, prefix '%s' is reserved " ,
2889- $ identifier ,
2890- self ::RESERVED_PREFIX
2891- )
2892- );
2880+ $ parts [] = $ this ->translate ( $ child_node );
28932881 }
28942882
2895- return $ identifier ;
2883+ return implode ( ' . ' , $ parts ) ;
28962884 }
28972885
28982886 /**
0 commit comments