sqlc icon indicating copy to clipboard operation
sqlc copied to clipboard

Kotlin generator doesn't work with named parameters

Open ahmed-envoy opened this issue 3 years ago • 1 comments

Version

1.12.0

What happened?

Tried to use named parameters with the Kotlin code generator, but ran into an error. I recreated the issue in the unit tests and came to know that Kotlin enforces the use of positional parameters with the Postgres engine.

Is it possible to get some guidance on which specific areas of the Kotlin code generator I should look at to add support for named parameters

Relevant log output

src/main/resources/authors/postgresql/query.sql:1:1: edited query syntax is invalid: syntax error at or near "dentifivation"
            src/main/resources/authors/postgresql/query.sql:10:1: edited query syntax is invalid: syntax error at or near "ame"
            src/main/resources/authors/postgresql/query.sql:18:1: edited query syntax is invalid: syntax error at or near "d"

Database schema

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

SQL queries

-- name: GetAuthor :one
SELECT * FROM authors
WHERE id = @identifivation LIMIT @lim;

-- name: ListAuthors :many
SELECT * FROM authors
ORDER BY name;

-- name: CreateAuthor :one
INSERT INTO authors (
          name, bio
) VALUES (
  @name, @bio
)
RETURNING *;

-- name: DeleteAuthor :exec
DELETE FROM authors
WHERE id = @id;

Configuration

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

Playground URL

No response

What operating system are you using?

macOS

What database engines are you using?

PostgreSQL

What type of code are you generating?

Kotlin

ahmed-envoy avatar Feb 23 '22 23:02 ahmed-envoy

The Kotlin code generation currently doesn't support named parameters. Sadly Kotlin support isn't actively being worked on, so you'll need to continue to use positional parameters.

kyleconroy avatar Aug 29 '22 02:08 kyleconroy

Migrated to https://github.com/tabbed/sqlc-gen-kotlin/issues/1

kyleconroy avatar Nov 09 '22 05:11 kyleconroy