Skip to content

Commit

Permalink
test against using inner joins
Browse files Browse the repository at this point in the history
  • Loading branch information
pjurewicz committed Dec 6, 2023
1 parent 3c50616 commit 47c294a
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions ruby_event_store-active_record/spec/event_repository_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module ActiveRecord

it_behaves_like :event_repository, mk_repository, helper


let(:repository) { mk_repository.call }
let(:specification) do
Specification.new(
Expand Down Expand Up @@ -212,7 +212,7 @@ module ActiveRecord
expect {
repository.read(specification.in_batches.as_of.result).to_a
}.to match_query /SELECT.*FROM.*event_store_events.*ORDER BY .*COALESCE(.*event_store_events.*valid_at.*, .*event_store_events.*created_at.*).* ASC,.*event_store_events.*id.* ASC LIMIT.*.OFFSET.*/,
2
2
end

specify "with batches and non-bi-temporal queries use monotonic ids" do
Expand Down Expand Up @@ -277,6 +277,22 @@ module ActiveRecord
}x
end

specify 'inner join events when event filtering criteria present' do
[
specification.stream("stream").of_type("type"),
specification.stream("stream").as_of,
specification.stream("stream").as_at,
specification.stream("stream").older_than(Time.now),
specification.stream("stream").older_than_or_equal(Time.now),
specification.stream("stream").newer_than(Time.now),
specification.stream("stream").newer_than_or_equal(Time.now),
].each do |spec|
expect {
repository.read(spec.result).to_a
}.to match_query /INNER\s+JOIN\s+.event_store_events./
end
end

specify "don't join events when no event filtering criteria when counting" do
expect {
repository.count(specification.stream("stream").result)
Expand Down

0 comments on commit 47c294a

Please sign in to comment.