Skip to content

Commit ffc8581

Browse files
committed
Fix query being executed when using describe on unsafe - fixes #424
1 parent 35c8a3f commit ffc8581

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/query.js

Lines changed: 2 additions & 1 deletion
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

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

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

0 commit comments

Comments
 (0)