Skip to content

simple migration with materialized view cannot be parsed #2300

Open
@antonio-antuan

Description

@antonio-antuan

Version

1.17.2

What happened?

checked with 1.16.0, 1.17.2, 1.18.0

With a migration below I'm trying to launch sqlc and got an error during migrations parsing.

Using renaming I couldn't fix the issue.

It's important to have exactly this kind of identifiers specification (schema.table.column) because this is a way how our tool generates migrations (so yes, the migration is auto-generated).

Relevant log output

➜ ✗ sqlc generate
# package db
migrations/1.sql:10:10: column reference "" not found

Database schema

create schema if not exists app;
CREATE TABLE app.table
(
    "id"              int
);

CREATE MATERIALIZED VIEW mat_view AS
SELECT app.table.id
FROM app.table
GROUP BY app.table.id;

SQL queries

doesn't matter

Configuration

version: "1"
packages:
  - name: "db"
    path: "./internal/db"
    queries: "./queries/"
    schema: "migrations"
    engine: "postgresql"
    emit_prepared_queries: true
    emit_interface: false
    emit_exact_table_names: false
    emit_empty_slices: false
    emit_json_tags: true
    json_tags_case_style: "snake"
    # TODO: unable to use -  sql_package: "pgx/v4" since we will loose tracing support for pg
overrides:
  - db_type: "pg_catalog.timestamp"
    go_type:
      import: "time"
      type: "Time"
      pointer: true
    nullable: true
  - db_type: "pg_catalog.timestamptz"
    go_type:
      import: "time"
      type: "Time"
      pointer: true
    nullable: true
  - db_type: "text"
    go_type:
      type: "string"
      pointer: true
    nullable: true
  - db_type: "pg_catalog.varchar"
    go_type:
      type: "string"
      pointer: true
    nullable: true
  - db_type: "ltree"
    go_type:
      type: "string"
      pointer: true
    nullable: true
  - db_type: "jsonb"
    go_type:
      import: "encoding/json"
      type: "RawMessage"
      pointer: true
    nullable: true
  - db_type: "json"
    go_type:
      import: "encoding/json"
      type: "RawMessage"
      pointer: true
    nullable: true
  - db_type: "pg_catalog.int2"
    go_type:
      type: "int16"
      pointer: true
    nullable: true
  - db_type: "pg_catalog.int4"
    go_type:
      type: "int"
      pointer: true
    nullable: true
  - db_type: "pg_catalog.int8"
    go_type:
      type: "int64"
      pointer: true
    nullable: true
  - db_type: "pg_catalog.bool"
    go_type:
      type: "bool"
      pointer: true
    nullable: true
  - db_type: "pg_catalog.float4"
    go_type:
      type: "float32"
      pointer: true
    nullable: true
  - db_type: "pg_catalog.float8"
    go_type:
      type: "float64"
      pointer: true
    nullable: true
  - db_type: "bigserial"
    go_type:
      type: "int"
      pointer: true
    nullable: true

Playground URL

https://play.sqlc.dev/p/18b7c68b9c3e7a1d285c7b7582ed1648b0383af161ee0f38ebcfbaace6ac8bfe

What operating system are you using?

Linux

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