Skip to content

Commit

Permalink
add failing test cases for update/delete return into
Browse files Browse the repository at this point in the history
  • Loading branch information
tyrelr committed Jul 15, 2022
1 parent 9534de3 commit 4846168
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tests/sqlite/describe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,47 @@ async fn it_describes_insert_with_returning() -> anyhow::Result<()> {

assert_eq!(d.columns().len(), 4);
assert_eq!(d.column(0).type_info().name(), "INTEGER");
assert_eq!(d.nullable(0), Some(false));
assert_eq!(d.column(1).type_info().name(), "TEXT");
assert_eq!(d.nullable(1), Some(false));

let d = conn
.describe("INSERT INTO accounts (name, is_active) VALUES ('a', true) RETURNING id")
.await?;

assert_eq!(d.columns().len(), 1);
assert_eq!(d.column(0).type_info().name(), "INTEGER");
assert_eq!(d.nullable(0), Some(false));

Ok(())
}

#[sqlx_macros::test]
async fn it_describes_update_with_returning() -> anyhow::Result<()> {
let mut conn = new::<Sqlite>().await?;

let d = conn
.describe("UPDATE accounts SET is_active=true WHERE name=?1 RETURNING id")
.await?;

assert_eq!(d.columns().len(), 1);
assert_eq!(d.column(0).type_info().name(), "INTEGER");
assert_eq!(d.nullable(0), Some(false));

Ok(())
}

#[sqlx_macros::test]
async fn it_describes_delete_with_returning() -> anyhow::Result<()> {
let mut conn = new::<Sqlite>().await?;

let d = conn
.describe("DELETE FROM accounts WHERE name=?1 RETURNING id")
.await?;

assert_eq!(d.columns().len(), 1);
assert_eq!(d.column(0).type_info().name(), "INTEGER");
assert_eq!(d.nullable(0), Some(false));

Ok(())
}
Expand Down

0 comments on commit 4846168

Please sign in to comment.