ubicloud/cli-commands/lb
Jeremy Evans 7a67afe8d4 Use the pg_auto_parameterize_duplicate_query_detection Sequel extension
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.
2025-10-18 03:24:36 +09:00
..
post Use the pg_auto_parameterize_duplicate_query_detection Sequel extension 2025-10-18 03:24:36 +09:00
list.rb Make cli lb list command include location 2025-02-21 15:19:20 -08:00