Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Can not handle cross-schema inheritance in postgres #4128

Open
@axlalmflower

Description

Version

1.29.0

What happened?

SQLC cannot handle cross-schema inheritance.

migration file, valid in postgres

CREATE SCHEMA schema_one;
CREATE SCHEMA schema_two;
CREATE TABLE schema_one.parent (
 foo TEXT
);
CREATE TABLE schema_two.child (
 bar TEXT
) INHERITS (schema_one.parent);

command:

sqlc generate

output:

000001_some_migration.up.sql:1:1: relation "parent" does not exist

Looking at the PR which adds inheritance it seems like the problem is that the schema of the CREATE clause is used to fetched the inherited table. I.e. there is an assumption that the tables are in the same schema. Same is done in latest version; see this line.

Fix, I would assume, would be to get the schema for the table referred to in the INHERITS part. Then use inherited_schema.getTable(inheritTable).

Relevant log output

000001_some_migration.up.sql:1:1: relation "parent" does not exist

Database schema

CREATE SCHEMA schema_one;
CREATE SCHEMA schema_two;
CREATE TABLE schema_one.parent (
 foo TEXT
);
CREATE TABLE schema_two.child (
 bar TEXT
) INHERITS (schema_one.parent);

SQL queries

Configuration

Playground URL

No response

What operating system are you using?

macOS

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /