Skip to content

Commit 5705a1f

Browse files
committed
statements: expose API to unset (serial) consistency
This is required by the CPP Rust Driver, and also useful for Rust Driver direct users. See #1384 for details.
1 parent 454e64a commit 5705a1f

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

scylla/src/statement/batch.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ impl Batch {
6767
self.config.consistency = Some(c);
6868
}
6969

70+
/// Unsets the consistency overridden on this batch.
71+
/// This means that consistency will be derived from the execution profile
72+
/// (per-batch or, if absent, the default one).
73+
pub fn unset_consistency(&mut self) {
74+
self.config.consistency = None;
75+
}
76+
7077
/// Gets the consistency to be used when executing this batch if it is filled.
7178
/// If this is empty, the default_consistency of the session will be used.
7279
pub fn get_consistency(&self) -> Option<Consistency> {
@@ -79,6 +86,13 @@ impl Batch {
7986
self.config.serial_consistency = Some(sc);
8087
}
8188

89+
/// Unsets the serial consistency overridden on this batch.
90+
/// This means that serial consistency will be derived from the execution profile
91+
/// (per-batch or, if absent, the default one).
92+
pub fn unset_serial_consistency(&mut self) {
93+
self.config.serial_consistency = None;
94+
}
95+
8296
/// Gets the serial consistency to be used when executing this batch.
8397
/// (Ignored unless the batch is an LWT)
8498
pub fn get_serial_consistency(&self) -> Option<SerialConsistency> {

scylla/src/statement/prepared.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,13 @@ impl PreparedStatement {
298298
self.config.consistency = Some(c);
299299
}
300300

301+
/// Unsets the consistency overridden on this statement.
302+
/// This means that consistency will be derived from the execution profile
303+
/// (per-statement or, if absent, the default one).
304+
pub fn unset_consistency(&mut self) {
305+
self.config.consistency = None;
306+
}
307+
301308
/// Gets the consistency to be used when executing this prepared statement if it is filled.
302309
/// If this is empty, the default_consistency of the session will be used.
303310
pub fn get_consistency(&self) -> Option<Consistency> {
@@ -310,6 +317,13 @@ impl PreparedStatement {
310317
self.config.serial_consistency = Some(sc);
311318
}
312319

320+
/// Unsets the serial consistency overridden on this statement.
321+
/// This means that serial consistency will be derived from the execution profile
322+
/// (per-statement or, if absent, the default one).
323+
pub fn unset_serial_consistency(&mut self) {
324+
self.config.serial_consistency = None;
325+
}
326+
313327
/// Gets the serial consistency to be used when executing this statement.
314328
/// (Ignored unless the statement is an LWT)
315329
pub fn get_serial_consistency(&self) -> Option<SerialConsistency> {

scylla/src/statement/unprepared.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ impl Statement {
6060
self.config.consistency = Some(c);
6161
}
6262

63+
/// Unsets the consistency overridden on this statement.
64+
/// This means that consistency will be derived from the execution profile
65+
/// (per-statement or, if absent, the default one).
66+
pub fn unset_consistency(&mut self) {
67+
self.config.consistency = None;
68+
}
69+
6370
/// Gets the consistency to be used when executing this statement if it is filled.
6471
/// If this is empty, the default_consistency of the session will be used.
6572
pub fn get_consistency(&self) -> Option<Consistency> {
@@ -72,6 +79,13 @@ impl Statement {
7279
self.config.serial_consistency = Some(sc);
7380
}
7481

82+
/// Unsets the serial consistency overridden on this statement.
83+
/// This means that serial consistency will be derived from the execution profile
84+
/// (per-statement or, if absent, the default one).
85+
pub fn unset_serial_consistency(&mut self) {
86+
self.config.serial_consistency = None;
87+
}
88+
7589
/// Gets the serial consistency to be used when executing this statement.
7690
/// (Ignored unless the statement is an LWT)
7791
pub fn get_serial_consistency(&self) -> Option<SerialConsistency> {

0 commit comments

Comments
 (0)