Skip to content

Commit 1d91d91

Browse files
committed
Update docs
1 parent 97e7c6a commit 1d91d91

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

src/queryable/query_result.rs

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,34 @@ impl ResultSetMeta {
4141

4242
/// Result of a query or statement execution.
4343
///
44-
/// Represents an asynchronous query result, that may not be fully consumed. Note,
45-
/// that unconsumed query results are dropped implicitly when corresponding connection
46-
/// is dropped or queried.
44+
/// Represents an asynchronous query result, that may not be fully consumed.
45+
///
46+
/// # Note
47+
///
48+
/// Unconsumed query results are dropped implicitly when corresponding connection
49+
/// is dropped or queried. Also note, that in this case all remaining errors will be
50+
/// emitted to the caller:
51+
///
52+
/// ```rust
53+
/// # use mysql_async::test_misc::get_opts;
54+
/// # #[tokio::main]
55+
/// # async fn main() -> mysql_async::Result<()> {
56+
/// use mysql_async::*;
57+
/// use mysql_async::prelude::*;
58+
/// let mut conn = Conn::new(get_opts()).await?;
59+
///
60+
/// // second result set will contain an error,
61+
/// // but the first result set is ok, so this line will pass
62+
/// conn.query_iter("DO 1; BLABLA;").await?;
63+
/// // `QueryResult` was dropped withot being consumed
64+
///
65+
/// // driver must cleanup any unconsumed result to perform another query on `conn`,
66+
/// // so this operation will be performed implicitly, but the unconsumed result
67+
/// // contains an error claiming about 'BLABLA', so this error will be emitted here:
68+
/// assert!(conn.query_iter("DO 1").await.unwrap_err().to_string().contains("BLABLA"));
69+
///
70+
/// # conn.disconnect().await }
71+
/// ```
4772
#[derive(Debug)]
4873
pub struct QueryResult<'a, 't: 'a, P> {
4974
conn: Connection<'a, 't>,

0 commit comments

Comments
 (0)