Skip to content

Commit

Permalink
build cf
Browse files Browse the repository at this point in the history
  • Loading branch information
porsager committed Jun 26, 2023
1 parent 8b82418 commit 4f1d670
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
5 changes: 1 addition & 4 deletions cf/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function Postgres(a, b) {

return sql

function Sql(handler, instant) {
function Sql(handler) {
handler.debug = options.debug

Object.entries(options.types).reduce((acc, [name, type]) => {
Expand Down Expand Up @@ -112,7 +112,6 @@ function Postgres(a, b) {
: typeof strings === 'string' && !args.length
? new Identifier(options.transform.column.to ? options.transform.column.to(strings) : strings)
: new Builder(strings, args)
instant && query instanceof Query && query.execute()
return query
}

Expand All @@ -123,7 +122,6 @@ function Postgres(a, b) {
...options,
simple: 'simple' in options ? options.simple : args.length === 0
})
instant && query.execute()
return query
}

Expand All @@ -141,7 +139,6 @@ function Postgres(a, b) {
...options,
simple: 'simple' in options ? options.simple : args.length === 0
})
instant && query.execute()
return query
}
}
Expand Down
10 changes: 7 additions & 3 deletions cf/src/subscribe.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,15 @@ export default function Subscribe(postgres, options) {
}

stream.on('data', data)
stream.on('error', sql.close)
stream.on('error', error)
stream.on('close', sql.close)

return { stream, state: xs.state }

function error(e) {
console.error('Unexpected error during logical streaming - reconnecting', e)
}

function data(x) {
if (x[0] === 0x77)
parse(x.subarray(25), state, sql.options.parsers, handle, options.transform)
Expand Down Expand Up @@ -191,7 +195,7 @@ function parse(x, state, parsers, handle, transform) {
i += 4
const key = x[i] === 75
handle(key || x[i] === 79
? tuples(x, key ? relation.keys : relation.columns, i += 3, transform).row
? tuples(x, relation.columns, i += 3, transform).row
: null
, {
command: 'delete',
Expand All @@ -205,7 +209,7 @@ function parse(x, state, parsers, handle, transform) {
i += 4
const key = x[i] === 75
const xs = key || x[i] === 79
? tuples(x, key ? relation.keys : relation.columns, i += 3, transform)
? tuples(x, relation.columns, i += 3, transform)
: null

xs && (i = xs.i)
Expand Down

0 comments on commit 4f1d670

Please sign in to comment.