Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rake chewy:sync should work for complex "outdated_sync_field" values #934

Open
lfv89 opened this issue Apr 1, 2024 · 2 comments
Open

Rake chewy:sync should work for complex "outdated_sync_field" values #934

lfv89 opened this issue Apr 1, 2024 · 2 comments

Comments

@lfv89
Copy link

lfv89 commented Apr 1, 2024

Expected behavior

If an outdated_sync_field do not have a simple value, it should still be possible to use chewy:sync on that index.

Actual behavior

If one defines an index with an updated_at similar to this one:

    field :updated_at, type: :date, value: ->(obj) do
      [obj.updated_at, obj.obj2.updated_at].compact.max
    end

Then chewy:sync will fail because inside supports_outdated_sync?:

        def supports_outdated_sync?
          updated_at_field = root.child_hash[outdated_sync_field] if outdated_sync_field
          !!updated_at_field && updated_at_field.value.nil?
        end

The condition updated_at_field.value.nil? will always be false since a proc is being used.

Steps to reproduce the problem

Run rake chewy:sync on a index that defines the value of updated_at as a proc.

Version Information

Share here essential version information such as:

  • Chewy version 7.3.4
  • Elasticsearch version
  • Ruby version 3.3
  • Rails version 7.0
@lfv89
Copy link
Author

lfv89 commented Apr 1, 2024

I would gladly jump on this if a maintainer could give me a few pointers to start with.

@lfv89
Copy link
Author

lfv89 commented Apr 5, 2024

@sasha370 @AlexDavidoiu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant