Skip to content

[Question] How should I bind a Vec as a parameter of IN ? #1261

New issue

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

Closed
TENX-S opened this issue May 30, 2021 · 3 comments
Closed

[Question] How should I bind a Vec as a parameter of IN ? #1261

TENX-S opened this issue May 30, 2021 · 3 comments

Comments

@TENX-S
Copy link

TENX-S commented May 30, 2021

Table:

CREATE TABLE IF NOT EXISTS posts (
    id                  BIGSERIAL PRIMARY KEY,
    title               TEXT NOT NULL
);

The rust part

let title = vec!["A", "B"];
let posts = sqlx::query(r#"
    SELECT * FROM posts
    WHERE title NOT IN ($1);
"#).bind(title).map( || {...}).fetch_all(&db_pool).await?;

The error output:

Database(PgDatabaseError { severity: Error, code: "42883", message: "operator does not exist: text <> text[]", detail: None, hint:
Some("No operator matches the given name and argument type(s). You might need to add explicit type casts."), position: 
Some(Original(46)), where: None, schema: None, table: None, column: None, data_type: None, constraint: None, file: 
Some("parse_oper.c"), line: Some(721), routine: Some("op_error") })', src/grpc/command.rs:111:14,

How should I fix it ? Thank you !

@TENX-S
Copy link
Author

TENX-S commented May 30, 2021

Close this as a duplicate of #875

@TENX-S TENX-S closed this as completed May 30, 2021
@Matrix-Zhang
Copy link

Close this as a duplicate of #875

how to fix ?

@abonander
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants