thiagopradi / octopus

Database Sharding for ActiveRecord
2.53k stars 504 forks source link

Comparison In Octopus Inspects Current Shard #446

Open spencerneste opened 7 years ago

spencerneste commented 7 years ago

What is the purpose of inspecting the current_shard when comparing two objects? https://github.com/thiagopradi/octopus/blob/master/lib/octopus/model.rb#L34

We are using Octopus and are getting failed comparison for the same objects. For example

Foo.where(id: 1) | Foo.using(:slave).where(id: 1)

will return an array containing the same record twice. What is the reasoning behind wanting to know which shard the query was run on and why does that influence comparison? If this is a feature it would be great if it were opt in or opt out, but if there isn't a reason then I am happy to make a PR and remove it, since it is preventing us from using Octopus at full capacity.

jughead commented 7 years ago

+1

thiagopradi commented 7 years ago

Hi @spencerneste / @jughead ,

Yes, this is a feature - it is actually useful for a few use cases. but, I agree, we should have a configuration to opt-in or out of it.

Can you provide a PR adding a configuration key for it? We might even disable it by default.

Thiago