mirror of
https://github.com/launchbadge/sqlx.git
synced 2026-03-19 08:39:44 +00:00
Feature: Add exclusion violation error kind (#3918)
* feat: add exclusion violation error kind * chore: add test for exclusion error kind
This commit is contained in:
@@ -75,6 +75,28 @@ async fn it_fails_with_check_violation() -> anyhow::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[sqlx_macros::test]
|
||||
async fn it_fails_with_exclude_violation() -> anyhow::Result<()> {
|
||||
let mut conn = new::<Postgres>().await?;
|
||||
let mut tx = conn.begin().await?;
|
||||
|
||||
sqlx::query("INSERT INTO circles VALUES (circle('(0,0)'::point, 5.0));")
|
||||
.execute(&mut *tx)
|
||||
.await?;
|
||||
|
||||
let res: Result<_, sqlx::Error> =
|
||||
sqlx::query("INSERT INTO circles VALUES (circle('(0,2.0)'::point, 2.0));")
|
||||
.execute(&mut *tx)
|
||||
.await;
|
||||
let err = res.unwrap_err();
|
||||
|
||||
let err = err.into_database_error().unwrap();
|
||||
|
||||
assert_eq!(err.kind(), ErrorKind::ExclusionViolation);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[sqlx_macros::test]
|
||||
async fn it_fails_with_begin_failed() -> anyhow::Result<()> {
|
||||
let mut conn = new::<Postgres>().await?;
|
||||
|
||||
@@ -63,3 +63,8 @@ CREATE SCHEMA IF NOT EXISTS foo;
|
||||
CREATE TYPE foo."Foo" as ENUM ('Bar', 'Baz');
|
||||
|
||||
CREATE TABLE mytable(f HSTORE);
|
||||
|
||||
CREATE TABLE circles (
|
||||
c circle,
|
||||
EXCLUDE USING gist (c WITH &&)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user