File tree 2 files changed +28
-0
lines changed
2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -19,3 +19,10 @@ NativeResult.prototype.addCommandComplete = function(pq) {
19
19
} ) ;
20
20
}
21
21
} ;
22
+
23
+ NativeResult . prototype . addRow = function ( row ) {
24
+ // This is empty to ensure pg code doesn't break when switching to pg-native
25
+ // pg-native loads all rows into the final result object by default.
26
+ // This is because libpg loads all rows into memory before passing the result
27
+ // to pg-native.
28
+ } ;
Original file line number Diff line number Diff line change @@ -36,6 +36,27 @@ test("simple query interface", function() {
36
36
} ) ;
37
37
} ) ;
38
38
39
+ test ( "simple query interface using addRow" , function ( ) {
40
+
41
+ var client = helper . client ( ) ;
42
+
43
+ var query = client . query ( "select name from person order by name" ) ;
44
+
45
+ client . on ( 'drain' , client . end . bind ( client ) ) ;
46
+
47
+ query . on ( 'row' , function ( row , result ) {
48
+ assert . ok ( result ) ;
49
+ result . addRow ( row ) ;
50
+ } ) ;
51
+
52
+ query . on ( 'end' , function ( result ) {
53
+ assert . lengthIs ( result . rows , 26 , "result returned wrong number of rows" ) ;
54
+ assert . lengthIs ( result . rows , result . rowCount ) ;
55
+ assert . equal ( result . rows [ 0 ] . name , "Aaron" ) ;
56
+ assert . equal ( result . rows [ 25 ] . name , "Zanzabar" ) ;
57
+ } ) ;
58
+ } ) ;
59
+
39
60
test ( "multiple simple queries" , function ( ) {
40
61
var client = helper . client ( ) ;
41
62
client . query ( { text : "create temp table bang(id serial, name varchar(5));insert into bang(name) VALUES('boom');" } )
You can’t perform that action at this time.
0 commit comments