Opened 6 years ago
Last modified 4 years ago
#29722 closed New feature
Add introspection of special table and view types. — at Version 3
Reported by: | Nick Pope | Owned by: | Nick Pope |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Normal | Keywords: | postgresql, introspection, inspectdb, views, partitions |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Originally this ticket was aimed at PostgreSQL:
Looking at the documentation for pg_class there are the following types that we might be interested in introspecting for generation of models:
r
— ordinary table — obviously this is already supported.v
— views — support was implemented in #29004.f
— foreign table — being addressed by #29719.m
— materialized views — could be handled much like #29004, mappingm
tov
.p
— partitioned table — could be handled mappingp
tot
, but gets more complicated, read on below...
For partitioned tables, we are unlikely to want to generate models for all of the individual partitions, although this could be supported with an --include-partitions
flag.
From this link we can see an example of output for partitioned tables:
relid | relname | relsize | relispartition | relkind -------+--------------------+---------+----------------+--------- 16410 | population | 0 | f | p 16417 | population_s | 8192 | t | r 16424 | population_t | 0 | t | p 16431 | population_t_10_20 | 8192 | t | r 16445 | population_t_20_30 | 8192 | t | r
On PostgreSQL 10+ we need to filter on NOT relispartition
to ignore all of the partitions and only include the parent (which is the table that is usually interacted with).
Regarding support for all backends:
Feature support by backend:
PostgreSQL | MySQL | Oracle | SQLite | |
---|---|---|---|---|
Partitions | ✔ | ✔ | ✔ | ✘ |
Foreign Tables | ✔ | ✘ | ✘ | ✘ |
Materialized Views | ✔ | ✘ | ✔ | ✘ |
It looks partitions can be introspected using INFORMATION_SCHEMA.PARTITIONS
for MySQL and there are other options for Oracle.
For introspection of materialized views, I think we could use USER_MVIEWS
for Oracle.
Change History (3)
comment:1 by , 6 years ago
Summary: | Improve introspection for special table and view types in PostgreSQL → Add introspection of special table and view types in PostgreSQL |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 6 years ago
Has patch: | set |
---|---|
Owner: | changed from | to
Status: | new → assigned |
comment:3 by , 6 years ago
Description: | modified (diff) |
---|---|
Summary: | Add introspection of special table and view types in PostgreSQL → Add introspection of special table and view types. |
PR