88use Doctrine \DBAL \Connection ;
99use Doctrine \DBAL \LockMode ;
1010use Doctrine \DBAL \Platforms \AbstractPlatform ;
11- use Doctrine \DBAL \Types \Type ;
11+ use Doctrine \DBAL \Types \TypeRegistry ;
1212use Doctrine \Deprecations \Deprecation ;
1313use Doctrine \ORM \EntityManagerInterface ;
1414use Doctrine \ORM \Mapping \ClassMetadata ;
@@ -141,6 +141,8 @@ class SqlWalker
141141 */
142142 private readonly QuoteStrategy $ quoteStrategy ;
143143
144+ private readonly TypeRegistry $ typeRegistry ;
145+
144146 /** @phpstan-param array<string, QueryComponent> $queryComponents The query components (symbol table). */
145147 public function __construct (
146148 private readonly Query $ query ,
@@ -152,6 +154,7 @@ public function __construct(
152154 $ this ->conn = $ this ->em ->getConnection ();
153155 $ this ->platform = $ this ->conn ->getDatabasePlatform ();
154156 $ this ->quoteStrategy = $ this ->em ->getConfiguration ()->getQuoteStrategy ();
157+ $ this ->typeRegistry = $ this ->em ->getConfiguration ()->getTypeRegistry ();
155158 }
156159
157160 /**
@@ -178,16 +181,6 @@ public function getEntityManager(): EntityManagerInterface
178181 return $ this ->em ;
179182 }
180183
181- private function getType (string $ name ): Type
182- {
183- return $ this ->em ->getConfiguration ()->getTypeRegistry ()->get ($ name );
184- }
185-
186- private function hasType (string $ name ): bool
187- {
188- return $ this ->em ->getConfiguration ()->getTypeRegistry ()->has ($ name );
189- }
190-
191184 /**
192185 * Gets the information about a single query component.
193186 *
@@ -1307,7 +1300,7 @@ public function walkSelectExpression(AST\SelectExpression $selectExpression): st
13071300 $ columnAlias = $ this ->getSQLColumnAlias ($ fieldMapping ->columnName );
13081301 $ col = $ sqlTableAlias . '. ' . $ columnName ;
13091302
1310- $ type = $ this ->getType ($ fieldMapping ->type );
1303+ $ type = $ this ->typeRegistry -> get ($ fieldMapping ->type );
13111304 $ col = $ type ->convertToPHPValueSQL ($ col , $ this ->conn ->getDatabasePlatform ());
13121305
13131306 $ sql .= $ col . ' AS ' . $ columnAlias ;
@@ -1355,7 +1348,7 @@ public function walkSelectExpression(AST\SelectExpression $selectExpression): st
13551348 break ;
13561349 }
13571350
1358- $ this ->rsm ->addScalarResult ($ columnAlias , $ resultAlias , $ this ->em -> getConfiguration ()-> getTypeRegistry () ->lookupName ($ expr ->getReturnType ()));
1351+ $ this ->rsm ->addScalarResult ($ columnAlias , $ resultAlias , $ this ->typeRegistry ->lookupName ($ expr ->getReturnType ()));
13591352
13601353 break ;
13611354
@@ -1433,7 +1426,7 @@ public function walkObjectExpression(string $dqlAlias, array $partialFieldSet, s
14331426
14341427 $ col = $ sqlTableAlias . '. ' . $ quotedColumnName ;
14351428
1436- $ type = $ this ->getType ($ mapping ->type );
1429+ $ type = $ this ->typeRegistry -> get ($ mapping ->type );
14371430 $ col = $ type ->convertToPHPValueSQL ($ col , $ this ->platform );
14381431
14391432 $ sqlParts [] = $ col . ' AS ' . $ columnAlias ;
@@ -1468,7 +1461,7 @@ public function walkObjectExpression(string $dqlAlias, array $partialFieldSet, s
14681461
14691462 $ col = $ sqlTableAlias . '. ' . $ quotedColumnName ;
14701463
1471- $ type = $ this ->getType ($ mapping ->type );
1464+ $ type = $ this ->typeRegistry -> get ($ mapping ->type );
14721465 $ col = $ type ->convertToPHPValueSQL ($ col , $ this ->platform );
14731466
14741467 $ sqlParts [] = $ col . ' AS ' . $ columnAlias ;
@@ -1573,7 +1566,7 @@ public function walkNewObject(AST\NewObjectExpression $newObjectExpression, stri
15731566 $ fieldType = $ fieldMapping ->type ;
15741567 $ col = trim ($ e ->dispatch ($ this ));
15751568
1576- $ type = $ this ->getType ($ fieldType );
1569+ $ type = $ this ->typeRegistry -> get ($ fieldType );
15771570 $ col = $ type ->convertToPHPValueSQL ($ col , $ this ->platform );
15781571
15791572 $ sqlSelectExpressions [] = $ col . ' AS ' . $ columnAlias ;
@@ -2207,8 +2200,8 @@ public function walkInputParameter(AST\InputParameter $inputParam): string
22072200
22082201 if ($ parameter ) {
22092202 $ type = $ parameter ->getType ();
2210- if (is_string ($ type ) && $ this ->hasType ($ type )) {
2211- return $ this ->getType ($ type )->convertToDatabaseValueSQL ('? ' , $ this ->platform );
2203+ if (is_string ($ type ) && $ this ->typeRegistry -> has ($ type )) {
2204+ return $ this ->typeRegistry -> get ($ type )->convertToDatabaseValueSQL ('? ' , $ this ->platform );
22122205 }
22132206 }
22142207
0 commit comments