Skip to content

core: LIMIT/OFFSET parameters named Column1/Column2 instead of Limit/Offset #4730

Backlog

Description

@manuelschoene

Version

Other (main at 5daa2db, sqlc version: v1.31.1-105)

What happened?

Under the core analyzer (SQLCEXPERIMENT=coreanalyzer), LIMIT and OFFSET placeholders get no name. The generated params struct has Column1/Column2 instead of Limit/Offset. The default analyzer names them correctly.

Generated with the default analyzer (expected):

type FooLimitCommaParams struct {
	Offset int64
	Limit  int64
}

Generated with SQLCEXPERIMENT=coreanalyzer:

type FooLimitCommaParams struct {
	Column1 int64
	Column2 int64
}

The order of the arguments is correct on both paths. Only the names are lost, so the generated code still runs.

This is not limited to SQLite's LIMIT ?, ? form. LIMIT ? OFFSET ? is affected the same way on SQLite and MySQL. The existing select_limit/sqlite and select_limit/mysql end-to-end cases already fail in the core replay context:

SQLC_TEST_CORE=1 go test ./internal/endtoend -run 'TestReplay/core/select_limit/'

The comma form deserves its own coverage: in LIMIT x, y the first placeholder is the offset, so a fix that names placeholders by position would swap the two names there.

#4614 mentions this as a leftover. A naming attempt in the core was backed out there because it changed analyze output for SQLite and ClickHouse, which suggests the fix belongs in the compiler bridge rather than in the analysis.

Relevant log output

No response

Database schema

CREATE TABLE foo (a text);

SQL queries

/* name: FooLimitComma :many */
SELECT a
FROM foo
LIMIT ?, ?;

Configuration

{
  "version": "1",
  "packages": [
    {
      "engine": "sqlite",
      "path": "go",
      "name": "querytest",
      "schema": "schema.sql",
      "queries": "query.sql"
    }
  ]
}

Playground URL

No response

What operating system are you using?

Linux

What database engines are you using?

SQLite, MySQL

What type of code are you generating?

Go

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions