Closed
Description
What I'd like to be able to do is something like this:
let categories = vec!["shoes", "socks"];
try!(tx.execute("
INSERT INTO categories (category)
VALUES $1",
&[&&categories[..]]
));
And I expected the SQL generated to be:
INSERT INTO categories (category)
VALUES ('shoes'), ('socks');
The code above compiles, but I get a panic on unwrapping:
Db(DbError {
severity: "ERROR",
code: SyntaxError,
message: "syntax error at or near \"$1\"",
detail: None, hint: None, position: Some(Normal(59)), where_: None, schema: None,
table: None, column: None, datatype: None, constraint: None, file: Some("scan.l"),
line: Some(1087), routine: Some("scanner_yyerror")
})
Which looks to me like the $1
wasn't substituted at all.
Is there a way to do this currently that I'm missing? If not, is this something that you'd want rust-postgres to support, or would it be better as a separate crate, something like activerecord-import?
Thanks!! ❤️
Metadata
Metadata
Assignees
Labels
No labels