File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -36,16 +36,18 @@ var Query = Node.define({
3636 return this . add ( from ) ;
3737 } ,
3838 where : function ( node ) {
39- this . where = new Where ( ) ;
40- this . where . add ( node ) ;
41- return this . add ( this . where ) ;
39+ //calling #where twice functions like calling #where & then #and
40+ if ( this . whereClause ) return this . and ( node ) ;
41+ this . whereClause = new Where ( ) ;
42+ this . whereClause . add ( node ) ;
43+ return this . add ( this . whereClause ) ;
4244 } ,
4345 or : function ( node ) {
44- this . where . or ( node ) ;
46+ this . whereClause . or ( node ) ;
4547 return this ;
4648 } ,
4749 and : function ( node ) {
48- this . where . and ( node ) ;
50+ this . whereClause . and ( node ) ;
4951 return this ;
5052 } ,
5153 order : function ( ) {
Original file line number Diff line number Diff line change @@ -311,3 +311,11 @@ test({
311311 query : user . where ( user . name . equals ( 3 ) ) ,
312312 pg : 'SELECT "user".* FROM "user" WHERE ("user"."name" = $1)'
313313} ) ;
314+
315+ var q = user . where ( user . name . equals ( 3 ) )
316+ console . log ( q )
317+ console . log ( Object . keys ( q ) )
318+ test ( {
319+ query : user . where ( user . name . equals ( 3 ) ) . where ( user . id . equals ( 1 ) ) ,
320+ pg : 'SELECT "user".* FROM "user" WHERE (("user"."name" = $1) AND ("user"."id" = $2))'
321+ } ) ;
You can’t perform that action at this time.
0 commit comments