-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
result stream stops after the first decoding error #1884
Comments
Here is a small reproduction with sqlite : use futures::stream::StreamExt;
use sqlx::{sqlite::SqliteConnection, Connection};
#[derive(Debug, sqlx::FromRow, PartialEq)]
struct MyType(u32);
#[tokio::main]
async fn main() {
let mut conn = SqliteConnection::connect("sqlite::memory:").await.unwrap();
let rows: Vec<Option<MyType>> =
sqlx::query_as("SELECT 1 UNION ALL SELECT 'x' UNION ALL SELECT 2")
.fetch(&mut conn)
.map(|x| x.ok())
.collect()
.await;
assert_eq!(rows, vec![Some(MyType(1)), None, Some(MyType(2))]);
} The result is assertion failed: |
lovasoa
added a commit
to sqlpage/sqlx-oldapi
that referenced
this issue
May 31, 2022
Fixes launchbadge#1884 When a single row cannot be converted to the target type of query_as, it should not prevent the library user from accessing the other rows Otherwise, the user cannot access all query results in query_as.
abonander
pushed a commit
that referenced
this issue
Jun 2, 2022
* query_as: don't stop stream after decoding error Fixes #1884 When a single row cannot be converted to the target type of query_as, it should not prevent the library user from accessing the other rows Otherwise, the user cannot access all query results in query_as. * use union in tests to maximize db compatibility
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
QueryAs::fetch
returns a stream ofResult<MyType, Error>
. So, I would expect that a single error for a single row in the results would result in a stream that contains manyOk(MyType)
and a singleErr
. However, it does not seem to be the case. The resulting stream contains Ok(MyType) for all the rows before the error, then anErr
, and then it stops, without returning the next results.The text was updated successfully, but these errors were encountered: