You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I try to use twice the $4 argument but it doesn't work in this specific case
`
INSERT INTO public.users (username, email, provider, client_uid, client_id)
VALUES ($1, $2, $3, $4, (select public.clients.id from public.clients where public.clients.uid = $4 limit 1))
RETURNING id, uid`
err := r.pool.QueryRow(context.Background(), q, username, email, "own", "7Rp9WhF3PdrkhY1uZbXj8").Scan(&RetID, &RetUID)
In the DB schema public.clients.uid and client_uid are of the same type : character varying
Expected behavior
I expect to have the same type inference both times (varchar I presume)
Actual behavior
ERROR: inconsistent types deduced for parameter $4 at character 119 (SQLSTATE 42P08)
DETAIL: text versus character varying
Version
PostgreSQL 14.15 (Postgres.app) on aarch64-apple-darwin20.6.0, compiled by Apple clang version 12.0.5 (clang-1205.0.22.9), 64-bit
github.com/jackc/pgx/v5 v5.7.2
go version go1.23.3 darwin/amd64
Additional context
I've tried with a prepared statement in PG Admin and the same query works fine.
I found 2 solutions :
If I use WHERE uid = $5 LIMIT 1)) it works fine (I double the same argument)
If I use WHERE uid = $4::varchar LIMIT 1)) it works fine
In another similar insert query where I use twice the same $ argument it works fine. In this case it's an int64 (bigint in DB).
Thanks in advance for your help.
Cheers
The text was updated successfully, but these errors were encountered:
Describe the bug
I try to use twice the $4 argument but it doesn't work in this specific case
In the DB schema public.clients.uid and client_uid are of the same type : character varying
Expected behavior
I expect to have the same type inference both times (varchar I presume)
Actual behavior
ERROR: inconsistent types deduced for parameter $4 at character 119 (SQLSTATE 42P08)
DETAIL: text versus character varying
Version
PostgreSQL 14.15 (Postgres.app) on aarch64-apple-darwin20.6.0, compiled by Apple clang version 12.0.5 (clang-1205.0.22.9), 64-bit
github.com/jackc/pgx/v5 v5.7.2
go version go1.23.3 darwin/amd64
Additional context
I've tried with a prepared statement in PG Admin and the same query works fine.
I found 2 solutions :
In another similar insert query where I use twice the same $ argument it works fine. In this case it's an int64 (bigint in DB).
Thanks in advance for your help.
Cheers
The text was updated successfully, but these errors were encountered: