Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix
Template.latest_version
ambiguity error
- Prior to this commit, the following error was encountered when applying the search filter within `/org_admin/templates`: ``` ActiveRecord::StatementInvalid - PG::AmbiguousColumn: ERROR: column reference "id" is ambiguous LINE 1: SELECT COUNT(DISTINCT id) FROM (SELECT MAX(version) AS versi... ^: app/views/layouts/_paginable.html.erb:5 app/controllers/concerns/paginable.rb:82:in `paginable_renderise' app/controllers/paginable/templates_controller.rb:25:in `index' ``` - Tracing the code reveals that the query encountering this error is `Template.includes(:org).latest_version.where(customization_of: nil).distinct.total_count`. - Although `SELECT "templates.*"` is the default behaviour of the `.latest_version` scope, the ambiguity error is raised unless `.select('templates.*')` is added explicitly.
- Loading branch information