@@ -167,7 +167,6 @@ public function loadTableSchema($name)
167
167
$ this ->resolveTableNames ($ table , $ name );
168
168
if ($ this ->findColumns ($ table )) {
169
169
$ this ->findConstraints ($ table );
170
-
171
170
return $ table ;
172
171
} else {
173
172
return null ;
@@ -209,14 +208,7 @@ protected function findTableNames($schema = '')
209
208
WHERE ns.nspname = :schemaName AND c.relkind IN ('r','v','m','f')
210
209
ORDER BY c.relname
211
210
SQL ;
212
- $ command = $ this ->db ->createCommand ($ sql , [':schemaName ' => $ schema ]);
213
- $ rows = $ command ->queryAll ();
214
- $ names = [];
215
- foreach ($ rows as $ row ) {
216
- $ names [] = $ row ['table_name ' ];
217
- }
218
-
219
- return $ names ;
211
+ return $ this ->db ->createCommand ($ sql , [':schemaName ' => $ schema ])->queryColumn ();
220
212
}
221
213
222
214
/**
@@ -237,14 +229,7 @@ protected function findViewNames($schema = '')
237
229
WHERE ns.nspname = :schemaName AND c.relkind = 'v'
238
230
ORDER BY c.relname
239
231
SQL ;
240
- $ command = $ this ->db ->createCommand ($ sql , [':schemaName ' => $ schema ]);
241
- $ rows = $ command ->queryAll ();
242
- $ names = [];
243
- foreach ($ rows as $ row ) {
244
- $ names [] = $ row ['table_name ' ];
245
- }
246
-
247
- return $ names ;
232
+ return $ this ->db ->createCommand ($ sql , [':schemaName ' => $ schema ])->queryColumn ();
248
233
}
249
234
250
235
/**
@@ -271,7 +256,6 @@ public function getViewNames($schema = '', $refresh = false)
271
256
*/
272
257
protected function findConstraints ($ table )
273
258
{
274
-
275
259
$ tableName = $ this ->quoteValue ($ table ->name );
276
260
$ tableSchema = $ this ->quoteValue ($ table ->schemaName );
277
261
@@ -305,6 +289,9 @@ protected function findConstraints($table)
305
289
306
290
$ constraints = [];
307
291
foreach ($ this ->db ->createCommand ($ sql )->queryAll () as $ constraint ) {
292
+ if ($ this ->db ->slavePdo ->getAttribute (\PDO ::ATTR_CASE ) === \PDO ::CASE_UPPER ) {
293
+ $ constraint = array_change_key_case ($ constraint , CASE_LOWER );
294
+ }
308
295
if ($ constraint ['foreign_table_schema ' ] !== $ this ->defaultSchema ) {
309
296
$ foreignTable = $ constraint ['foreign_table_schema ' ] . '. ' . $ constraint ['foreign_table_name ' ];
310
297
} else {
@@ -373,6 +360,9 @@ public function findUniqueIndexes($table)
373
360
374
361
$ rows = $ this ->getUniqueIndexInformation ($ table );
375
362
foreach ($ rows as $ row ) {
363
+ if ($ this ->db ->slavePdo ->getAttribute (\PDO ::ATTR_CASE ) === \PDO ::CASE_UPPER ) {
364
+ $ row = array_change_key_case ($ row , CASE_LOWER );
365
+ }
376
366
$ column = $ row ['columnname ' ];
377
367
if (!empty ($ column ) && $ column [0 ] === '" ' ) {
378
368
// postgres will quote names that are not lowercase-only
0 commit comments