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
Hi,
I have a an error with the following function:
func ByOwnerIDs(owner user.ID, ids ...int64) ([]Form, error) { const query = ` select * from forms_data where owner_id = $1 and id in ($2);` rows, err := postgres.DB().Query(query, owner, pq.Int64Array(ids)) if err != nil { return nil, err } defer rows.Close() return formRowsToList(rows) }
Expected <*pq.Error | 0xc42033d9e0>: { Severity: "ERROR", Code: "22P02", Message: "invalid input syntax for integer: \"{354,355}\"", Detail: "", Hint: "", Position: "", InternalPosition: "", InternalQuery: "", Where: "", Schema: "", Table: "", Column: "", DataTypeName: "", Constraint: "", File: "int8.c", Line: "99", Routine: "scanint8", } to be nil
If I replace pq.Int64Array with pq.Array I still got the problem.
Also the request appears to be correct when I write it in an pg shell :
select * from forms_data where owner_id = 165 and id in (354,355);
Also I just did a pull from the master.
Thank you for your help and the great work.
The text was updated successfully, but these errors were encountered:
IN (...) is an SQL construct that takes more than one literal. Each placeholder/parameter in a query is a single literal.
IN (...)
You can use the ANY() array function to write equivalent SQL that works with a single array literal: id = ANY($2).
ANY()
id = ANY($2)
Sorry, something went wrong.
Thanks cbandy, it works great!
No branches or pull requests
Hi,
I have a an error with the following function:
If I replace pq.Int64Array with pq.Array I still got the problem.
Also the request appears to be correct when I write it in an pg shell :
Also I just did a pull from the master.
Thank you for your help and the great work.
The text was updated successfully, but these errors were encountered: