fix(filter): filtering types_de_champs by enum should not ilike. nows it search by exact match since enum are normalized so findable with simple where
This commit is contained in:
parent
1339e10280
commit
75063ae31e
2 changed files with 13 additions and 2 deletions
|
@ -33,5 +33,11 @@ module DossierFilteringConcern
|
||||||
q = Array.new(values.count, "(#{table_column} ILIKE ?)").join(' OR ')
|
q = Array.new(values.count, "(#{table_column} ILIKE ?)").join(' OR ')
|
||||||
where(q, *(values.map { |value| "%#{value}%" }))
|
where(q, *(values.map { |value| "%#{value}%" }))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scope :filter_enum, lambda { |table, column, values|
|
||||||
|
table_column = ProcedurePresentation.sanitized_column(table, column)
|
||||||
|
q = Array.new(values.count, "(#{table_column} = ?)").join(' OR ')
|
||||||
|
where(q, *(values))
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -220,8 +220,13 @@ class ProcedurePresentation < ApplicationRecord
|
||||||
dossiers.where("dossiers.#{column} IN (?)", values)
|
dossiers.where("dossiers.#{column} IN (?)", values)
|
||||||
end
|
end
|
||||||
when TYPE_DE_CHAMP
|
when TYPE_DE_CHAMP
|
||||||
dossiers.with_type_de_champ(column)
|
if dossier_column.type == :enum
|
||||||
.filter_ilike(:champs, value_column, values)
|
dossiers.with_type_de_champ(column)
|
||||||
|
.filter_enum(:champs, value_column, values)
|
||||||
|
else
|
||||||
|
dossiers.with_type_de_champ(column)
|
||||||
|
.filter_ilike(:champs, value_column, values)
|
||||||
|
end
|
||||||
when 'etablissement'
|
when 'etablissement'
|
||||||
if column == 'entreprise_date_creation'
|
if column == 'entreprise_date_creation'
|
||||||
dates = values
|
dates = values
|
||||||
|
|
Loading…
Reference in a new issue