Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cf/src/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
: (query = q, query.active = true)

build(q)
q.onquery && (q.onquery = q.onquery(q))
return write(toBuffer(q))
&& !q.describeFirst
&& !q.cursorFn
Expand Down
2 changes: 2 additions & 0 deletions cf/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ function Postgres(a, b) {

function Sql(handler) {
handler.debug = options.debug
handler.onquery = options.onquery

Object.entries(options.types).reduce((acc, [name, type]) => {
acc[name] = (x) => new Parameter(x, type.to)
Expand Down Expand Up @@ -492,6 +493,7 @@ function parseOptions(a, b) {
onnotify : o.onnotify,
onclose : o.onclose,
onparameter : o.onparameter,
onquery : o.onquery,
socket : o.socket,
transform : parseTransform(o.transform || { undefined: undefined }),
parameters : {},
Expand Down
27 changes: 23 additions & 4 deletions cf/src/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export class Query extends Promise {
reject = b
})

this.resolver = resolve
this.rejecter = reject

this.tagged = Array.isArray(strings.raw)
this.strings = strings
this.args = args
Expand All @@ -23,19 +26,29 @@ export class Query extends Promise {
this.state = null
this.statement = null

this.resolve = x => (this.active = false, resolve(x))
this.reject = x => (this.active = false, reject(x))

this.active = false
this.cancelled = null
this.executed = false
this.signature = ''
this.onquery = this.handler.onquery

this[originError] = this.handler.debug
? new Error()
: this.tagged && cachedError(this.strings)
}

resolve(x) {
this.active = false
this.onquery && (this.onquery = this.onquery(x))
this.resolver(x)
}

reject(x) {
this.active = false
this.onquery && (this.onquery = this.onquery(x))
this.rejecter(x)
}

get origin() {
return (this.handler.debug
? this[originError].stack
Expand Down Expand Up @@ -137,7 +150,13 @@ export class Query extends Promise {
}

async handle() {
!this.executed && (this.executed = true) && await 1 && this.handler(this)
if (this.executed)
return

this.executed = true
await 1
this.onquery && (this.onquery = this.onquery(this))
this.handler(this)
}

execute() {
Expand Down
1 change: 1 addition & 0 deletions cjs/src/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
: (query = q, query.active = true)

build(q)
q.onquery && (q.onquery = q.onquery(q))
return write(toBuffer(q))
&& !q.describeFirst
&& !q.cursorFn
Expand Down
2 changes: 2 additions & 0 deletions cjs/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ function Postgres(a, b) {

function Sql(handler) {
handler.debug = options.debug
handler.onquery = options.onquery

Object.entries(options.types).reduce((acc, [name, type]) => {
acc[name] = (x) => new Parameter(x, type.to)
Expand Down Expand Up @@ -491,6 +492,7 @@ function parseOptions(a, b) {
onnotify : o.onnotify,
onclose : o.onclose,
onparameter : o.onparameter,
onquery : o.onquery,
socket : o.socket,
transform : parseTransform(o.transform || { undefined: undefined }),
parameters : {},
Expand Down
27 changes: 23 additions & 4 deletions cjs/src/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ const Query = module.exports.Query = class Query extends Promise {
reject = b
})

this.resolver = resolve
this.rejecter = reject

this.tagged = Array.isArray(strings.raw)
this.strings = strings
this.args = args
Expand All @@ -23,19 +26,29 @@ const Query = module.exports.Query = class Query extends Promise {
this.state = null
this.statement = null

this.resolve = x => (this.active = false, resolve(x))
this.reject = x => (this.active = false, reject(x))

this.active = false
this.cancelled = null
this.executed = false
this.signature = ''
this.onquery = this.handler.onquery

this[originError] = this.handler.debug
? new Error()
: this.tagged && cachedError(this.strings)
}

resolve(x) {
this.active = false
this.onquery && (this.onquery = this.onquery(x))
this.resolver(x)
}

reject(x) {
this.active = false
this.onquery && (this.onquery = this.onquery(x))
this.rejecter(x)
}

get origin() {
return (this.handler.debug
? this[originError].stack
Expand Down Expand Up @@ -137,7 +150,13 @@ const Query = module.exports.Query = class Query extends Promise {
}

async handle() {
!this.executed && (this.executed = true) && await 1 && this.handler(this)
if (this.executed)
return

this.executed = true
await 1
this.onquery && (this.onquery = this.onquery(this))
this.handler(this)
}

execute() {
Expand Down
1 change: 1 addition & 0 deletions deno/src/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
: (query = q, query.active = true)

build(q)
q.onquery && (q.onquery = q.onquery(q))
return write(toBuffer(q))
&& !q.describeFirst
&& !q.cursorFn
Expand Down
2 changes: 2 additions & 0 deletions deno/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ function Postgres(a, b) {

function Sql(handler) {
handler.debug = options.debug
handler.onquery = options.onquery

Object.entries(options.types).reduce((acc, [name, type]) => {
acc[name] = (x) => new Parameter(x, type.to)
Expand Down Expand Up @@ -492,6 +493,7 @@ function parseOptions(a, b) {
onnotify : o.onnotify,
onclose : o.onclose,
onparameter : o.onparameter,
onquery : o.onquery,
socket : o.socket,
transform : parseTransform(o.transform || { undefined: undefined }),
parameters : {},
Expand Down
27 changes: 23 additions & 4 deletions deno/src/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export class Query extends Promise {
reject = b
})

this.resolver = resolve
this.rejecter = reject

this.tagged = Array.isArray(strings.raw)
this.strings = strings
this.args = args
Expand All @@ -23,19 +26,29 @@ export class Query extends Promise {
this.state = null
this.statement = null

this.resolve = x => (this.active = false, resolve(x))
this.reject = x => (this.active = false, reject(x))

this.active = false
this.cancelled = null
this.executed = false
this.signature = ''
this.onquery = this.handler.onquery

this[originError] = this.handler.debug
? new Error()
: this.tagged && cachedError(this.strings)
}

resolve(x) {
this.active = false
this.onquery && (this.onquery = this.onquery(x))
this.resolver(x)
}

reject(x) {
this.active = false
this.onquery && (this.onquery = this.onquery(x))
this.rejecter(x)
}

get origin() {
return (this.handler.debug
? this[originError].stack
Expand Down Expand Up @@ -137,7 +150,13 @@ export class Query extends Promise {
}

async handle() {
!this.executed && (this.executed = true) && await 1 && this.handler(this)
if (this.executed)
return

this.executed = true
await 1
this.onquery && (this.onquery = this.onquery(this))
this.handler(this)
}

execute() {
Expand Down
1 change: 1 addition & 0 deletions src/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
: (query = q, query.active = true)

build(q)
q.onquery && (q.onquery = q.onquery(q))
return write(toBuffer(q))
&& !q.describeFirst
&& !q.cursorFn
Expand Down
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ function Postgres(a, b) {

function Sql(handler) {
handler.debug = options.debug
handler.onquery = options.onquery

Object.entries(options.types).reduce((acc, [name, type]) => {
acc[name] = (x) => new Parameter(x, type.to)
Expand Down Expand Up @@ -492,6 +493,7 @@ function parseOptions(a, b) {
onnotify : o.onnotify,
onclose : o.onclose,
onparameter : o.onparameter,
onquery : o.onquery,
socket : o.socket,
transform : parseTransform(o.transform || { undefined: undefined }),
parameters : {},
Expand Down
27 changes: 23 additions & 4 deletions src/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export class Query extends Promise {
reject = b
})

this.resolver = resolve
this.rejecter = reject

this.tagged = Array.isArray(strings.raw)
this.strings = strings
this.args = args
Expand All @@ -23,19 +26,29 @@ export class Query extends Promise {
this.state = null
this.statement = null

this.resolve = x => (this.active = false, resolve(x))
this.reject = x => (this.active = false, reject(x))

this.active = false
this.cancelled = null
this.executed = false
this.signature = ''
this.onquery = this.handler.onquery

this[originError] = this.handler.debug
? new Error()
: this.tagged && cachedError(this.strings)
}

resolve(x) {
this.active = false
this.onquery && (this.onquery = this.onquery(x))
this.resolver(x)
}

reject(x) {
this.active = false
this.onquery && (this.onquery = this.onquery(x))
this.rejecter(x)
}

get origin() {
return (this.handler.debug
? this[originError].stack
Expand Down Expand Up @@ -137,7 +150,13 @@ export class Query extends Promise {
}

async handle() {
!this.executed && (this.executed = true) && await 1 && this.handler(this)
if (this.executed)
return

this.executed = true
await 1
this.onquery && (this.onquery = this.onquery(this))
this.handler(this)
}

execute() {
Expand Down