Skip to content

Fix detection of null relations for Rails 7

Heinrich Lee Yu requested to merge fix-null-relation-detection into master

What does this MR do and why?

In Rails 7, ActiveRecord::NullRelation.to_sql no longer results into a blank string. So we check for the class of the relation instead.

Rails 6:

[1] pry(main)> Issue.none.to_sql
=> ""

Rails 7:

[1] pry(main)> Issue.none.to_sql
=> "SELECT \"issues\".* FROM \"issues\" WHERE (1=0)"

Related failure: https://gitlab.com/gitlab-org/gitlab/-/jobs/3669887028

Refs &7875 (closed)

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Peter Leitzen

Merge request reports