Skip to content

Reset column information when we encounter an error

Thong Kuah requested to merge active_record_relation_union_reset into master

What does this MR do and why?

Reset column information when we encounter an error

To reduce time to mitigation, we reset the column information for the model when we encounter an error where the columns are not the same for a UNION query

Related issue: #412980 (closed)

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

  1. In a rails console, run User.first.authorized_groups.load. The query should succeed
  2. In a psql console, run ALTER TABLE namespaces ADD COLUMN test_column_added int;
  3. In the rails console, run User.first.authorized_groups.load again. The query should error.
  4. Run User.first.authorized_groups.load again. On master, the query will still error. On this branch, the query will now succeeed.

Clean-up

  1. In a psql console, run ALTER TABLE namespaces DROP COLUMN test_column_added;

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 Thong Kuah

Merge request reports