Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
fix test
  • Loading branch information
0xdeafbeef committed Feb 23, 2023
1 parent ce88ca3 commit 4166e9f
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions tests/postgres/derives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,20 +378,20 @@ SELECT $1 = ROW('fuzzy dice', 42, 199)::inventory_item, $1
#[sqlx_macros::test]
async fn test_new_type() {
struct NewType(i32);
let conn = new::<Postgres>().await.unwrap();
conn.execute("CREATE TABLE new_type (id INTEGER)")
.await
.unwrap();

conn.execute("INSERT INTO new_type (id) VALUES (1)")
.await
.unwrap();
impl From<i32> for NewType {
fn from(value: i32) -> Self {
NewType(value)
}
}

let conn = new::<Postgres>().await.unwrap();

struct NewTypeRow {
id: NewType,
}

let res = sqlx::query_as!(NewTypeRow, "SELECT id FROM new_type")
let res = sqlx::query_as!(NewTypeRow, "SELECT 1 as id")
.fetch_one(&conn)
.await
.unwrap();
Expand All @@ -401,17 +401,12 @@ async fn test_new_type() {
id: i32,
}

let res = sqlx::query_as!(NormalRow, "SELECT id FROM new_type")
let res = sqlx::query_as!(NormalRow, "SELECT 1 as id")
.fetch_one(&conn)
.await
.unwrap();

assert_eq!(res.id, 1);

sqlx::query!("DROP TABLE new_type")
.execute(&conn)
.await
.unwrap();
}

#[cfg(feature = "macros")]
Expand Down

0 comments on commit 4166e9f

Please sign in to comment.