Skip to content

SQLite: running generate on a query using the json_each function results in 'column "value" does not exist' for json_each.value reference #3802

Open
@hopesea

Description

@hopesea

Version

1.28.0

What happened?

Referening the "value" column from json_each function results in the error message 'column "value" does not exist'.
Aliasing the result from json_each function call has no impact either.

Relevant log output

sqlc generate failed.
# package 
query.sql:4:7: 396: column "value" does not exist

Database schema

CREATE TABLE demo (
	id INTEGER PRIMARY KEY AUTOINCREMENT,
	simple_val TEXT,
	compound_json_val TEXT
);

SQL queries

-- name: FetchDemoRowsByJsonVal :many
SELECT demo.*
  FROM demo, json_each(demo.compound_json_val)
WHERE json_each.value IN (sqlc.slice('param'));

Configuration

{
  "version": "2",
  "sql": [{
    "schema": "schema.sql",
    "queries": "query.sql",
    "engine": "sqlite",
    "gen": {
      "go": {
        "out": "db"
      }
    }
  }]
}

Playground URL

https://play.sqlc.dev/p/b48066cc2ed3aaba5ed85e794b275c9d3b4857b70d0c810b95de28d2e1a0d303

What operating system are you using?

macOS

What database engines are you using?

SQLite

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