Skip to content

Add cached column list slicing to `attributes` calls

charlie ablett requested to merge cablett-421237-slice-by-attributes into master

What does this MR do and why?

Avoids multi-deployment errors when database migrations occur on one environment but not another.

Added slice with the appropriate class for multiple attributes calls that are used to instantiate a new AR object.

This avoids multi-deployment errors such as Mixed deployment issue: Column added on `labels... (#421145 - closed) which was caused by the attributes method caching column names and then throwing a wobbly when a column has been added to an underlying database because a new database column "wasn't found" (cache was outdated).

The fix Override attributes to include known column nam... (!128578 - merged) to unblock deployments was to slice the label call (and any other called to label.attributes) by known column names to avoid issues where an added column wasn't picked up sufficiently by the cached attributes value, and ActiveRecord threw an error as a result.

Co-created with Add reset when UnknownAttributeError is hit (!128576 - merged) - the catch-all for if any of them sneak by, and is a longer-term solution I think.

Note: This doens't fix all of them, but the easy ones. #421237 (comment 1503492098) has a grep of the ones I could find.

Screenshots or screen recordings

No user-facing changes

How to set up and validate locally

See !128576 (merged) for validating locally.

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 charlie ablett

Merge request reports