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
#[tokio::test]
async fn it_writes_then_reads_count() {
let client = prepare("it_writes_then_reads_count").await;
#[derive(Debug, Row, Serialize, Deserialize)]
struct MyRow {
no: u32,
num: u32
}
#[derive(Debug, Row, Serialize, Deserialize)]
struct MyRowResult {
no: u32,
result: u32
}
// Create a table.
client
.query(
"
CREATE TABLE some(no UInt32, num UInt32)
ENGINE = MergeTree
ORDER BY no
",
)
.execute()
.await
.expect("cannot create a table");
// Write to the table.
let mut insert = client.insert("some").expect("cannot insert");
for i in 0..1000 {
insert
.write(&MyRow { no: i, num: i })
.await
.expect("cannot write()");
insert
.write(&MyRow { no: i, num: i+1 })
.await
.expect("cannot write()");
}
insert.end().await.expect("cannot end()");
// Read from the table.
let mut cursor = client
.query("SELECT no, count(*) FROM some WHERE no BETWEEN ? AND ? GROUP BY no ORDER BY no")
.bind(500)
.bind(504)
.fetch::<MyRowResult>()
.expect("cannot fetch");
let mut i = 500;
while let Some(row) = cursor.next().await.expect("cannot next()") {
dbg!(&row);
assert_eq!(row.no, i);
assert_eq!(row.result, 2);
i += 1;
}
}
The same with : count(*) as result
The text was updated successfully, but these errors were encountered:
Thus, using u64 (or any type that deserializes from it) for the result's type fixes your problem.
I don't like such silent errors and I'm going to move to RowBinaryWithNamesAndTypes in #10, because that format provides information about types of columns, that can be useful for conversions. However, even in this case, I think u64 -> u32 should be prohibited and lead to deserialization errors. Thus, I'm closing the issue.
The second row must be:
Test:
The same with :
count(*) as result
The text was updated successfully, but these errors were encountered: