Lookup Table Wrongly Reordered in HasManyFacet
Opened this issue · 1 comments
Hi all,
I've been using the system for a while now, and it has been working great for me. However, I've added a new facet, and am running into an issue.
I have 5 relavent models/tables
IndexedWriter
Language
Ethnicity
IndexedWritersEthnicity
IndexedWritersLanguage
IndexedWriter
has_many :languages, :through => :indexed_writers_languages
has_many :ethnicities, :through => :indexed_writers_ethnicities
When I introduce facets for language
and ethnicity
class WriterSearch < FortyFacets::FacetSearch
model 'IndexedWriter' # which model to search for
facet :ethnicities, name: "Ethnicities"
facet :languages, name: "Languages"
end
Languages works perfectly, but throws ERROR: missing FROM-clause entry for table "ethnicities_indexed_writers"
when I try the other.
After some debugging I've determined the source of the issue is where the join table gets calculated:
The sort
in this line resolves the join table indexed_writers_languages
correctly since 'i' < 'l', but it does resolve the ethnicities join table as ethnicities_indexed_writers
. This obviously is wrong, and for my case I can change the line to:
join_name = [base_table.to_sdefinition.association.name.to_s].join('_')
But this change breaks a test.
Please advise!
For others in this boat - this lexicagraphic ordering is the rails default, FF is following that convention -- it might be better to read the through table off the model, but this behaves in-line with rails generally.