Ensure PostgreSQL versions are memoized at start of tests
What does this MR do and why?
Some GitLab classes, such as Gitlab::Database::AsWithMaterialized
, need to check the PostgreSQL version to determine whether certain keywords can be used. We have some specs that specify exact query types or check for N+1 queries that might be thrown off by an extra SELECT VERSION()
call. To ensure this doesn't happen, retrieve the version at the beginning of the test.
Note that the initializer config/initializers/1_postgresql_only.rb
already attempts to check the PostgreSQL version, but the result isn't memoized properly for callers that use ApplicationRecord.database.version
.
This came up in !99097 (comment 1118427731).
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.