File tree 1 file changed +6
-2
lines changed
1 file changed +6
-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,9 +20,12 @@ class Result {
19
20
consumeFields ( pq ) {
20
21
const nfields = pq . nfields ( )
21
22
this . fields = new Array ( nfields )
23
+ this . _prebuiltEmptyResultObject = { }
22
24
for ( var x = 0 ; x < nfields ; x ++ ) {
25
+ var name = pq . fname ( x )
26
+ this . _prebuiltEmptyResultObject [ 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
}
@@ -36,7 +40,7 @@ class Result {
36
40
}
37
41
38
42
consumeRowAsObject ( pq , rowIndex ) {
39
- const row = { }
43
+ const row = { ... this . _prebuiltEmptyResultObject }
40
44
for ( var j = 0 ; j < this . fields . length ; j ++ ) {
41
45
row [ this . fields [ j ] . name ] = this . readValue ( pq , rowIndex , j )
42
46
}
You can’t perform that action at this time.
0 commit comments