Skip to content

Column does not exist error with jsonb_each in Postgres #1979

Closed
@bretwalker

Description

@bretwalker

Version

1.15.0

What happened?

When running generate, I get an error about a column not existing even though it should and the select works if I run it directly against a database.

Relevant log output

query.sql:3:8: column "key" does not exist

Database schema

CREATE TABLE my_table (
  data JSONB NOT NULL
);

SQL queries

-- name: GetData :one

SELECT key, value
FROM my_table, jsonb_each(data)
LIMIT 1;

Configuration

version: "2"
sql:
  - engine: "postgresql"
    queries: "query.sql"
    schema: "schema.sql"
    gen:
      go:
        package: "example"
        out: "example"

Playground URL

https://play.sqlc.dev/p/51d375a16d47e652835b91f5bcebfd41eeb62da8cfc09a01bcbad790862ac9d8

What operating system are you using?

Linux, 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