Skip to content

override for json not working in golang #3979

Open
@julian-reactive

Description

@julian-reactive

Version

1.29.0

What happened?

set overrides for a field type json is not working

Image

Image

sqlc generate

Image

GetOrderProductsRow.Additionals should be json cutom type not []byte

Relevant log output

Database schema

CREATE TABLE public.order_products (
	id bigserial NOT NULL,
	product_amount int4 NULL,
	additionals json NULL,
	order_id uuid NOT NULL,
	product_id uuid NOT NULL,
	created_at timestamp(6) NOT NULL,
	updated_at timestamp(6) NOT NULL,
	deleted bool DEFAULT false NULL,
	product_price float8 NULL,
	CONSTRAINT order_products_order_id_product_id_key UNIQUE (order_id, product_id),
	CONSTRAINT order_products_pkey PRIMARY KEY (id),
	CONSTRAINT fk_rails_96c0709f78 FOREIGN KEY (product_id) REFERENCES public.products(id),
	CONSTRAINT fk_rails_f40b8ccee4 FOREIGN KEY (order_id) REFERENCES public.orders(id)
);

SQL queries

-- name: GetOrderProducts :many
SELECT
  op.id,
  op.product_amount,
  op.additionals,
  op.product_price,
  p.name AS product_name
FROM order_products op
JOIN products p ON op.product_id = p.id
WHERE op.order_id = $1;

Configuration

version: "2"
sql:
  - engine: "postgresql"
    queries: "db/queries"
    schema: "db/migrations"
    gen:
      go:
        package: "db"
        sql_package: "pgx/v5"
        out: "internal/db"
        overrides:
          - db_type: "json"
            go_type: "encoding/json.RawMessage"

Playground URL

No response

What operating system are you using?

mac and linux

What database engines are you using?

postgresql

What type of code are you generating?

No response

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