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

Add __eq__ method for Index instances #311

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

fullonic
Copy link

Fix #258

This issue happens because new_indexes.difference(old_indexes) [code] and old_indexes.difference(new_indexes) [code] returns always all indexes, even when they are equal.

This PR fixes this by adding the __eq__ to all Index instances. To ensure that indexes are equal we compare them using the __hash__ method.

).hexdigest()
def add_hash_eq_methods_to_index(idx):
def _hash(self):
return hash(self.index_name(cls.ddl.schema_generator, model).encode() + self.__class__.__name__.encode())
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@long2ice these hash arguments are enough to ensure that every change in the index configuration will generate a different one?

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

Successfully merging this pull request may close these issues.

New migration file on migrate for Indexes defined on a Model.
1 participant