sqlc-dev / sqlc

Generate type-safe code from SQL
https://sqlc.dev
MIT License
12.26k stars 778 forks source link

Playground does not work when a column is named "user" #3575

Closed EwenQuim closed 6 days ago

EwenQuim commented 1 week ago

Version

1.27.0

What happened?

Relevant log output

sqlc generate failed.
# package 
schema.sql:4:4: syntax error at or near "user"

Database schema

CREATE TABLE IF NOT EXISTS notes (
  id text PRIMARY KEY,
  slug text NOT NULL,
  user text NOT NULL, 
  UNIQUE(slug, user)
);

SQL queries

None

Configuration

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

Playground URL

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

What operating system are you using?

No response

What database engines are you using?

No response

What type of code are you generating?

No response

kyleconroy commented 1 week ago

Thanks for the report. user conflicts with a built in function for PostgreSQL, so you need to use it double quotes. Here's a working example.

https://play.sqlc.dev/p/02bbc37ca7fc34be99fb9d941f11ece21b3e642d7680f215d156845fc4de43be