Skip to content

Commit 22b7bd7

Browse files
committed
docs/batch: clarify the wording around what can be put in batches
This commit clarifies the doc page about batches and performs two changes: - Occurrences of "query" have been changed to "statement". Batches do not support putting queries into them, only data-modifying statements. The driver documentation interchangeably uses "query" and "statement" which is not really correct but is especially confusing in this page. - The first paragraph now also lists `DELETE` as a possible operation for batch in addition to `INSERT` and `UPDATE`. As a bonus, a single backslash that was unnecessarily rendered at the end of a line was removed.
1 parent b8711d1 commit 22b7bd7

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

docs/source/queries/batch.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Batch statement
22

3-
A batch statement allows to run many queries at once.\
4-
These queries can be [simple queries](simple.md) or [prepared queries](prepared.md).\
5-
Only queries like `INSERT` or `UPDATE` can be in a batch.
3+
A batch statement allows to execute many data-modifying statements at once.\
4+
These statements can be [simple](simple.md) or [prepared](prepared.md).\
5+
Only `INSERT`, `UPDATE` and `DELETE` statements are allowed.
66

77
```rust
88
# extern crate scylla;
@@ -16,20 +16,20 @@ use scylla::prepared_statement::PreparedStatement;
1616
// Create a batch statement
1717
let mut batch: Batch = Default::default();
1818

19-
// Add a simple query to the batch using its text
19+
// Add a simple statement to the batch using its text
2020
batch.append_statement("INSERT INTO ks.tab(a, b) VALUES(?, ?)");
2121

22-
// Add a simple query created manually to the batch
22+
// Add a simple statement created manually to the batch
2323
let simple: Query = Query::new("INSERT INTO ks.tab (a, b) VALUES(3, 4)");
2424
batch.append_statement(simple);
2525

26-
// Add a prepared query to the batch
26+
// Add a prepared statement to the batch
2727
let prepared: PreparedStatement = session
2828
.prepare("INSERT INTO ks.tab (a, b) VALUES(?, 6)")
2929
.await?;
3030
batch.append_statement(prepared);
3131

32-
// Specify bound values to use with each query
32+
// Specify bound values to use with each statement
3333
let batch_values = ((1_i32, 2_i32),
3434
(),
3535
(5_i32,));
@@ -41,7 +41,7 @@ session.batch(&batch, batch_values).await?;
4141
```
4242

4343
### Preparing a batch
44-
Instead of preparing each query individually, it's possible to prepare a whole batch at once:
44+
Instead of preparing each statement individually, it's possible to prepare a whole batch at once:
4545

4646
```rust
4747
# extern crate scylla;
@@ -58,7 +58,7 @@ batch.append_statement("INSERT INTO ks.simple_unprepared2 VALUES(?, ?)");
5858
// Prepare all statements in the batch at once
5959
let prepared_batch: Batch = session.prepare_batch(&batch).await?;
6060

61-
// Specify bound values to use with each query
61+
// Specify bound values to use with each statement
6262
let batch_values = ((1_i32, 2_i32),
6363
(3_i32, 4_i32));
6464

@@ -99,10 +99,10 @@ for more options
9999
Batch takes a tuple of values specified just like in [simple](simple.md) or [prepared](prepared.md) queries.
100100

101101
Length of batch values must be equal to the number of statements in a batch.\
102-
Each query must have its values specified, even if they are empty.
102+
Each statement must have its values specified, even if they are empty.
103103

104104
Values passed to `Session::batch` must implement the trait `BatchValues`.\
105-
By default this includes tuples `()` and slices `&[]` of tuples and slices which implement `ValueList`.\
105+
By default this includes tuples `()` and slices `&[]` of tuples and slices which implement `ValueList`.
106106

107107
Example:
108108
```rust
@@ -114,26 +114,26 @@ use scylla::batch::Batch;
114114

115115
let mut batch: Batch = Default::default();
116116

117-
// A query with two bound values
117+
// A statement with two bound values
118118
batch.append_statement("INSERT INTO ks.tab(a, b) VALUES(?, ?)");
119119

120-
// A query with one bound value
120+
// A statement with one bound value
121121
batch.append_statement("INSERT INTO ks.tab(a, b) VALUES(3, ?)");
122122

123-
// A query with no bound values
123+
// A statement with no bound values
124124
batch.append_statement("INSERT INTO ks.tab(a, b) VALUES(5, 6)");
125125

126-
// Batch values is a tuple of 3 tuples containing values for each query
127-
let batch_values = ((1_i32, 2_i32), // Tuple with two values for the first query
128-
(4_i32,), // Tuple with one value for the second query
129-
()); // Empty tuple/unit for the third query
126+
// Batch values is a tuple of 3 tuples containing values for each statement
127+
let batch_values = ((1_i32, 2_i32), // Tuple with two values for the first statement
128+
(4_i32,), // Tuple with one value for the second statement
129+
()); // Empty tuple/unit for the third statement
130130

131131
// Run the batch
132132
session.batch(&batch, batch_values).await?;
133133
# Ok(())
134134
# }
135135
```
136-
For more information about sending values in a query see [Query values](values.md)
136+
For more information about sending values in a statement see [Query values](values.md)
137137

138138

139139
### Performance

0 commit comments

Comments
 (0)