Skip to content

Commit

Permalink
no temp table with transaction pooling
Browse files Browse the repository at this point in the history
  • Loading branch information
cirospaciari committed Feb 14, 2025
1 parent abf6de7 commit 01c9f1d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions test/js/sql/tls-sql.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ for (const options of [
max: 1,
bigint: true,
prepare: true,
transactionPool: false,
},
{
url: PG_TRANSACTION_POOL_SUPABASE_URL,
Expand All @@ -21,9 +22,10 @@ for (const options of [
max: 1,
bigint: true,
prepare: false,
transactionPool: true,
},
]) {
describe(`${options.prepare === false ? "Transaction Pooling" : "Prepared Statements"}`, () => {
describe(`${options.transactionPool ? "Transaction Pooling" : "Prepared Statements"}`, () => {
test("default sql", async () => {
expect(sql.reserve).toBeDefined();
expect(sql.options).toBeDefined();
Expand Down Expand Up @@ -70,7 +72,7 @@ for (const options of [
return expect(error.code).toBe("ERR_POSTGRES_UNSAFE_TRANSACTION");
});

test("Transaction throws", async () => {
test.skipIf(options.transactionPool)("Transaction throws", async () => {
await using sql = new SQL(options);
const random_name = ("t_" + randomUUIDv7("hex").replaceAll("-", "")).toLowerCase();

Expand All @@ -85,7 +87,7 @@ for (const options of [
).toBe("22P02");
});

test("Transaction rolls back", async () => {
test.skipIf(options.transactionPool)("Transaction rolls back", async () => {
await using sql = new SQL(options);
const random_name = ("t_" + randomUUIDv7("hex").replaceAll("-", "")).toLowerCase();

Expand All @@ -103,7 +105,7 @@ for (const options of [
expect((await sql`select a from ${sql(random_name)}`).count).toBe(0);
});

test("Transaction throws on uncaught savepoint", async () => {
test.skipIf(options.transactionPool)("Transaction throws on uncaught savepoint", async () => {
await using sql = new SQL(options);
const random_name = ("t_" + randomUUIDv7("hex").replaceAll("-", "")).toLowerCase();
await sql`CREATE TEMPORARY TABLE IF NOT EXISTS ${sql(random_name)} (a int)`;
Expand All @@ -120,7 +122,7 @@ for (const options of [
).toBe("fail");
});

test("Transaction throws on uncaught named savepoint", async () => {
test.skipIf(options.transactionPool)("Transaction throws on uncaught named savepoint", async () => {
await using sql = new SQL(options);
const random_name = ("t_" + randomUUIDv7("hex").replaceAll("-", "")).toLowerCase();
await sql`CREATE TEMPORARY TABLE IF NOT EXISTS ${sql(random_name)} (a int)`;
Expand Down Expand Up @@ -228,7 +230,7 @@ for (const options of [
).toBe("11");
});

test("Transaction waits", async () => {
test.skipIf(options.transactionPool)("Transaction waits", async () => {
await using sql = new SQL({ ...options, max: 2 });
const random_name = ("t_" + randomUUIDv7("hex").replaceAll("-", "")).toLowerCase();
await sql`CREATE TEMPORARY TABLE IF NOT EXISTS ${sql(random_name)} (a int)`;
Expand Down

0 comments on commit 01c9f1d

Please sign in to comment.