Closed
Description
If I do something like
CREATE TABLE authors (
id BIGSERIAL PRIMARY KEY,
name text NOT NULL
);
-- name: UpdateAuthor :exec
UPDATE authors
SET name = $1
WHERE id = $1;
In theory this should error because $1 must either be a number or a text. PostgreSQL returns the following error when executing this query:
ERROR: invalid input syntax for type bigint: "foo"
In practice sqlc is happy to allow it, generating the following code:
// Code generated by sqlc. DO NOT EDIT.
// source: query.sql
package querytest
import (
"context"
)
const updateAuthor = `-- name: UpdateAuthor :exec
UPDATE authors
SET name = $1
WHERE id = $1
`
func (q *Queries) UpdateAuthor(ctx context.Context, name string) error {
_, err := q.db.ExecContext(ctx, updateAuthor, name)
return err
}