Skip to content

Unable to generate parameter type where named parameters are on each side of an equal sign #1187

Closed as not planned
@boecklim

Description

@boecklim

Version

1.10.0

What happened?

The parameter data type is not generated by sqlc if in a situation query for a column with datatype jsonb where named parameters are on each side of an equal sign.

This type should be generated but it isn't

type GetFooByBarNumberedParams struct {
	key   pqtype.NullRawMessage
	value pqtype.NullRawMessage
}

Also the query generated is not what is expected

const getFooByBarNamed = `-- name: GetFooByBarNamed :one
SELECT bar_named FROM foo_named
WHERE bar_named->>@key = $1
LIMIT 1
`

It would be expected that this query is generated

const getFooByBarNamed = `-- name: GetFooByBarNamed :one
SELECT bar_named FROM foo_named
WHERE bar_named->>@key = @value
LIMIT 1
`

Relevant log output

No response

Database schema

CREATE TABLE foo_named (
    bar_named jsonb
);

SQL queries

-- name: GetFooByBarNamed :one
SELECT bar_named FROM foo_named
WHERE bar_named->>@key = @value
LIMIT 1;
​

Configuration

---

version: "1"
packages:
  - name: "db"
    path: "internal/db"
    queries: "./queries/"
    schema: "./migrations/"
    engine: "postgresql"
    emit_prepared_queries: false
    emit_interface: false
    emit_exact_table_names: false
    emit_empty_slices: false
    emit_json_tags: false

Playground URL

https://play.sqlc.dev/p/357e581cff2aec6d6d835ec993dc17eb8480686b7377d2704508a58da1a71313

What operating system are you using?

Linux

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