Skip to content

[MODEL] Do not override existing methods #936

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

Merged
merged 2 commits into from
Aug 19, 2020

Conversation

michaelmcchen
Copy link
Contributor

@michaelmcchen michaelmcchen commented Apr 22, 2020

This PR reverts the line from this commit: https://github.com/elastic/elasticsearch-rails/pull/893/files to address the issue described here #924

My biggest concern is that this is a very subtle change in behavior that could lead to bugs, especially in a project where custom methods with similar names (import, search, etc.) are defined. It seems safer to keep the existing behavior (pre 7.x.x elasticsearch-rails) and force users who are facing this sort of conflict to be more explicit about their method choice (via ModelName.__elasticsearch__.method())

@cla-checker-service
Copy link

cla-checker-service bot commented Apr 22, 2020

💚 CLA has been signed

@michaelmcchen
Copy link
Contributor Author

Agreement review in progress, just wanted to put up this PR in the meantime

@michaelmcchen
Copy link
Contributor Author

A rep from my company signed the CLA (via Docusign), and included my name & Github handle in the company agreement. I think the bot doesn't take that into account, hence the failure

@picandocodigo (tagging you because you recently released a new version of this gem), do you think you could help me route this PR to the right folks for review? I appreciate it!

@picandocodigo
Copy link
Member

picandocodigo commented May 5, 2020

Hi @michaelmcchen, thanks for this contribution! I'll take a look at it tomorrow soon 👍

@greenonion
Copy link

Hi, we're in the process of changing our codebase so we can upgrade our clusters to ES 7x and we've stumbled on this as well. Can we expect this PR to be merged?

Also to address @michaelmcchen 's concern, I think this behavior should probably have some unit tests to help avoid any regressions :/

@picandocodigo
Copy link
Member

I'll bump the priority on this issue and let you know about a future release 👍

@greenonion
Copy link

@picandocodigo thank you very much! If you'd like we could maybe try to write some tests too!

@picandocodigo
Copy link
Member

@greenonion definitely, some tests would really help. Thanks!

@michaelmcchen michaelmcchen force-pushed the undo-es-models-priority branch from affa0cb to a2c2950 Compare July 11, 2020 17:52
@michaelmcchen
Copy link
Contributor Author

michaelmcchen commented Jul 11, 2020

Also to address @michaelmcchen 's concern, I think this behavior should probably have some unit tests to help avoid any regressions :/

Agreed! I've updated an existing spec to cover this case and tested it out by reverting my original commit (which now fails the spec). @greenonion @picandocodigo

@@ -48,6 +48,7 @@ def self.search(query, options={})
end

DummyIncludingModel.__send__ :include, Elasticsearch::Model
DummyIncludingModelWithSearchMethodDefined.__send__ :include, Elasticsearch::Model

Choose a reason for hiding this comment

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

Ah so there was a test for this (line 71) but it wasn't actually set up correctly. Nice!

papanikge pushed a commit to skroutz/elasticsearch-rails that referenced this pull request Jul 15, 2020
papanikge pushed a commit to skroutz/elasticsearch-rails that referenced this pull request Jul 16, 2020
@picandocodigo picandocodigo merged commit 10ed5ca into elastic:master Aug 19, 2020
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.

3 participants