Skip to content

Commit

Permalink
chore(sqlite): add repro for #1419
Browse files Browse the repository at this point in the history
  • Loading branch information
abonander committed Sep 22, 2021
1 parent 593364f commit 7ff6620
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 deletions.
15 changes: 5 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions tests/sqlite/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,3 +567,26 @@ async fn concurrent_resets_dont_segfault() {

sqlx_rt::sleep(Duration::from_millis(1)).await;
}

// https://github.com/launchbadge/sqlx/issues/1419
// note: this passes before and after the fix; you need to run it with `--nocapture`
// to see the panic from the worker thread, which doesn't happen after the fix
#[sqlx_macros::test]
async fn row_dropped_after_connection_doesnt_panic() {
let mut conn = SqliteConnection::connect(":memory:").await.unwrap();

let books = sqlx::query("SELECT 'hello' AS title")
.fetch_all(&mut conn)
.await
.unwrap();

for book in &books {
// force the row to be inflated
let _title: String = book.get("title");
}

// hold `books` past the lifetime of `conn`
drop(conn);
sqlx_rt::sleep(std::time::Duration::from_secs(1)).await;
drop(books);
}

0 comments on commit 7ff6620

Please sign in to comment.