Skip to content

missing argument in ORDER BY clause #4211

@em-ily-dev

Description

@em-ily-dev

Version

1.30.0

What happened?

The generated code for the following schema supplies only one of the two parameters in the query.

const getMainSequence = `-- name: GetMainSequence :one
SELECT ID FROM Sequence
WHERE SeriesID = ?
ORDER BY Name = ? DESC, ID
LIMIT 1
`

func (q *Queries) GetMainSequence(ctx context.Context, seriesid string) (string, error) {
	row := q.db.QueryRowContext(ctx, getMainSequence, seriesid)
	var id string
	err := row.Scan(&id)
	return id, err
}

This seems similar to #3990 and #3834.

Relevant log output

msg="missing argument with index 2"

Database schema

CREATE TABLE Sequence
(
	ID       TEXT PRIMARY KEY DEFAULT (newID()),
	Name     TEXT NOT NULL,
	SeriesID TEXT NOT NULL REFERENCES Series
)
STRICT;

SQL queries

-- name: GetMainSequence :one
SELECT ID FROM Sequence
WHERE SeriesID = ?
ORDER BY Name = ? DESC, ID
LIMIT 1;

Configuration

{
  "version": "2",
  "sql": [
    {
      "engine": "sqlite",
      "queries": "query.sql",
      "schema": "ddl",
      "gen": {
        "go": {
          "package": "schema",
          "out": "schema",
          "emit_exact_table_names": true,
          "emit_pointers_for_null_types": true,
          "rename": {
            "artworkkey": "ArtworkKey",
            "ownerid": "OwnerID",
            "sequenceid": "SequenceID",
            "seriesid": "SeriesID",
            "sortkey": "SortKey",
            "tagid": "TagID"
          }
        }
      }
    }
  ]
}

Playground URL

No response

What operating system are you using?

Linux

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