Ignore 'imported' column on Epic model
<!--IssueSummary start--> <details> <summary> Everyone can contribute. [Help move this issue forward](https://handbook.gitlab.com/handbook/marketing/developer-relations/contributor-success/community-contributors-workflows/#contributor-links) while earning points, leveling up and collecting rewards. </summary> - [Close this issue](https://contributors.gitlab.com/manage-issue?action=close&projectId=278964&issueIid=462125) </details> <!--IssueSummary end--> When [implementing the ignores](https://gitlab.com/gitlab-org/gitlab/-/issues/460213) for models where an `imported` column was added, [specs failed](https://gitlab.com/gitlab-org/gitlab/-/jobs/6825342309#L2057) due to ignoring the column on the `Epic` model. This proved difficult to debug, so it was decided to create this issue specifically for the `Epic` model. The root cause is a consequence of how nested queries are constructed when calculating relative positions and sorting epic trees. As background: When you ignore a column, rails will replace `SELECT epics.*` with a column list without the ignored column. This can cause issues if you nest queries. E.g. `Epic.from("(#{Epic.select(:id).to_sql}) as epics").first` (the FROM clause is a subquery) This scope works when no column ignores present and fails when you ignore any columns. The fix is to add explicit select to the outer query as well: `Epic.select(:id).from("(#{Epic.select(:id).to_sql}) as epics").first`
issue