15
15
use function array_column ;
16
16
use function array_fill_keys ;
17
17
use function array_filter ;
18
+ use function array_key_exists ;
18
19
use function array_keys ;
19
20
use function array_map ;
20
21
use function array_merge ;
26
27
use function implode ;
27
28
use function in_array ;
28
29
use function is_array ;
30
+ use function is_bool ;
29
31
use function is_string ;
30
32
use function iterator_to_array ;
31
33
use function sort ;
@@ -170,6 +172,9 @@ private function getCollectionRows(
170
172
continue ;
171
173
}
172
174
175
+ $ options = $ collectionInfo ->getOptions ();
176
+ $ collation = $ options ['collation ' ] ?? [];
177
+
173
178
// Aggregation is not supported on views
174
179
$ shouldAggregateStats = $ aggregateStats !== null && $ collectionInfo ->getType () !== 'view ' ;
175
180
@@ -181,7 +186,7 @@ private function getCollectionRows(
181
186
'schema_qualified_name ' => $ db ->getDatabaseName () . '. ' . $ collectionName ,
182
187
'size ' => $ stats [0 ]?->storageStats?->totalSize ?? null ,
183
188
'comment ' => null ,
184
- 'collation ' => null ,
189
+ 'collation ' => $ this -> collationToString ( $ collation ) ,
185
190
'engine ' => null ,
186
191
];
187
192
}
@@ -191,6 +196,32 @@ private function getCollectionRows(
191
196
return $ collections ;
192
197
}
193
198
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
+
194
225
/** @param string|null $schema Database name */
195
226
public function getTables ($ schema = null )
196
227
{
0 commit comments