Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pg schema #24999

Merged
merged 15 commits into from
Jun 5, 2019
16 changes: 13 additions & 3 deletions libraries/joomla/database/driver/postgresql.php
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ public function getTableCreate($tables)
/**
* Retrieves field information about a given table.
*
* @param string $table The name of the database table.
* @param string $table The name of the database table. For PostgreSQL may start with a schema.
* @param boolean $typeOnly True to only return field types.
*
* @return array An array of fields for the database table.
Expand All @@ -404,8 +404,18 @@ public function getTableColumns($table, $typeOnly = true)
$this->connect();

$result = array();

$tableSub = $this->replacePrefix($table);
$fn = explode('.', $tableSub);

if (count($fn) == 2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (count($fn) == 2)
if (count($fn) == 2)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

softarius marked this conversation as resolved.
Show resolved Hide resolved
{
$schema = $fn[0];
$tableSub = $fn[1];
}
else
{
$schema = 'public';
}

$this->setQuery('
SELECT a.attname AS "column_name",
Expand All @@ -427,7 +437,7 @@ public function getTableColumns($table, $typeOnly = true)
WHERE a.attrelid =
(SELECT oid FROM pg_catalog.pg_class WHERE relname=' . $this->quote($tableSub) . '
AND relnamespace = (SELECT oid FROM pg_catalog.pg_namespace WHERE
nspname = \'public\')
nspname = ' . $this->quote($schema) . ')
)
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum'
Expand Down