@@ -437,6 +437,10 @@ public function getGeneratedTypeFields(string $type): array
437437 return $ this ->types [$ this ->requireRegisteredType ($ type )]['generated_fields ' ];
438438 }
439439
440+ public function getTypeSqlReadStatements (string $ type ): array
441+ {
442+ return $ this ->types [$ this ->requireRegisteredType ($ type )]['sql_read_statements ' ];
443+ }
440444 public function getTypeProperty (string $ type , string $ property , callable $ callback ): mixed
441445 {
442446 $ registered_type = $ this ->requireRegisteredType ($ type );
@@ -456,7 +460,7 @@ private function getSelectOneByType(string $type): string
456460 if (empty ($ this ->types [$ type ]['sql_select_by_ids ' ])) {
457461 $ this ->types [$ type ]['sql_select_by_ids ' ] = sprintf (
458462 'SELECT %s FROM %s WHERE `id` IN ? ORDER BY `id` ' ,
459- $ this ->getEscapedTypeFields ($ type ),
463+ $ this ->getTypeFieldsReadStatement ($ type ),
460464 $ this ->getTypeTable ($ type , true )
461465 );
462466 }
@@ -491,21 +495,21 @@ public function getTypeFieldsReadStatement(string $type): string
491495 {
492496 return $ this ->getTypeProperty (
493497 $ type ,
494- 'escaped_fields ' ,
498+ 'field_read_statements ' ,
495499 function () use ($ type ) {
496500 $ table_name = $ this ->getTypeTable ($ type , true );
497501
498- $ escaped_field_names = [];
502+ $ field_read_statements = [];
499503
500- foreach ($ this ->getTypeFields ($ type ) as $ field_name ) {
501- $ escaped_field_names [] = $ table_name . ' . ' . $ this -> connection -> escapeFieldName ( $ field_name ) ;
504+ foreach ($ this ->getTypeSqlReadStatements ($ type ) as $ sql_read_statement ) {
505+ $ field_read_statements [] = $ sql_read_statement ;
502506 }
503507
504508 foreach ($ this ->getGeneratedTypeFields ($ type ) as $ field_name ) {
505- $ escaped_field_names [] = $ table_name . '. ' . $ this ->connection ->escapeFieldName ($ field_name );
509+ $ field_read_statements [] = $ table_name . '. ' . $ this ->connection ->escapeFieldName ($ field_name );
506510 }
507511
508- return implode (', ' , $ escaped_field_names );
512+ return implode (', ' , $ field_read_statements );
509513 }
510514 );
511515 }
@@ -671,6 +675,7 @@ public function registerType(string ...$types): PoolInterface
671675 'table_name ' => $ default_properties ['table_name ' ],
672676 'fields ' => $ default_properties ['entity_fields ' ],
673677 'generated_fields ' => $ default_properties ['generated_entity_fields ' ],
678+ 'sql_read_statements ' => $ default_properties ['sql_read_statements ' ],
674679 'order_by ' => $ default_properties ['order_by ' ],
675680 ];
676681 }
0 commit comments