Skip to content

Commit 5752af4

Browse files
authored
Merge pull request #1061 from wprzytula/paging-api-hardening
Query paging API: hardening, robustness, explicitness
2 parents 78286c3 + a1286de commit 5752af4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+1537
-983
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ let uri = "127.0.0.1:9042";
1919

2020
let session: Session = SessionBuilder::new().known_node(uri).build().await?;
2121

22-
let result = session.query("SELECT a, b, c FROM ks.t", &[]).await?;
22+
let result = session.query_unpaged("SELECT a, b, c FROM ks.t", &[]).await?;
2323
let mut iter = result.rows_typed::<(i32, i32, String)>()?;
2424
while let Some((a, b, c)) = iter.next().transpose()? {
2525
println!("a, b, c: {}, {}, {}", a, b, c);

docs/source/data-types/blob.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ use scylla::IntoTypedRows;
1313
// We can insert it by reference to not move the whole blob
1414
let to_insert: Vec<u8> = vec![1, 2, 3, 4, 5];
1515
session
16-
.query("INSERT INTO keyspace.table (a) VALUES(?)", (&to_insert,))
16+
.query_unpaged("INSERT INTO keyspace.table (a) VALUES(?)", (&to_insert,))
1717
.await?;
1818

1919
// Read blobs from the table
20-
let result = session.query("SELECT a FROM keyspace.table", &[]).await?;
20+
let result = session.query_unpaged("SELECT a FROM keyspace.table", &[]).await?;
2121
let mut iter = result.rows_typed::<(Vec<u8>,)>()?;
2222
while let Some((blob_value,)) = iter.next().transpose()? {
2323
println!("{:?}", blob_value);

docs/source/data-types/collections.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ use scylla::IntoTypedRows;
1313
// Insert a list of ints into the table
1414
let my_list: Vec<i32> = vec![1, 2, 3, 4, 5];
1515
session
16-
.query("INSERT INTO keyspace.table (a) VALUES(?)", (&my_list,))
16+
.query_unpaged("INSERT INTO keyspace.table (a) VALUES(?)", (&my_list,))
1717
.await?;
1818

1919
// Read a list of ints from the table
20-
let result = session.query("SELECT a FROM keyspace.table", &[]).await?;
20+
let result = session.query_unpaged("SELECT a FROM keyspace.table", &[]).await?;
2121
let mut iter = result.rows_typed::<(Vec<i32>,)>()?;
2222
while let Some((list_value,)) = iter.next().transpose()? {
2323
println!("{:?}", list_value);
@@ -39,11 +39,11 @@ use scylla::IntoTypedRows;
3939
// Insert a set of ints into the table
4040
let my_set: Vec<i32> = vec![1, 2, 3, 4, 5];
4141
session
42-
.query("INSERT INTO keyspace.table (a) VALUES(?)", (&my_set,))
42+
.query_unpaged("INSERT INTO keyspace.table (a) VALUES(?)", (&my_set,))
4343
.await?;
4444

4545
// Read a set of ints from the table
46-
let result = session.query("SELECT a FROM keyspace.table", &[]).await?;
46+
let result = session.query_unpaged("SELECT a FROM keyspace.table", &[]).await?;
4747
let mut iter = result.rows_typed::<(Vec<i32>,)>()?;
4848
while let Some((list_value,)) = iter.next().transpose()? {
4949
println!("{:?}", list_value);
@@ -63,11 +63,11 @@ use std::collections::HashSet;
6363
// Insert a set of ints into the table
6464
let my_set: HashSet<i32> = vec![1, 2, 3, 4, 5].into_iter().collect();
6565
session
66-
.query("INSERT INTO keyspace.table (a) VALUES(?)", (&my_set,))
66+
.query_unpaged("INSERT INTO keyspace.table (a) VALUES(?)", (&my_set,))
6767
.await?;
6868

6969
// Read a set of ints from the table
70-
let result = session.query("SELECT a FROM keyspace.table", &[]).await?;
70+
let result = session.query_unpaged("SELECT a FROM keyspace.table", &[]).await?;
7171
let mut iter = result.rows_typed::<(HashSet<i32>,)>()?;
7272
while let Some((list_value,)) = iter.next().transpose()? {
7373
println!("{:?}", list_value);
@@ -87,11 +87,11 @@ use std::collections::BTreeSet;
8787
// Insert a set of ints into the table
8888
let my_set: BTreeSet<i32> = vec![1, 2, 3, 4, 5].into_iter().collect();
8989
session
90-
.query("INSERT INTO keyspace.table (a) VALUES(?)", (&my_set,))
90+
.query_unpaged("INSERT INTO keyspace.table (a) VALUES(?)", (&my_set,))
9191
.await?;
9292

9393
// Read a set of ints from the table
94-
let result = session.query("SELECT a FROM keyspace.table", &[]).await?;
94+
let result = session.query_unpaged("SELECT a FROM keyspace.table", &[]).await?;
9595
let mut iter = result.rows_typed::<(BTreeSet<i32>,)>()?;
9696
while let Some((list_value,)) = iter.next().transpose()? {
9797
println!("{:?}", list_value);
@@ -116,11 +116,11 @@ let mut my_map: HashMap<String, i32> = HashMap::new();
116116
my_map.insert("abcd".to_string(), 16);
117117

118118
session
119-
.query("INSERT INTO keyspace.table (a) VALUES(?)", (&my_map,))
119+
.query_unpaged("INSERT INTO keyspace.table (a) VALUES(?)", (&my_map,))
120120
.await?;
121121

122122
// Read a map from the table
123-
let result = session.query("SELECT a FROM keyspace.table", &[]).await?;
123+
let result = session.query_unpaged("SELECT a FROM keyspace.table", &[]).await?;
124124
let mut iter = result.rows_typed::<(HashMap<String, i32>,)>()?;
125125
while let Some((map_value,)) = iter.next().transpose()? {
126126
println!("{:?}", map_value);
@@ -142,11 +142,11 @@ let mut my_map: BTreeMap<String, i32> = BTreeMap::new();
142142
my_map.insert("abcd".to_string(), 16);
143143

144144
session
145-
.query("INSERT INTO keyspace.table (a) VALUES(?)", (&my_map,))
145+
.query_unpaged("INSERT INTO keyspace.table (a) VALUES(?)", (&my_map,))
146146
.await?;
147147

148148
// Read a map from the table
149-
let result = session.query("SELECT a FROM keyspace.table", &[]).await?;
149+
let result = session.query_unpaged("SELECT a FROM keyspace.table", &[]).await?;
150150
let mut iter = result.rows_typed::<(BTreeMap<String, i32>,)>()?;
151151
while let Some((map_value,)) = iter.next().transpose()? {
152152
println!("{:?}", map_value);

docs/source/data-types/counter.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use scylla::IntoTypedRows;
1111
use scylla::frame::value::Counter;
1212

1313
// Read counter from the table
14-
let result = session.query("SELECT c FROM keyspace.table", &[]).await?;
14+
let result = session.query_unpaged("SELECT c FROM keyspace.table", &[]).await?;
1515
let mut iter = result.rows_typed::<(Counter,)>()?;
1616
while let Some((counter_value,)) = iter.next().transpose()? {
1717
let counter_int_value: i64 = counter_value.0;

docs/source/data-types/date.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ let to_insert = CqlDate((1 << 31) + 7);
2525

2626
// Insert date into the table
2727
session
28-
.query("INSERT INTO keyspace.table (a) VALUES(?)", (to_insert,))
28+
.query_unpaged("INSERT INTO keyspace.table (a) VALUES(?)", (to_insert,))
2929
.await?;
3030

3131
// Read raw Date from the table
3232
if let Some(rows) = session
33-
.query("SELECT a FROM keyspace.table", &[])
33+
.query_unpaged("SELECT a FROM keyspace.table", &[])
3434
.await?
3535
.rows
3636
{
@@ -63,11 +63,11 @@ let to_insert = NaiveDate::from_ymd_opt(2021, 3, 24).unwrap();
6363

6464
// Insert date into the table
6565
session
66-
.query("INSERT INTO keyspace.table (a) VALUES(?)", (to_insert,))
66+
.query_unpaged("INSERT INTO keyspace.table (a) VALUES(?)", (to_insert,))
6767
.await?;
6868

6969
// Read NaiveDate from the table
70-
let result = session.query("SELECT a FROM keyspace.table", &[]).await?;
70+
let result = session.query_unpaged("SELECT a FROM keyspace.table", &[]).await?;
7171
let mut iter = result.rows_typed::<(NaiveDate,)>()?;
7272
while let Some((date_value,)) = iter.next().transpose()? {
7373
println!("{:?}", date_value);
@@ -97,11 +97,11 @@ let to_insert = Date::from_calendar_date(2021, Month::March, 24).unwrap();
9797

9898
// Insert date into the table
9999
session
100-
.query("INSERT INTO keyspace.table (a) VALUES(?)", (to_insert,))
100+
.query_unpaged("INSERT INTO keyspace.table (a) VALUES(?)", (to_insert,))
101101
.await?;
102102

103103
// Read Date from the table
104-
let result = session.query("SELECT a FROM keyspace.table", &[]).await?;
104+
let result = session.query_unpaged("SELECT a FROM keyspace.table", &[]).await?;
105105
let mut iter = result.rows_typed::<(Date,)>()?;
106106
while let Some((date_value,)) = iter.next().transpose()? {
107107
println!("{:?}", date_value);

docs/source/data-types/decimal.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ use std::str::FromStr;
1818
let to_insert: CqlDecimal =
1919
CqlDecimal::from_signed_be_bytes_and_exponent(vec![0x01, 0xE2, 0x40], 3);
2020
session
21-
.query("INSERT INTO keyspace.table (a) VALUES(?)", (to_insert,))
21+
.query_unpaged("INSERT INTO keyspace.table (a) VALUES(?)", (to_insert,))
2222
.await?;
2323

2424
// Read a decimal from the table
25-
if let Some(rows) = session.query("SELECT a FROM keyspace.table", &[]).await?.rows {
25+
if let Some(rows) = session.query_unpaged("SELECT a FROM keyspace.table", &[]).await?.rows {
2626
for row in rows.into_typed::<(CqlDecimal,)>() {
2727
let (decimal_value,): (CqlDecimal,) = row?;
2828
}
@@ -48,11 +48,11 @@ use std::str::FromStr;
4848
// Insert a decimal into the table
4949
let to_insert: BigDecimal = BigDecimal::from_str("12345.0")?;
5050
session
51-
.query("INSERT INTO keyspace.table (a) VALUES(?)", (to_insert,))
51+
.query_unpaged("INSERT INTO keyspace.table (a) VALUES(?)", (to_insert,))
5252
.await?;
5353

5454
// Read a decimal from the table
55-
let result = session.query("SELECT a FROM keyspace.table", &[]).await?;
55+
let result = session.query_unpaged("SELECT a FROM keyspace.table", &[]).await?;
5656
let mut iter = result.rows_typed::<(BigDecimal,)>()?;
5757
while let Some((decimal_value,)) = iter.next().transpose()? {
5858
println!("{:?}", decimal_value);

docs/source/data-types/duration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ use scylla::frame::value::CqlDuration;
1212
// Insert some duration into the table
1313
let to_insert: CqlDuration = CqlDuration { months: 1, days: 2, nanoseconds: 3 };
1414
session
15-
.query("INSERT INTO keyspace.table (a) VALUES(?)", (to_insert,))
15+
.query_unpaged("INSERT INTO keyspace.table (a) VALUES(?)", (to_insert,))
1616
.await?;
1717

1818
// Read duration from the table
19-
let result = session.query("SELECT a FROM keyspace.table", &[]).await?;
19+
let result = session.query_unpaged("SELECT a FROM keyspace.table", &[]).await?;
2020
let mut iter = result.rows_typed::<(CqlDuration,)>()?;
2121
while let Some((duration_value,)) = iter.next().transpose()? {
2222
println!("{:?}", duration_value);

docs/source/data-types/inet.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ use std::net::{IpAddr, Ipv4Addr};
1212
// Insert some ip address into the table
1313
let to_insert: IpAddr = IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1));;
1414
session
15-
.query("INSERT INTO keyspace.table (a) VALUES(?)", (to_insert,))
15+
.query_unpaged("INSERT INTO keyspace.table (a) VALUES(?)", (to_insert,))
1616
.await?;
1717

1818
// Read inet from the table
19-
let result = session.query("SELECT a FROM keyspace.table", &[]).await?;
19+
let result = session.query_unpaged("SELECT a FROM keyspace.table", &[]).await?;
2020
let mut iter = result.rows_typed::<(IpAddr,)>()?;
2121
while let Some((inet_value,)) = iter.next().transpose()? {
2222
println!("{:?}", inet_value);

docs/source/data-types/primitive.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ use scylla::IntoTypedRows;
1414
// Insert a bool into the table
1515
let to_insert: bool = true;
1616
session
17-
.query("INSERT INTO keyspace.table (a) VALUES(?)", (to_insert,))
17+
.query_unpaged("INSERT INTO keyspace.table (a) VALUES(?)", (to_insert,))
1818
.await?;
1919

2020
// Read a bool from the table
21-
let result = session.query("SELECT a FROM keyspace.table", &[]).await?;
21+
let result = session.query_unpaged("SELECT a FROM keyspace.table", &[]).await?;
2222
let mut iter = result.rows_typed::<(bool,)>()?;
2323
while let Some((bool_value,)) = iter.next().transpose()? {
2424
println!("{}", bool_value);
@@ -41,11 +41,11 @@ use scylla::IntoTypedRows;
4141
// Insert a tinyint into the table
4242
let to_insert: i8 = 123;
4343
session
44-
.query("INSERT INTO keyspace.table (a) VALUES(?)", (to_insert,))
44+
.query_unpaged("INSERT INTO keyspace.table (a) VALUES(?)", (to_insert,))
4545
.await?;
4646

4747
// Read a tinyint from the table
48-
let result = session.query("SELECT a FROM keyspace.table", &[]).await?;
48+
let result = session.query_unpaged("SELECT a FROM keyspace.table", &[]).await?;
4949
let mut iter = result.rows_typed::<(i8,)>()?;
5050
while let Some((tinyint_value,)) = iter.next().transpose()? {
5151
println!("{:?}", tinyint_value);
@@ -68,11 +68,11 @@ use scylla::IntoTypedRows;
6868
// Insert a smallint into the table
6969
let to_insert: i16 = 12345;
7070
session
71-
.query("INSERT INTO keyspace.table (a) VALUES(?)", (to_insert,))
71+
.query_unpaged("INSERT INTO keyspace.table (a) VALUES(?)", (to_insert,))
7272
.await?;
7373

7474
// Read a smallint from the table
75-
let result = session.query("SELECT a FROM keyspace.table", &[]).await?;
75+
let result = session.query_unpaged("SELECT a FROM keyspace.table", &[]).await?;
7676
let mut iter = result.rows_typed::<(i16,)>()?;
7777
while let Some((smallint_value,)) = iter.next().transpose()? {
7878
println!("{}", smallint_value);
@@ -95,11 +95,11 @@ use scylla::IntoTypedRows;
9595
// Insert an int into the table
9696
let to_insert: i32 = 12345;
9797
session
98-
.query("INSERT INTO keyspace.table (a) VALUES(?)", (to_insert,))
98+
.query_unpaged("INSERT INTO keyspace.table (a) VALUES(?)", (to_insert,))
9999
.await?;
100100

101101
// Read an int from the table
102-
let result = session.query("SELECT a FROM keyspace.table", &[]).await?;
102+
let result = session.query_unpaged("SELECT a FROM keyspace.table", &[]).await?;
103103
let mut iter = result.rows_typed::<(i32,)>()?;
104104
while let Some((int_value,)) = iter.next().transpose()? {
105105
println!("{}", int_value);
@@ -122,11 +122,11 @@ use scylla::IntoTypedRows;
122122
// Insert a bigint into the table
123123
let to_insert: i64 = 12345;
124124
session
125-
.query("INSERT INTO keyspace.table (a) VALUES(?)", (to_insert,))
125+
.query_unpaged("INSERT INTO keyspace.table (a) VALUES(?)", (to_insert,))
126126
.await?;
127127

128128
// Read a bigint from the table
129-
let result = session.query("SELECT a FROM keyspace.table", &[]).await?;
129+
let result = session.query_unpaged("SELECT a FROM keyspace.table", &[]).await?;
130130
let mut iter = result.rows_typed::<(i64,)>()?;
131131
while let Some((bigint_value,)) = iter.next().transpose()? {
132132
println!("{:?}", bigint_value);
@@ -149,11 +149,11 @@ use scylla::IntoTypedRows;
149149
// Insert a float into the table
150150
let to_insert: f32 = 123.0;
151151
session
152-
.query("INSERT INTO keyspace.table (a) VALUES(?)", (to_insert,))
152+
.query_unpaged("INSERT INTO keyspace.table (a) VALUES(?)", (to_insert,))
153153
.await?;
154154

155155
// Read a float from the table
156-
let result = session.query("SELECT a FROM keyspace.table", &[]).await?;
156+
let result = session.query_unpaged("SELECT a FROM keyspace.table", &[]).await?;
157157
let mut iter = result.rows_typed::<(f32,)>()?;
158158
while let Some((float_value,)) = iter.next().transpose()? {
159159
println!("{:?}", float_value);
@@ -176,11 +176,11 @@ use scylla::IntoTypedRows;
176176
// Insert a double into the table
177177
let to_insert: f64 = 12345.0;
178178
session
179-
.query("INSERT INTO keyspace.table (a) VALUES(?)", (to_insert,))
179+
.query_unpaged("INSERT INTO keyspace.table (a) VALUES(?)", (to_insert,))
180180
.await?;
181181

182182
// Read a double from the table
183-
let result = session.query("SELECT a FROM keyspace.table", &[]).await?;
183+
let result = session.query_unpaged("SELECT a FROM keyspace.table", &[]).await?;
184184
let mut iter = result.rows_typed::<(f64,)>()?;
185185
while let Some((double_value,)) = iter.next().transpose()? {
186186
println!("{:?}", double_value);

docs/source/data-types/text.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ use scylla::IntoTypedRows;
1111
// Insert some text into the table as a &str
1212
let to_insert_str: &str = "abcdef";
1313
session
14-
.query("INSERT INTO keyspace.table (a) VALUES(?)", (to_insert_str,))
14+
.query_unpaged("INSERT INTO keyspace.table (a) VALUES(?)", (to_insert_str,))
1515
.await?;
1616

1717
// Insert some text into the table as a String
1818
let to_insert_string: String = "abcdef".to_string();
1919
session
20-
.query("INSERT INTO keyspace.table (a) VALUES(?)", (to_insert_string,))
20+
.query_unpaged("INSERT INTO keyspace.table (a) VALUES(?)", (to_insert_string,))
2121
.await?;
2222

2323
// Read ascii/text/varchar from the table
24-
let result = session.query("SELECT a FROM keyspace.table", &[]).await?;
24+
let result = session.query_unpaged("SELECT a FROM keyspace.table", &[]).await?;
2525
let mut iter = result.rows_typed::<(String,)>()?;
2626
while let Some((text_value,)) = iter.next().transpose()? {
2727
println!("{}", text_value);

0 commit comments

Comments
 (0)