Skip to content

sqlc.arg (and it's shorthand @) not working for LIMIT and OFFSET #3840

Open
@733amir

Description

@733amir

Version

1.28.0

What happened?

The sqlc.arg or @ is not working for LIMIT and OFFSET.

Relevant log output

sqlc generate failed.
# package 
query.sql:23:9: syntax error at or near "limit"

Database schema

CREATE TABLE authors (
  id   BIGSERIAL PRIMARY KEY,
  name text      NOT NULL,
  bio  text
);

SQL queries

-- name: PaginatedShorthand :many
select * from authors
limit @limit offset @offset;

-- name: Paginated :many
select * from authors
limit sqlc.arg(limit) offset sqlc.arg(offset);

Configuration

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

Playground URL

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

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