Skip to content

Commit

Permalink
Add delete to manual execution plans
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelmior committed Sep 11, 2015
1 parent be45972 commit 300385a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/nose/plans/execution_plan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,21 @@ def Insert(index_key, *fields)
@update_steps << step
end

# Add a new deletion step from an index
def Delete(index_key)
@index = @schema.indexes[index_key]

step = Plans::DeletePlanStep.new @index

# Get cardinality from last step of each support query plan
# as in UpdatePlanner#find_plans_for_update
cardinalities = @query_plans.map { |p| p.steps.last.state.cardinality }
cardinality = cardinalities.inject(1, &:*)
step.state = OpenStruct.new cardinality: cardinality

@update_steps << step
end

# rubocop:enable MethodName
end
end
Expand Down
1 change: 1 addition & 0 deletions plans/rubis_expert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@
Param items.id, :==
Param items.end_date, :==
Insert 'items_with_category', items.id, categories.id, items.quantity
Delete 'items_by_category'
Insert 'items_by_category', categories.id, items.end_date, items.id
end

Expand Down

0 comments on commit 300385a

Please sign in to comment.