Merge pull request #5538 from tchak/fix-champ-order-joins
Fix champ order joins sql error
This commit is contained in:
commit
0ec63672a8
1 changed files with 7 additions and 1 deletions
|
@ -48,7 +48,13 @@ class Champ < ApplicationRecord
|
|||
scope :private_only, -> { where(private: true) }
|
||||
scope :ordered, -> { includes(:type_de_champ).order(:row, 'types_de_champ.order_place') }
|
||||
scope :public_ordered, -> { public_only.joins(dossier: { revision: :revision_types_de_champ }).where('procedure_revision_types_de_champ.type_de_champ_id = champs.type_de_champ_id').order(:position) }
|
||||
scope :private_ordered, -> { private_only.joins(dossier: { revision: :revision_types_de_champ_private }).where('procedure_revision_types_de_champ.type_de_champ_id = champs.type_de_champ_id').order(:position) }
|
||||
# we need to do private champs order as manual join to avoid conflicting join names
|
||||
scope :private_ordered, -> do
|
||||
private_only.joins('INNER JOIN types_de_champ types_de_champ_private
|
||||
ON types_de_champ_private.id = champs.type_de_champ_id AND types_de_champ_private.private = true
|
||||
INNER JOIN procedure_revision_types_de_champ procedure_revision_types_de_champ_private
|
||||
ON procedure_revision_types_de_champ_private.type_de_champ_id = types_de_champ_private.id').order(:position)
|
||||
end
|
||||
|
||||
scope :root, -> { where(parent_id: nil) }
|
||||
|
||||
|
|
Loading…
Reference in a new issue