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
In Cassandra, a Hashmap can be appended to/updated via the following CQL query:
UPDATE cycling.cyclist_teams SET teams = teams + {2009 : 'DSB Bank - Nederland bloeit'} WHERE id = 5b6962dd-3f90-4c93-8f61-eabfa4a803e2;
How would I go about doing this via the Rust API? Would it be:
session.query("UPDATE cycling.cyclist_teams SET teams = teams + {? : ?} WHERE id = 5b6962dd-3f90-4c93-8f61-eabfa4a803e2, (2009, 'DSB Bank - Nederland bloeit'));
or
hashmap.Insert(2009, 'DSB Bank - Nederland bloeit')
session.query("UPDATE cycling.cyclist_teams SET teams = teams + {? : ?} WHERE id = 5b6962dd-3f90-4c93-8f61-eabfa4a803e2, (hashmap,));
The text was updated successfully, but these errors were encountered:
WarrenN1
changed the title
Append to HashMap
Query Syntax: Appending to a HashMap
Jun 7, 2023
Each value in the tuple correspond to one bind marker (question mark) in the query string.
Your first example will work if you change the single quote marks to double quote marks (it's not a valid Rust syntax for string literals):
session.query("UPDATE cycling.cyclist_teams SET teams = teams + {? : ?} WHERE id = 5b6962dd-3f90-4c93-8f61-eabfa4a803e2",(2009,"DSB Bank - Nederland bloeit")).await?;
In the second example, instead of {? : ?} you should just use ? - because the hashmap you pass in is a single value:
letmut hashmap:HashMap<i32,&str> = HashMap::new();
hashmap.insert(2009,"DSB Bank - Nederland bloeit");
session.query("UPDATE cycling.cyclist_teams SET teams = teams + ? WHERE id = 5b6962dd-3f90-4c93-8f61-eabfa4a803e2",(&hashmap,)).await?;
Next time, in case of general questions, please post them on the ScyllaDB Forum or the #rust-driver channel on the ScyllaDB Users Slack. GitHub issues should be used for tracking bugs, feature requests, requests to update the documentation - generally, things that ultimately result in some pull requests being merged.
In Cassandra, a Hashmap can be appended to/updated via the following CQL query:
How would I go about doing this via the Rust API? Would it be:
or
The text was updated successfully, but these errors were encountered: