Skip to content

Commit

Permalink
Merge pull request #27743 from jordanlewis/simplify-postgres-column-d…
Browse files Browse the repository at this point in the history
…efinitions

Simplify query in column_definitions() for Postgres
  • Loading branch information
rafaelfranca committed Jan 30, 2017
2 parents 6bf6957 + f9c6cbd commit eda7f26
Showing 1 changed file with 5 additions and 5 deletions.
Expand Up @@ -759,11 +759,11 @@ def column_definitions(table_name)
query(<<-end_sql, "SCHEMA")
SELECT a.attname, format_type(a.atttypid, a.atttypmod),
pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
(SELECT c.collname FROM pg_collation c, pg_type t
WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation),
col_description(a.attrelid, a.attnum) AS comment
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
c.collname, col_description(a.attrelid, a.attnum) AS comment
FROM pg_attribute a
LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
LEFT JOIN pg_type t ON a.atttypid = t.oid
LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation
WHERE a.attrelid = #{quote(quote_table_name(table_name))}::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
Expand Down

0 comments on commit eda7f26

Please sign in to comment.