Skip to content

Inheritance multi parent: more than one row returned by a subquery used as an expression #81

@deem0n

Description

@deem0n

From the PG docs: A table can inherit from more than one parent table, in which case it has the union of the columns defined by the parent tables.

That means we can have many parents for one child table which make the concept of the PG table inheritance confusing ;-)

If we create table which have many parents, then we will have SQL error with schemainspect: more than one row returned by a subquery used as an expression

where child.oid = c.oid)

I would propose returning array of parent tables, but not sure if that is supported by the rest of the schemainspect

Here is the problematic SQL:

'"' || nmsp_parent.nspname || '"."' || parent.relname || '"' as parent

You can use

SELECT json_agg(
              '"' || nmsp_parent.nspname || '"."' || parent.relname || '"') as parent

or

SELECT array_agg(
              '"' || nmsp_parent.nspname || '"."' || parent.relname || '"') as parent

and probably even

SELECT array_agg( format('%I.%I', nmsp_parent.nspname, parent.relname)) as parent

But you may want to set quote_all_identifiers to ensure that all names are always quoted with ".

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