Fix PgSQL generated always as identity fix

This commit is contained in:
Sartor 2020-04-29 13:03:23 +03:00 committed by Jakub Vrana
parent d888031603
commit 5cab8eabb7
2 changed files with 4 additions and 3 deletions

View file

@ -350,7 +350,7 @@ WHERE relkind IN ('r', 'm', 'v', 'f')
'timestamp with time zone' => 'timestamptz',
);
$identity_column = min_version(10) ? "(a.attidentity = 'd')::int" : '0';
$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
FROM pg_class c
@ -375,8 +375,8 @@ ORDER BY a.attnum"
$row["type"] = $type;
$row["full_type"] = $row["type"] . $length . $addon . $array;
}
if ($row['identity']) {
$row['default'] = 'GENERATED BY DEFAULT AS IDENTITY';
if (in_array($row['identity'], array('a', 'd'))) {
$row['default'] = 'GENERATED ' . ($row['identity'] == 'd' ? 'BY DEFAULT' : 'ALWAYS') . ' AS IDENTITY';
}
$row["null"] = !$row["attnotnull"];
$row["auto_increment"] = $row['identity'] || preg_match('~^nextval\(~i', $row["default"]);

View file

@ -2,6 +2,7 @@ Adminer 4.7.9-dev:
Elasticsearch, ClickHouse: Do not print response if HTTP code is not 200
PostgreSQL: Export all FKs after all CREATE TABLE (PR #351)
PostgreSQL: Fix dollar-quoted syntax highlighting (bug #738)
PostgreSQL 10: Support GENERATED ALWAYS BY IDENTITY (PR #386)
Re-enable PHP warnings (regression from 4.7.8)
Adminer 4.7.8 (released 2020-12-06):