File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
ruby_event_store-active_record/spec Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -292,6 +292,21 @@ module ActiveRecord
292292 end
293293 end
294294
295+ specify "avoid N+1 without additional query when join is used for querying" do
296+ repository . append_to_stream (
297+ [ SRecord . new , SRecord . new ] ,
298+ Stream . new ( "stream" ) ,
299+ ExpectedVersion . auto
300+ )
301+ expect { repository . read ( specification . stream ( "stream" ) . of_type ( "type" ) . result ) } . to match_query_count ( 1 )
302+ expect { repository . read ( specification . stream ( "stream" ) . as_of . result ) } . to match_query_count ( 1 )
303+ expect { repository . read ( specification . stream ( "stream" ) . as_at . result ) } . to match_query_count ( 1 )
304+ expect { repository . read ( specification . stream ( "stream" ) . older_than ( Time . now ) . result ) } . to match_query_count ( 1 )
305+ expect { repository . read ( specification . stream ( "stream" ) . older_than_or_equal ( Time . now ) . result ) } . to match_query_count ( 1 )
306+ expect { repository . read ( specification . stream ( "stream" ) . newer_than ( Time . now ) . result ) } . to match_query_count ( 1 )
307+ expect { repository . read ( specification . stream ( "stream" ) . newer_than_or_equal ( Time . now ) . result ) } . to match_query_count ( 1 )
308+ end
309+
295310 specify "don't join events when no event filtering criteria when counting" do
296311 expect {
297312 repository . count ( specification . stream ( "stream" ) . result )
You can’t perform that action at this time.
0 commit comments