@@ -95,79 +95,6 @@ class Result {
9595 }
9696 }
9797 }
98-
99- // adds a command complete message
100- addCommandComplete ( msg ) {
101- var match
102- if ( msg . text ) {
103- // pure javascript
104- match = matchRegexp . exec ( msg . text )
105- } else {
106- // native bindings
107- match = matchRegexp . exec ( msg . command )
108- }
109- if ( match ) {
110- this . command = match [ 1 ]
111- if ( match [ 3 ] ) {
112- // COMMMAND OID ROWS
113- this . oid = parseInt ( match [ 2 ] , 10 )
114- this . rowCount = parseInt ( match [ 3 ] , 10 )
115- } else if ( match [ 2 ] ) {
116- // COMMAND ROWS
117- this . rowCount = parseInt ( match [ 2 ] , 10 )
118- }
119- }
120- }
121-
122- _parseRowAsArray ( rowData ) {
123- var row = new Array ( rowData . length )
124- for ( var i = 0 , len = rowData . length ; i < len ; i ++ ) {
125- var rawValue = rowData [ i ]
126- if ( rawValue !== null ) {
127- row [ i ] = this . _parsers [ i ] ( rawValue )
128- } else {
129- row [ i ] = null
130- }
131- }
132- return row
133- }
134-
135- parseRow ( rowData ) {
136- var row = { }
137- for ( var i = 0 , len = rowData . length ; i < len ; i ++ ) {
138- var rawValue = rowData [ i ]
139- var field = this . fields [ i ] . name
140- if ( rawValue !== null ) {
141- row [ field ] = this . _parsers [ i ] ( rawValue )
142- } else {
143- row [ field ] = null
144- }
145- }
146- return row
147- }
148-
149- addRow ( row ) {
150- this . rows . push ( row )
151- }
152-
153- addFields ( fieldDescriptions ) {
154- // clears field definitions
155- // multiple query statements in 1 action can result in multiple sets
156- // of rowDescriptions...eg: 'select NOW(); select 1::int;'
157- // you need to reset the fields
158- this . fields = fieldDescriptions
159- if ( this . fields . length ) {
160- this . _parsers = new Array ( fieldDescriptions . length )
161- }
162- for ( var i = 0 ; i < fieldDescriptions . length ; i ++ ) {
163- var desc = fieldDescriptions [ i ]
164- if ( this . _types ) {
165- this . _parsers [ i ] = this . _types . getTypeParser ( desc . dataTypeID , desc . format || 'text' )
166- } else {
167- this . _parsers [ i ] = types . getTypeParser ( desc . dataTypeID , desc . format || 'text' )
168- }
169- }
170- }
17198}
17299
173100module . exports = Result
0 commit comments