File tree Expand file tree Collapse file tree 3 files changed +22
-2
lines changed
Expand file tree Collapse file tree 3 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,10 @@ def append(hash = {}, &block)
3636 with ( operations : operations + new_operations )
3737 end
3838
39+ def merge ( other )
40+ with ( operations : operations + other . operations )
41+ end
42+
3943 def to_ast
4044 [ :where , operations . map ( &:to_ast ) ]
4145 end
Original file line number Diff line number Diff line change @@ -20,9 +20,9 @@ def each(&block)
2020 def append ( type , *args , &block )
2121 new_dsl =
2222 if block
23- dsl . new ( &block )
23+ dsl . new ( ast : [ ] , &block )
2424 else
25- dsl . new . __send__ ( type , *args )
25+ dsl . new ( ast : [ ] ) . __send__ ( type , *args )
2626 end
2727
2828 left = self
Original file line number Diff line number Diff line change 442442 end
443443 end
444444
445+ context "with existing :where" do
446+ let ( :query ) do
447+ source_query . append ( :where , name : "Jane" ) . append ( :where , id : 1 )
448+ end
449+
450+ specify do
451+ expect ( result ) . to eql (
452+ <<~SQL . strip . gsub ( "\n " , " " )
453+ SELECT id, name
454+ FROM users
455+ WHERE name = 'Jane' AND id = 1
456+ SQL
457+ )
458+ end
459+ end
460+
445461 context "with a block" do
446462 let ( :query ) do
447463 source_query . append ( :order ) { WHERE ( `name` == "Jane" ) }
You can’t perform that action at this time.
0 commit comments