1515use function array_column ;
1616use function array_fill_keys ;
1717use function array_filter ;
18+ use function array_key_exists ;
1819use function array_keys ;
1920use function array_map ;
2021use function array_merge ;
2627use function implode ;
2728use function in_array ;
2829use function is_array ;
30+ use function is_bool ;
2931use function is_string ;
3032use function iterator_to_array ;
3133use function sort ;
@@ -170,6 +172,9 @@ private function getCollectionRows(
170172 continue ;
171173 }
172174
175+ $ options = $ collectionInfo ->getOptions ();
176+ $ collation = $ options ['collation ' ] ?? [];
177+
173178 // Aggregation is not supported on views
174179 $ shouldAggregateStats = $ aggregateStats !== null && $ collectionInfo ->getType () !== 'view ' ;
175180
@@ -181,7 +186,7 @@ private function getCollectionRows(
181186 'schema_qualified_name ' => $ db ->getDatabaseName () . '. ' . $ collectionName ,
182187 'size ' => $ stats [0 ]?->storageStats?->totalSize ?? null ,
183188 'comment ' => null ,
184- 'collation ' => null ,
189+ 'collation ' => $ this -> collationToString ( $ collation ) ,
185190 'engine ' => null ,
186191 ];
187192 }
@@ -191,6 +196,32 @@ private function getCollectionRows(
191196 return $ collections ;
192197 }
193198
199+ private function collationToString (array $ collation ): string
200+ {
201+ $ map = [
202+ 'locale ' => 'l ' ,
203+ 'strength ' => 's ' ,
204+ 'caseLevel ' => 'cl ' ,
205+ 'caseFirst ' => 'cf ' ,
206+ 'numericOrdering ' => 'no ' ,
207+ 'alternate ' => 'a ' ,
208+ 'maxVariable ' => 'mv ' ,
209+ 'normalization ' => 'n ' ,
210+ 'backwards ' => 'b ' ,
211+ ];
212+
213+ $ parts = [];
214+ foreach ($ collation as $ key => $ value ) {
215+ if (array_key_exists ($ key , $ map )) {
216+ $ shortKey = $ map [$ key ];
217+ $ shortValue = is_bool ($ value ) ? ($ value ? '1 ' : '0 ' ) : $ value ;
218+ $ parts [] = "{$ shortKey }= {$ shortValue }" ;
219+ }
220+ }
221+
222+ return implode ('; ' , $ parts );
223+ }
224+
194225 /** @param string|null $schema Database name */
195226 public function getTables ($ schema = null )
196227 {
0 commit comments