Skip to content

Commit

Permalink
PostgreSQL < 10 PDO: Avoid displaying GENERATED ALWAYS BY IDENTITY ev…
Browse files Browse the repository at this point in the history
…erywhere (bug #785)
  • Loading branch information
vrana committed Feb 15, 2021
1 parent 7f8c93a commit 28996e2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
10 changes: 4 additions & 6 deletions adminer/drivers/pgsql.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,7 @@ function fields($table) {
'timestamp with time zone' => 'timestamptz',
);

$identity_column = min_version(10) ? 'a.attidentity' : '0';

foreach (get_rows("SELECT a.attname AS field, format_type(a.atttypid, a.atttypmod) AS full_type, pg_get_expr(d.adbin, d.adrelid) AS default, a.attnotnull::int, col_description(c.oid, a.attnum) AS comment, $identity_column AS identity
foreach (get_rows("SELECT a.attname AS field, format_type(a.atttypid, a.atttypmod) AS full_type, pg_get_expr(d.adbin, d.adrelid) AS default, a.attnotnull::int, col_description(c.oid, a.attnum) AS comment" . (min_version(10) ? ", a.attidentity" : "") . "
FROM pg_class c
JOIN pg_namespace n ON c.relnamespace = n.oid
JOIN pg_attribute a ON c.oid = a.attrelid
Expand All @@ -373,11 +371,11 @@ function fields($table) {
$row["type"] = $type;
$row["full_type"] = $row["type"] . $length . $addon . $array;
}
if (in_array($row['identity'], array('a', 'd'))) {
$row['default'] = 'GENERATED ' . ($row['identity'] == 'd' ? 'BY DEFAULT' : 'ALWAYS') . ' AS IDENTITY';
if (in_array($row['attidentity'], array('a', 'd'))) {
$row['default'] = 'GENERATED ' . ($row['attidentity'] == 'd' ? 'BY DEFAULT' : 'ALWAYS') . ' AS IDENTITY';
}
$row["null"] = !$row["attnotnull"];
$row["auto_increment"] = $row['identity'] || preg_match('~^nextval\(~i', $row["default"]);
$row["auto_increment"] = $row['attidentity'] || preg_match('~^nextval\(~i', $row["default"]);
$row["privileges"] = array("insert" => 1, "select" => 1, "update" => 1);
if (preg_match('~(.+)::[^,)]+(.*)~', $row["default"], $match)) {
$row["default"] = ($match[1] == "NULL" ? null : (($match[1][0] == "'" ? idf_unescape($match[1]) : $match[1]) . $match[2]));
Expand Down
1 change: 1 addition & 0 deletions changes.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Adminer 4.8.1-dev:
Fix more PHP 8 warnings (bug #781)
MySQL: Allow moving views to other DB and renaming DB with views (bug #783)
PostgreSQL < 10 PDO: Avoid displaying GENERATED ALWAYS BY IDENTITY everywhere (bug #785, regression from 4.7.9)
SQLite: Fix displayed types (bug #784, regression from 4.8.0)

Adminer 4.8.0 (released 2021-02-10):
Expand Down

0 comments on commit 28996e2

Please sign in to comment.