Skip to content

sqlc.arg and @ does not work when queries getting complicated  #2202

@Shihansin

Description

@Shihansin

Version

1.17.2

What happened?

WITH new_promo AS (
  INSERT INTO promotion (name, description, start_date, end_date)
  VALUES ($1, $2, $3, $4)
  RETURNING id
), new_promo_configs AS (
  INSERT INTO promotion_config (product_id, promotion_id, pd_start_date, pd_end_date)
  SELECT unnest(@product_id::BIGINT[]), (SELECT id FROM new_promo), $6, $7
)
RETURNING * ;

this doesn't  work , it return 

db/queries/createpromo.sql:1:1: could not determine data type of parameter $5
make: *** [Makefile:17: sqlc] Error 1

WITH new_promo AS (
  INSERT INTO promotion (name, description, start_date, end_date)
  VALUES ($1, $2, $3, $4)
  RETURNING id
), new_promo_configs AS (
  INSERT INTO promotion_config (product_id, promotion_id, pd_start_date, pd_end_date)
  SELECT unnest($5::BIGINT[]), (SELECT id FROM new_promo), $6, $7
)
RETURNING * ;

this works, but return column5

if you have a more complicated query like above , then @ and sqlc,arg does not work

Relevant log output

db/queries/createpromo.sql:1:1: could not determine data type of parameter $5
make: *** [Makefile:17: sqlc] Error 1

Database schema

No response

SQL queries

No response

Configuration

No response

Playground URL

No response

What operating system are you using?

Windows

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