]> git.joonet.de Git - adminer.git/commitdiff
Fix PgSQL generated always as identity fix
authorSartor <sartor@syneforge.com>
Wed, 29 Apr 2020 10:03:23 +0000 (13:03 +0300)
committerJakub Vrana <jakub@vrana.cz>
Sat, 6 Feb 2021 11:18:27 +0000 (12:18 +0100)
adminer/drivers/pgsql.inc.php
changes.txt

index 5466ed21b2432a03aac14a5cf6b4f3ee23d175de..8abcaba7b82280ed2a0053b72eeb8da80d1d8f42 100644 (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"]);
index 7fa7ad50d1e1ece45b8e010f7f4faa3e2b62ab7f..d3ddbdd5e4dae2a7acca8b1aaaeb41094ef512be 100644 (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):