File tree 1 file changed +7
-2
lines changed
1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ class Result {
9
9
this . rowCount = undefined
10
10
this . fields = [ ]
11
11
this . rows = [ ]
12
+ this . _prebuiltEmptyResultObject = null
12
13
}
13
14
14
15
consumeCommand ( pq ) {
@@ -19,12 +20,16 @@ class Result {
19
20
consumeFields ( pq ) {
20
21
const nfields = pq . nfields ( )
21
22
this . fields = new Array ( nfields )
23
+ var row = { }
22
24
for ( var x = 0 ; x < nfields ; x ++ ) {
25
+ var name = pq . fname ( x ) ;
26
+ row [ name ] = null
23
27
this . fields [ x ] = {
24
- name : pq . fname ( x ) ,
28
+ name : name ,
25
29
dataTypeID : pq . ftype ( x ) ,
26
30
}
27
31
}
32
+ this . _prebuiltEmptyResultObject = { ...row }
28
33
}
29
34
30
35
consumeRows ( pq ) {
@@ -36,7 +41,7 @@ class Result {
36
41
}
37
42
38
43
consumeRowAsObject ( pq , rowIndex ) {
39
- const row = { }
44
+ const row = { ... this . _prebuiltEmptyResultObject }
40
45
for ( var j = 0 ; j < this . fields . length ; j ++ ) {
41
46
row [ this . fields [ j ] . name ] = this . readValue ( pq , rowIndex , j )
42
47
}
You can’t perform that action at this time.
0 commit comments