We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1.18.0
A field should be added to params but it does not
const productListByOwner = `-- name: ProductListByOwner :many SELECT id, owner_id, created_by, name, slug, category_id, vendor_id, tags, created_at, updated_at, published_at, deleted_at FROM products WHERE owner_id = $1 AND (deleted_at IS NOT NULL OR $4 IS NULL) ORDER BY id ASC LIMIT $2 OFFSET $3 ` type ProductListByOwnerParams struct { OwnerID int32 Limit int32 Offset int32 } func (q *Queries) ProductListByOwner(ctx context.Context, arg *ProductListByOwnerParams) ([]Product, error) { rows, err := q.db.QueryContext(ctx, productListByOwner, arg.OwnerID, arg.Limit, arg.Offset) if err != nil { return nil, err } defer rows.Close() var items []Product for rows.Next() { var i Product if err := rows.Scan( &i.ID, &i.DeletedAt, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil }
CREATE TABLE products ( id SERIAL PRIMARY KEY, owner_id INT NOT NULL, created_by INT NOT NULL, name VARCHAR(100) NOT NULL, slug VARCHAR(255) NOT NULL, created_at TIMESTAMP NOT NULL DEFAULT NOW(), updated_at TIMESTAMP NOT NULL DEFAULT NOW(), published_at TIMESTAMP, deleted_at TIMESTAMP );
version: "2" sql: - engine: "postgresql" queries: "internal/db/query.sql" schema: "internal/db/schema.sql" gen: go: package: "db" out: "internal/db" emit_params_struct_pointers: true
https://play.sqlc.dev/p/f2ae3b0558f20a7040d2aeb039f30d7c797b51fe6b2c67fcdc3522d838024a24
Linux
PostgreSQL
Go
The text was updated successfully, but these errors were encountered:
In this case, the problem seems to occur because the type of sqlc.narg cannot be determined. If you explicitly specify the type as follows, it works. https://play.sqlc.dev/p/7037e328e07626afa86b94322ef813279c5649f72e6f062b28b07e3deab8837f
What type did you expect sqlc.narg('DeletedAt') to be?
sqlc.narg('DeletedAt')
Sorry, something went wrong.
When running this query through PostgreSQL, we get the following error:
queries/products.sql:1:1: ERROR: could not determine data type of parameter $4 (SQLSTATE 42P18)
That said, sqlc shouldn't drop the parameter completely, as that will result in a query error.
Fixed in #2844
No branches or pull requests
Version
1.18.0
What happened?
A field should be added to params but it does not
Relevant log output
Database schema
Configuration
Playground URL
https://play.sqlc.dev/p/f2ae3b0558f20a7040d2aeb039f30d7c797b51fe6b2c67fcdc3522d838024a24
What operating system are you using?
Linux
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go
The text was updated successfully, but these errors were encountered: