Skip to content

Commit 7d960bf

Browse files
committed
[BUGFIX] Add a.attisdropped = false flag to compile columns sql to fix the output of Schema::getColumns()
1 parent f5a1282 commit 7d960bf

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/Schema/CockroachGrammar.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,21 @@ public function compileDropUnique(Blueprint $blueprint, Fluent $command)
6868

6969
return "drop index {$this->wrapTable($blueprint)}@{$index} cascade";
7070
}
71+
72+
public function compileColumns($database, $schema, $table): string
73+
{
74+
return sprintf(
75+
'select a.attname as name, t.typname as type_name, format_type(a.atttypid, a.atttypmod) as type, '
76+
.'(select tc.collcollate from pg_catalog.pg_collation tc where tc.oid = a.attcollation) as collation, '
77+
.'not a.attnotnull as nullable, '
78+
.'(select pg_get_expr(adbin, adrelid) from pg_attrdef where c.oid = pg_attrdef.adrelid and pg_attrdef.adnum = a.attnum) as default, '
79+
.'col_description(c.oid, a.attnum) as comment '
80+
.'from pg_attribute a, pg_class c, pg_type t, pg_namespace n '
81+
.'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 and a.attisdropped = false '
82+
.'order by a.attnum',
83+
$this->quoteString($table),
84+
$this->quoteString($schema)
85+
);
86+
}
87+
7188
}

0 commit comments

Comments
 (0)