Skip to content

LIMIT results in Syntax Error #1665

Closed as not planned
Closed as not planned
@rhodee

Description

@rhodee

Version

1.13.0

What happened?

Hello!

I tried to create a query with dynamic query/offset. Unfortunately, it returned an error.

Tickets I discovered:

https://github.com/kyleconroy/sqlc/issues?q=is%3Aissue+is%3Aopen+limit+label%3A%22%3Abooks%3A+mysql%22

Things I've tried:

#1439 - it appears changing the reserve words did not change the error.

Comparing the output of PG and MySQL


This works for PG and not for MySQL

Relevant log output

sqlc generate failed.
# package db
query.sql:16:11: syntax error near "sqlc.arg(row_offset), sqlc.arg(row_limit);"

Database schema

-- Example queries for sqlc
CREATE TABLE authors (
  id  varchar(255) NOT NULL,
  name text      NOT NULL,
  bio  text
);

SQL queries

-- name: ListAuthors :many
SELECT * FROM authors
ORDER BY name
LIMIT sqlc.arg(row_offset), sqlc.arg(row_limit);

Configuration

{
  "version": "1",
  "packages": [
    {
      "path": "db",
      "engine": "mysql",
      "schema": "query.sql",
      "queries": "query.sql"
    }
  ]
}

Playground URL

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

What operating system are you using?

macOS

What database engines are you using?

MySQL

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