mirror of
https://github.com/ubicloud/ubicloud.git
synced 2025-11-29 17:10:26 +08:00
This makes route specs raise if there are duplicate queries that are not inside explicit `ignore_duplicate_queries` blocks. This is the Sequel tooling that that found all of the N+1 issues in #4006. This also enables duplicate query reporting in development mode, though it warns instead of raising. Testing things in development found a bunch of N+1 issues not found by the specs, because this tooling will only find issues if N is greater than 1. Any place where `ignore_duplicate_queries` is used is a place where we definitely have duplicate queries. Some of these are not actually issues, just cases where N is fixed (2 or 3) and used to DRY up duplicate logic. Others we may want to address in the future. This modifies the route spec helpers slightly to ensure that we only build a single app to test against. Previously, `spec/routes/web/spec_helper.rb` used an unnecessary `RackTestPlus` module with an `app` method that override `app` method in `spec/routes/spec_helper.rb`, but returned the same value. This defines a `RackTestApp` for the wrapper app with the duplicate query testing, has `app` return that, and sets `Capybara.app` to it. This avoids loading the pg_auto_parameterize_duplicate_query_detection in production mode and when doing production-like testing (where CLOVER_FREEZE == 1). In those cases, DB.ignore_duplicate_queries is defined to just yield. |
||
|---|---|---|
| .. | ||
| post | ||
| list.rb | ||