Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Postgres: JSONB type override doesn't work with named parameters on Insert #4089

Open
@martin31821

Description

Version

1.30.0

What happened?

I've tried to run an INSERT INTO on postgres with a JSONB column and using sqlc.arg(name)::jsonb as type.

The column is type-overridden with a custom go-struct, which also works when having 1ドル as parameter in the insert query. It breaks when changing 1ドル into sqlc.arg(name)::jsonb.

As a user, I'd expect sqlc to track the type overrides.

Relevant log output

Database schema

CREATE TABLE public.sample (
 name text not null,
 id text not null,
 settings jsonb
);

SQL queries

INSERT INTO sample (name, id, settings) VALUES (sqlc.arg(custom_name)::text, sqlc.arg(id)::text, sqlc.arg(default_settings)::jsonb) RETURNING *;

Configuration

version: "2"
sql:
- engine: "postgresql"
 schema: "sql/schema.sql"
 queries: "sql/queries.sql"
 gen:
 go:
 emit_interface: true
 emit_enum_valid_method: true
 emit_pointers_for_null_types: true
 out: "./database"
 package: "database"
 sql_package: "pgx/v5"
 overrides:
 - column: "sample.settings"
 go_type:
 type: "Settings"
 package: dto
 import: "my_pkg/dto"

Playground URL

No response

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

        AltStyle によって変換されたページ (->オリジナル) /