Permalink
Browse files

Fixes #1435: pgsql getTableNames() should not prefix table names wit…

…h schema name.
  • Loading branch information...
qiangxue committed Dec 5, 2013
1 parent 2fca1e9 commit 64ef54bf183b66a10c7c6fee77917a5db256ca29
Showing with 2 additions and 7 deletions.
  1. +2 −7 framework/yii/db/pgsql/Schema.php
@@ -156,8 +156,7 @@ public function getPdoType($data)
/**
* Returns all table names in the database.
* @param string $schema the schema of the tables. Defaults to empty string, meaning the current or default schema.
- * If not empty, the returned table names will be prefixed with the schema name.
- * @return array all table names in the database.
+ * @return array all table names in the database. The names have NO schema name prefix.
*/
protected function findTableNames($schema = '')
{
@@ -173,11 +172,7 @@ protected function findTableNames($schema = '')
$rows = $command->queryAll();
$names = [];
foreach ($rows as $row) {
- if ($schema === $this->defaultSchema) {
- $names[] = $row['table_name'];
- } else {
- $names[] = $row['table_schema'] . '.' . $row['table_name'];
- }
+ $names[] = $row['table_name'];
}
return $names;
}

4 comments on commit 64ef54b

@gitrad

This comment has been minimized.

Show comment
Hide comment
@gitrad

gitrad Dec 5, 2013

Contributor

did not work. i changed public to office in yii\dbpgsql\schema.php manually line (28):

public $defaultSchema = 'office';

and it did work.

i have several backend with special db user and special schema granted to that user.
is it any way to override it in every backend ( eg. in backend\config\params.php -> dsn ).

Contributor

gitrad replied Dec 5, 2013

did not work. i changed public to office in yii\dbpgsql\schema.php manually line (28):

public $defaultSchema = 'office';

and it did work.

i have several backend with special db user and special schema granted to that user.
is it any way to override it in every backend ( eg. in backend\config\params.php -> dsn ).

@qiangxue

This comment has been minimized.

Show comment
Hide comment
@qiangxue

qiangxue Dec 5, 2013

Member

Do you mean entering office.* as table name doesn't work?

Yes, it is possible to configure defaultSchema. You can do so by responding to Connection's afterOpen event and set $db->schema->defaultSchema.

Member

qiangxue replied Dec 5, 2013

Do you mean entering office.* as table name doesn't work?

Yes, it is possible to configure defaultSchema. You can do so by responding to Connection's afterOpen event and set $db->schema->defaultSchema.

@gitrad

This comment has been minimized.

Show comment
Hide comment
@gitrad

gitrad Dec 5, 2013

Contributor

yes office.* ( even ' * ' alone ) doesn't work.
but 'person' and 'office.person' after setting _public $defaultSchema = 'office';_
works.

Contributor

gitrad replied Dec 5, 2013

yes office.* ( even ' * ' alone ) doesn't work.
but 'person' and 'office.person' after setting _public $defaultSchema = 'office';_
works.

@gitrad

This comment has been minimized.

Show comment
Hide comment
@gitrad

gitrad Dec 5, 2013

Contributor

is setting by _$db->schema->defaultSchema_ application-wide?
i mean once for every backend? and where?

Contributor

gitrad replied Dec 5, 2013

is setting by _$db->schema->defaultSchema_ application-wide?
i mean once for every backend? and where?

Please sign in to comment.