Skip to content

Commit 5d25f43

Browse files
committed
chore(sqlite): add repro for #1419
1 parent 593364f commit 5d25f43

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

tests/sqlite/sqlite.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,3 +567,37 @@ async fn concurrent_resets_dont_segfault() {
567567

568568
sqlx_rt::sleep(Duration::from_millis(1)).await;
569569
}
570+
571+
// https://github.com/launchbadge/sqlx/issues/1419
572+
#[sqlx_macros::test]
573+
async fn row_dropped_after_connection_doesnt_panic() {
574+
let mut conn = SqliteConnection::connect(":memory:").await.unwrap();
575+
576+
conn.execute(
577+
"CREATE TABLE IF NOT EXISTS books
578+
(
579+
title TEXT NOT NULL,
580+
created_at INTEGER DEFAULT (cast(strftime('%s','now') as int)),
581+
updated_at INTEGER DEFAULT (cast(strftime('%s','now') as int))
582+
);
583+
584+
INSERT INTO books(title) VALUES('hello');
585+
INSERT INTO books(title) VALUES('test');
586+
INSERT INTO books(title) VALUES('example');
587+
INSERT INTO books(title) VALUES('stuff');
588+
INSERT INTO books(title) VALUES('here');
589+
INSERT INTO books(title) VALUES('there');
590+
INSERT INTO books(title) VALUES('everywhere');",
591+
)
592+
.await
593+
.unwrap();
594+
595+
let _books = sqlx::query("SELECT * FROM books")
596+
.fetch_all(&mut *conn3)
597+
.await
598+
.unwrap();
599+
600+
// hold `_books` past the lifetime of `conn`
601+
drop(conn);
602+
drop(_books);
603+
}

0 commit comments

Comments
 (0)