@@ -88,9 +88,14 @@ public function getColumns(string $table, ?string $schema = null): array
88
88
CASE WHEN a.atttypmod = -1 THEN NULL ELSE a.atttypmod -4 END AS size,
89
89
pg_catalog.pg_get_expr(ad.adbin, 'pg_catalog.pg_attrdef'::regclass)::varchar AS default,
90
90
COALESCE(co.contype = 'p', FALSE) AS is_primary,
91
- COALESCE(co.contype = 'p' AND strpos(pg_get_expr(ad.adbin, ad.adrelid), 'nextval') = 1, FALSE) AS is_autoincrement,
91
+ COALESCE(co.contype = 'p' AND ( strpos(pg_get_expr(ad.adbin, ad.adrelid), 'nextval') = 1 OR a.attidentity != '') , FALSE) AS is_autoincrement,
92
92
NOT (a.attnotnull OR t.typtype = 'd' AND t.typnotnull) AS is_nullable,
93
- SUBSTRING(pg_catalog.pg_get_expr(ad.adbin, 'pg_catalog.pg_attrdef'::regclass) FROM %s) AS sequence
93
+ " ) . (
94
+ count ($ tableArgs ) > 1
95
+ ? "pg_get_serial_sequence('%table.%table', a.attname) AS sequence "
96
+ : "pg_get_serial_sequence('%table', a.attname) AS sequence "
97
+ )
98
+ . (/** @lang GenericSQL */ "
94
99
FROM
95
100
pg_catalog.pg_attribute AS a
96
101
JOIN pg_catalog.pg_class AS c ON a.attrelid = c.oid
@@ -108,7 +113,7 @@ public function getColumns(string $table, ?string $schema = null): array
108
113
AND NOT a.attisdropped
109
114
ORDER BY
110
115
a.attnum
111
- " ), " nextval[(]' \" ?([^' \" ]+) " , ...$ tableArgs );
116
+ " ), ... $ tableArgs , ...$ tableArgs );
112
117
113
118
$ columns = [];
114
119
foreach ($ result as $ row ) {
0 commit comments