[Fix #2622] Change filters to proper JSONB

This commit is contained in:
Frederic Merizen 2018-09-20 16:18:21 +02:00
parent 1419e9b73f
commit 7d382837d9
4 changed files with 5 additions and 8 deletions

View file

@ -152,7 +152,7 @@ module NewGestionnaire
'value' => params[:value]
}
procedure_presentation.update(filters: filters.to_json)
procedure_presentation.update(filters: filters)
end
redirect_back(fallback_location: gestionnaire_procedure_url(procedure))
@ -166,7 +166,7 @@ module NewGestionnaire
filters[statut] = filters[statut] - [filter_to_remove]
procedure_presentation.update(filters: filters.to_json)
procedure_presentation.update(filters: filters)
redirect_back(fallback_location: gestionnaire_procedure_url(procedure))
end

View file

@ -1,7 +1,3 @@
class ProcedurePresentation < ApplicationRecord
belongs_to :assign_to
def filters
JSON.parse(read_attribute(:filters))
end
end

View file

@ -3,7 +3,8 @@ namespace :'2018_09_20_procedure_presentation_jsonb' do
ProcedurePresentation.update_all(
<<~SQL
displayed_fields = ('[' || ARRAY_TO_STRING(old_displayed_fields, ',') || ']')::JSONB,
sort = (sort #>> '{}')::jsonb
sort = (sort #>> '{}')::jsonb,
filters = (filters #>> '{}')::jsonb
SQL
)
end

View file

@ -8,7 +8,7 @@ describe ProcedurePresentation do
{ "label" => "test2", "table" => "champs" }
],
sort: { "table" => "user","column" => "email","order" => "asc" },
filters: { "a-suivre" => [], "suivis" => [{ "label" => "label1", "table" => "table1", "column" => "column1" }] }.to_json
filters: { "a-suivre" => [], "suivis" => [{ "label" => "label1", "table" => "table1", "column" => "column1" }] }
).id
}
let (:procedure_presentation) { ProcedurePresentation.find(procedure_presentation_id) }