Skip to content

information_schema.columns and pg_attribute report nothing for views #104

Description

@erans

Problem

information_schema.columns and pg_attribute both report nothing for views. Each restricts to type = 'table':

  • information_schema_columns (migration v29, src/migration/registry.rs) — WHERE m.type = 'table'
  • pg_attribute (migration v26) — same restriction

This is longstanding behavior, unchanged by #103 (which rebuilt information_schema_columns but deliberately preserved the restriction to avoid widening that change's blast radius). The Rust handler #103 deleted had the same limitation, so nothing regressed — but nothing improved either.

Why it matters

Real PostgreSQL reports view columns in both surfaces. ORMs use this for view reflection: SQLAlchemy's Inspector.get_columns() works on views, and Django's inspectdb will discover a view but generate a model with no fields.

What to do

Extend both to type IN ('table', 'view').

The interesting part is type resolution. A view's columns have no PRAGMA table_info declared type in the useful sense — SQLite reports empty strings for expression columns — and no __pgsqlite_schema rows at all, since that table is populated at CREATE TABLE time. Options worth weighing:

  1. Report text for every view column (honest, cheap, matches the current ELSE 'text' fallback).
  2. Resolve through PRAGMA table_info where SQLite infers a type from a passthrough column, falling back to text.
  3. Trace simple SELECT col FROM t views back to the base table's __pgsqlite_schema entry.

(3) is the only one that gets NUMERIC/UUID/JSONB right on a view, but it needs view-body parsing and stops working the moment an expression is involved.

Notes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions