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 5d25f43
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/sqlite/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,3 +567,37 @@ async fn concurrent_resets_dont_segfault() {

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

// https://github.com/launchbadge/sqlx/issues/1419
#[sqlx_macros::test]
async fn row_dropped_after_connection_doesnt_panic() {
let mut conn = SqliteConnection::connect(":memory:").await.unwrap();

conn.execute(
"CREATE TABLE IF NOT EXISTS books
(
title TEXT NOT NULL,
created_at INTEGER DEFAULT (cast(strftime('%s','now') as int)),
updated_at INTEGER DEFAULT (cast(strftime('%s','now') as int))
);
INSERT INTO books(title) VALUES('hello');
INSERT INTO books(title) VALUES('test');
INSERT INTO books(title) VALUES('example');
INSERT INTO books(title) VALUES('stuff');
INSERT INTO books(title) VALUES('here');
INSERT INTO books(title) VALUES('there');
INSERT INTO books(title) VALUES('everywhere');",
)
.await
.unwrap();

let _books = sqlx::query("SELECT * FROM books")
.fetch_all(&mut *conn3)
.await
.unwrap();

// hold `_books` past the lifetime of `conn`
drop(conn);
drop(_books);
}

0 comments on commit 5d25f43

Please sign in to comment.