Skip to content
Open
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
9 changes: 6 additions & 3 deletions packages/pg-native/lib/build-result.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class Result {
this.fields = []
this.rows = []
this._prebuiltEmptyResultObject = null
this._parsers = []
}

consumeCommand(pq) {
Expand All @@ -21,13 +22,16 @@ class Result {
const nfields = pq.nfields()
this.fields = new Array(nfields)
const row = {}
this._parsers = new Array(nfields)
for (let x = 0; x < nfields; x++) {
const name = pq.fname(x)
row[name] = null
const typeId = pq.ftype(x)
this.fields[x] = {
name: name,
dataTypeID: pq.ftype(x),
dataTypeID: typeId,
}
this._parsers[x] = this._types.getTypeParser(typeId)
}
this._prebuiltEmptyResultObject = { ...row }
}
Expand Down Expand Up @@ -61,8 +65,7 @@ class Result {
if (rawValue === '' && pq.getisnull(rowIndex, colIndex)) {
return null
}
const dataTypeId = this.fields[colIndex].dataTypeID
return this._types.getTypeParser(dataTypeId)(rawValue)
return this._parsers[colIndex](rawValue)
}
}

Expand Down