Closed mgrazianoc closed 9 months ago
The following code tries to get the current tables available in the database, before deciding whether it should download it from elsewhere.
let mut table_exists = false; let table_name = String::from("test"); let mut stmt = conn.prepare("SHOW TABLES;")?; let _ = stmt.query_map([], |row| { let t: String = row.get("name")?; if t == table_name { table_exists = true; } Ok(()) })?;
But, the query_map call never iterates, the system continues to download the table, and it raises that the table test already exists.
query_map
test
I've tested these behaviors on duckdb 0.9.0, 0.9.2 and 0.10.0.
0.9.0
0.9.2
0.10.0
I think the iterator is lazy, try to consume the result of iterator with collect.
Yep, it was that, thanks
The following code tries to get the current tables available in the database, before deciding whether it should download it from elsewhere.
But, the
query_map
call never iterates, the system continues to download the table, and it raises that the tabletest
already exists.I've tested these behaviors on duckdb
0.9.0
,0.9.2
and0.10.0
.