Skip to content

Commit 3e47f0a

Browse files
committed
Fix query being executed when using describe on unsafe - fixes porsager#424
1 parent 85bca49 commit 3e47f0a

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/query.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ export class Query extends Promise {
108108
}
109109

110110
describe() {
111-
this.onlyDescribe = true
111+
this.options.simple = false
112+
this.onlyDescribe = this.options.prepare = true
112113
return this
113114
}
114115

tests/index.js

+12
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,18 @@ t('unsafe simple includes columns', async() => {
616616
return ['x', (await sql.unsafe('select 1 as x').values()).columns[0].name]
617617
})
618618

619+
t('unsafe describe', async() => {
620+
const q = 'insert into test values (1)'
621+
await sql`create table test(a int unique)`
622+
await sql.unsafe(q).describe()
623+
const x = await sql.unsafe(q).describe()
624+
return [
625+
q,
626+
x.string,
627+
await sql`drop table test`
628+
]
629+
})
630+
619631
t('listen and notify', async() => {
620632
const sql = postgres(options)
621633
const channel = 'hello'

0 commit comments

Comments
 (0)