I have an index definition with some crutches. The reindex operation always triggers a crutch execution even if I don't want to reindex that one by skipping the related field using :update_fields. Looks like the reason is this line of code https://github.com/toptal/chewy/blob/master/lib/chewy/index/import/bulk_builder.rb#L52 where we don't pass @fields option.
Expected behavior
crutch execution should respect :update_fields option.
Actual behavior
crutch is executed regardless :update_fields option
Steps to reproduce the problem
class UsersIndex < Chewy::Index
index_scope User....
crutch :driver_role do |collection|
::User.includes(employees: :group)
.where(id: collection.map(&:id))
.group(:id, "groups.kind", "groups.role")
.pluck(
:id,
Arel.sql(
"jsonb_build_object(
'driver_role', CASE
WHEN (groups.kind = 'carrier' AND groups.role ='ca_driver') THEN TRUE
ELSE FALSE
END
)"
)
).to_h
end
field :first_name
field :last_name
field :driver_role, type: :boolean, value: ->(user, crutch) { crutch.driver_role.dig(user.id, "driver_role") }
...
end
I have an index definition with some crutches. The reindex operation always triggers a crutch execution even if I don't want to reindex that one by skipping the related field using
:update_fields
. Looks like the reason is this line of code https://github.com/toptal/chewy/blob/master/lib/chewy/index/import/bulk_builder.rb#L52 where we don't pass @fields option.Expected behavior
crutch execution should respect :update_fields option.
Actual behavior
crutch is executed regardless :update_fields option
Steps to reproduce the problem
call from the console
look at logs and confirm that
drivers
crutch SQL call has been madeVersion Information
Share here essential version information such as: