Skip to content

Commit f82ca1b

Browse files
committed
Properly check if prepared
1 parent 6f20f3f commit f82ca1b

File tree

6 files changed

+36
-9
lines changed

6 files changed

+36
-9
lines changed

cjs/src/connection.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
788788
const error = Errors.postgres(parseError(x))
789789
query && query.retried
790790
? errored(query.retried)
791-
: query && query.prepare && retryRoutines.has(error.routine)
791+
: query && query.prepared && retryRoutines.has(error.routine)
792792
? retry(query, error)
793793
: errored(error)
794794
}

cjs/tests/index.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1789,14 +1789,14 @@ t('Recreate prepared statements on RevalidateCachedQuery error', async() => {
17891789
]
17901790
})
17911791

1792-
t('Properly throws routing error on not prepared statements', async() => {
1792+
t('Properly throws routine error on not prepared statements', async() => {
17931793
await sql`create table x (x text[])`
17941794
const { routine } = await sql.unsafe(`insert into x(x) values (('a', 'b'))`).catch(e => e)
17951795

17961796
return ['transformAssignedExpr', routine, await sql`drop table x`]
17971797
})
17981798

1799-
t('Properly throws routing error on not prepared statements in transaction', async() => {
1799+
t('Properly throws routine error on not prepared statements in transaction', async() => {
18001800
const { routine } = await sql.begin(sql => [
18011801
sql`create table x (x text[])`,
18021802
sql`insert into x(x) values (('a', 'b'))`,
@@ -1805,6 +1805,15 @@ t('Properly throws routing error on not prepared statements in transaction', asy
18051805
return ['transformAssignedExpr', routine]
18061806
})
18071807

1808+
t('Properly throws routine error on not prepared statements using file', async() => {
1809+
const { routine } = await sql.unsafe(`
1810+
create table x (x text[]);
1811+
insert into x(x) values (('a', 'b'));
1812+
`, { prepare: true }).catch(e => e)
1813+
1814+
return ['transformAssignedExpr', routine]
1815+
})
1816+
18081817
t('Catches connection config errors', async() => {
18091818
const sql = postgres({ ...options, user: { toString: () => { throw new Error('wat') } }, database: 'prut' })
18101819

deno/src/connection.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
791791
const error = Errors.postgres(parseError(x))
792792
query && query.retried
793793
? errored(query.retried)
794-
: query && query.prepare && retryRoutines.has(error.routine)
794+
: query && query.prepared && retryRoutines.has(error.routine)
795795
? retry(query, error)
796796
: errored(error)
797797
}

deno/tests/index.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1791,14 +1791,14 @@ t('Recreate prepared statements on RevalidateCachedQuery error', async() => {
17911791
]
17921792
})
17931793

1794-
t('Properly throws routing error on not prepared statements', async() => {
1794+
t('Properly throws routine error on not prepared statements', async() => {
17951795
await sql`create table x (x text[])`
17961796
const { routine } = await sql.unsafe(`insert into x(x) values (('a', 'b'))`).catch(e => e)
17971797

17981798
return ['transformAssignedExpr', routine, await sql`drop table x`]
17991799
})
18001800

1801-
t('Properly throws routing error on not prepared statements in transaction', async() => {
1801+
t('Properly throws routine error on not prepared statements in transaction', async() => {
18021802
const { routine } = await sql.begin(sql => [
18031803
sql`create table x (x text[])`,
18041804
sql`insert into x(x) values (('a', 'b'))`,
@@ -1807,6 +1807,15 @@ t('Properly throws routing error on not prepared statements in transaction', asy
18071807
return ['transformAssignedExpr', routine]
18081808
})
18091809

1810+
t('Properly throws routine error on not prepared statements using file', async() => {
1811+
const { routine } = await sql.unsafe(`
1812+
create table x (x text[]);
1813+
insert into x(x) values (('a', 'b'));
1814+
`, { prepare: true }).catch(e => e)
1815+
1816+
return ['transformAssignedExpr', routine]
1817+
})
1818+
18101819
t('Catches connection config errors', async() => {
18111820
const sql = postgres({ ...options, user: { toString: () => { throw new Error('wat') } }, database: 'prut' })
18121821

src/connection.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
788788
const error = Errors.postgres(parseError(x))
789789
query && query.retried
790790
? errored(query.retried)
791-
: query && query.prepare && retryRoutines.has(error.routine)
791+
: query && query.prepared && retryRoutines.has(error.routine)
792792
? retry(query, error)
793793
: errored(error)
794794
}

tests/index.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1789,14 +1789,14 @@ t('Recreate prepared statements on RevalidateCachedQuery error', async() => {
17891789
]
17901790
})
17911791

1792-
t('Properly throws routing error on not prepared statements', async() => {
1792+
t('Properly throws routine error on not prepared statements', async() => {
17931793
await sql`create table x (x text[])`
17941794
const { routine } = await sql.unsafe(`insert into x(x) values (('a', 'b'))`).catch(e => e)
17951795

17961796
return ['transformAssignedExpr', routine, await sql`drop table x`]
17971797
})
17981798

1799-
t('Properly throws routing error on not prepared statements in transaction', async() => {
1799+
t('Properly throws routine error on not prepared statements in transaction', async() => {
18001800
const { routine } = await sql.begin(sql => [
18011801
sql`create table x (x text[])`,
18021802
sql`insert into x(x) values (('a', 'b'))`,
@@ -1805,6 +1805,15 @@ t('Properly throws routing error on not prepared statements in transaction', asy
18051805
return ['transformAssignedExpr', routine]
18061806
})
18071807

1808+
t('Properly throws routine error on not prepared statements using file', async() => {
1809+
const { routine } = await sql.unsafe(`
1810+
create table x (x text[]);
1811+
insert into x(x) values (('a', 'b'));
1812+
`, { prepare: true }).catch(e => e)
1813+
1814+
return ['transformAssignedExpr', routine]
1815+
})
1816+
18081817
t('Catches connection config errors', async() => {
18091818
const sql = postgres({ ...options, user: { toString: () => { throw new Error('wat') } }, database: 'prut' })
18101819

0 commit comments

Comments
 (0)