@@ -46,6 +46,9 @@ abstract class AbstractSqlRenderer
4646
4747 private string $ identifierSeparator = '. ' ;
4848
49+ /** @var array<string, string> */
50+ public array $ identifier = [];
51+
4952 /** @var array<int, string> */
5053 private array $ tablePrefixCache = [];
5154
@@ -67,6 +70,7 @@ public function init(
6770 $ this ->platform = $ platform ;
6871 $ this ->identifierSeparator = $ platform ->getIdentifierSeparator ();
6972 $ this ->tablePrefixCache = [];
73+ $ this ->identifier = [];
7074 }
7175
7276 $ this ->driver = $ driver ;
@@ -120,14 +124,14 @@ public function renderTableSource(
120124 } elseif ($ table instanceof Select) {
121125 $ rendered = '( ' . $ this ->processSubSelect ($ table ) . ') ' ;
122126 } elseif (is_string ($ table )) {
123- $ rendered = $ this ->platform ->quoteIdentifier ($ table );
127+ $ rendered = $ this ->identifier [ $ table ] ??= $ this -> platform ->quoteIdentifier ($ table );
124128 } else {
125129 $ pi = 0 ;
126130 $ rendered = $ table ->toSql ($ this , '' , $ pi );
127131 }
128132
129133 if ($ alias !== null ) {
130- $ rendered .= ' AS ' . $ this ->platform ->quoteIdentifier ($ alias );
134+ $ rendered .= ' AS ' . ( $ this ->identifier [ $ alias ] ??= $ this -> platform ->quoteIdentifier ($ alias) );
131135 }
132136
133137 return $ rendered ;
@@ -143,10 +147,10 @@ public function renderResolvedTable(
143147
144148 if ($ table instanceof TableIdentifier) {
145149 $ prefix = $ alias !== null
146- ? $ this ->platform ->quoteIdentifier ($ alias )
150+ ? ( $ this ->identifier [ $ alias ] ??= $ this -> platform ->quoteIdentifier ($ alias) )
147151 : $ this ->platform ->quoteIdentifier (name: $ table ->table , prefix: $ table ->schema );
148152 } else {
149- $ prefix = $ this ->platform ->quoteIdentifier ($ alias );
153+ $ prefix = $ this ->identifier [ $ alias ] ??= $ this -> platform ->quoteIdentifier ($ alias );
150154 }
151155
152156 return $ this ->tablePrefixCache [$ id ] = $ prefix . $ this ->identifierSeparator ;
@@ -158,7 +162,8 @@ public function renderIdentifiersIn(string $part): string
158162 $ count = count ($ identifiers );
159163
160164 for ($ idx = 1 ; $ idx < $ count ; $ idx += 2 ) {
161- $ identifiers [$ idx ] = $ this ->platform ->quoteIdentifier ($ identifiers [$ idx ]);
165+ $ id = $ identifiers [$ idx ];
166+ $ identifiers [$ idx ] = $ this ->identifier [$ id ] ??= $ this ->platform ->quoteIdentifier ($ id );
162167 }
163168
164169 return implode ('' , $ identifiers );
@@ -184,7 +189,8 @@ public function renderArgument(
184189 int &$ paramIndex ,
185190 ): string {
186191 return match (true ) {
187- $ argument instanceof Identifier => $ this ->platform ->quoteIdentifier ($ argument ->identifier ),
192+ $ argument instanceof Identifier => $ this ->identifier [$ argument ->identifier ]
193+ ??= $ this ->platform ->quoteIdentifier ($ argument ->identifier ),
188194 $ argument instanceof Literal => $ argument ->literal ,
189195 $ argument instanceof NullValue => 'NULL ' ,
190196 $ argument instanceof Parameter => $ this ->bindParameter ($ argument ),
@@ -245,7 +251,8 @@ private function renderIdentifiers(array $identifiers): string
245251 {
246252 $ quoted = [];
247253 foreach ($ identifiers as $ id ) {
248- $ quoted [] = $ this ->platform ->quoteIdentifier ($ id ->identifier );
254+ $ name = $ id ->identifier ;
255+ $ quoted [] = $ this ->identifier [$ name ] ??= $ this ->platform ->quoteIdentifier ($ name );
249256 }
250257 return implode (', ' , $ quoted );
251258 }
0 commit comments