Skip to content

Commit 7959d9e

Browse files
committed
progress
1 parent 81b811c commit 7959d9e

File tree

4 files changed

+33
-23
lines changed

4 files changed

+33
-23
lines changed

crates/pgls_splinter/TODO.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

crates/pgls_splinter/src/query.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,17 @@ pub struct SplinterQueryResult {
3939
}
4040

4141
pub async fn load_splinter_results(pool: &PgPool) -> Result<Vec<SplinterQueryResult>, sqlx::Error> {
42-
let mut tx = pool.begin().await?;
42+
let mut conn = pool.acquire().await?;
4343

4444
// this is done by the splinter.sql file normally, but we remove it so that sqlx can work with
4545
// the file properly.
4646
sqlx::query("set local search_path = ''")
47-
.execute(&mut *tx)
47+
.execute(&mut *conn)
4848
.await?;
4949

5050
let results = sqlx::query_file_as!(SplinterQueryResult, "vendor/splinter.sql")
51-
.fetch_all(&mut *tx)
51+
.fetch_all(&mut *conn)
5252
.await?;
5353

54-
tx.commit().await?;
55-
5654
Ok(results)
5755
}

crates/pgls_splinter/tests/diagnostics.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,6 @@ struct TestSetup<'a> {
5151

5252
impl TestSetup<'_> {
5353
async fn test(self) {
54-
// Create Supabase-specific roles that splinter expects
55-
for role in ["anon", "authenticated", "service_role"] {
56-
let result = sqlx::query(&format!("CREATE ROLE {role} NOLOGIN"))
57-
.execute(self.test_db)
58-
.await;
59-
60-
// Ignore duplicate role errors
61-
if let Err(sqlx::Error::Database(db_err)) = &result {
62-
let code = db_err.code();
63-
if code.as_deref() != Some("23505") && code.as_deref() != Some("42710") {
64-
result.expect("Failed to create Supabase roles");
65-
}
66-
}
67-
}
68-
6954
// Run setup SQL
7055
sqlx::raw_sql(self.setup)
7156
.execute(self.test_db)

crates/pgls_test_utils/testdb_migrations/0001_setup-roles.sql

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,40 @@ end;
2121

2222
begin
2323
create role test_nologin;
24-
exception
24+
exception
25+
when duplicate_object then
26+
null;
27+
when unique_violation then
28+
null;
29+
end;
30+
31+
-- Supabase roles required for splinter tests
32+
begin
33+
create role anon nologin;
34+
exception
35+
when duplicate_object then
36+
null;
37+
when unique_violation then
38+
null;
39+
end;
40+
41+
begin
42+
create role authenticated nologin;
43+
exception
44+
when duplicate_object then
45+
null;
46+
when unique_violation then
47+
null;
48+
end;
49+
50+
begin
51+
create role service_role nologin;
52+
exception
2553
when duplicate_object then
2654
null;
2755
when unique_violation then
2856
null;
2957
end;
3058

31-
end
59+
end
3260
$$;

0 commit comments

Comments
 (0)