Closed rw closed 4 years ago
I tried using the example code below, but it seems to work differently with Vec<u8>
than with String: https://github.com/AlexPikalov/cdrs/blob/d28e153db23704af9a78443fff586fcba5ae0c92/tests/query_values.rs#L40-L43
hi @rw,
I guess there was a similar issue. Let me first try to find it. I'll try to get back soon.
@AlexPikalov Thanks! Anything I can do to help? Getting this batching working will significantly speed up our application, because we fetch thousands of objects from Cassandra.
Works fine for me. Some pseudo code:
#[test]
fn test_temp_test() {
let connection = setup_test_keyspace();
query(&connection, "drop TABLE if EXISTS v");
query(&connection, "CREATE TABLE IF NOT EXISTS v (key blob PRIMARY KEY)");
let val1 = "Val1";
let val2 = "Val2";
let insert = |v: &str| connection.query_with_values("insert into v(key) values (?)", query_values!(v)).unwrap();
insert(val1);
insert(val2);
let result = query_with_values(&connection, "SELECT * FROM v WHERE key IN ?", query_values!(vec![val1, val2]));
assert_eq!(2, result.get_body().unwrap().into_rows().unwrap().len());
}
can you provide a reproduction project with a test that fails? That makes it more easy to fix the problem, because the problem is nowhere described in the issue (I don't read there is 'maybe' a problem with the encoding, but no actual problem has been described.
I made a test case reproduction of what I think the encoding problem is: https://github.com/AlexPikalov/cdrs/issues/341
@Jasperav Thanks for the example code, but I'm using Vec<Vec<u8>>
, not Vec<String>
.
Fixed by the suggestion in #341
I have a vec of binary keys (
Vec<Vec<u8>>
), and I want to provide them as a query value in the following select statement:I think I'm getting tripped up on encoding with
query_values!
here. I know how to do the single-key case, by wrapping the key incdrs::types::value::Bytes::new(mykey)
. But, I don't understand how to do that with a Vec of bytes keys. One issue I've run into is that I can get the conversions to compile, but queries don't work as expected -- that's why I think I don't understand the encoding process.Edit:
Here's what does work, for a single key lookup:
Here's what I tried for a vec of keys, that compiles but I think produces a wrong encoding:
Here's my schema:
Thanks!
cc @AlexPikalov