Skip to content

Commit fd4edf4

Browse files
[11.x] Fix retrieving generated columns on legacy PostgreSQL (#50834)
* fix retrieving generated column on pgsql < 12 * flip the condition
1 parent 21d32cc commit fd4edf4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public function compileColumns($schema, $table)
123123
.'(select tc.collcollate from pg_catalog.pg_collation tc where tc.oid = a.attcollation) as collation, '
124124
.'not a.attnotnull as nullable, '
125125
.'(select pg_get_expr(adbin, adrelid) from pg_attrdef where c.oid = pg_attrdef.adrelid and pg_attrdef.adnum = a.attnum) as default, '
126-
.'a.attgenerated as generated, '
126+
.(version_compare($this->connection?->getServerVersion(), '12.0', '<') ? "'' as generated, " : 'a.attgenerated as generated, ')
127127
.'col_description(c.oid, a.attnum) as comment '
128128
.'from pg_attribute a, pg_class c, pg_type t, pg_namespace n '
129129
.'where c.relname = %s and n.nspname = %s and a.attnum > 0 and a.attrelid = c.oid and a.atttypid = t.oid and n.oid = c.relnamespace '

0 commit comments

Comments
 (0)