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

Deprecate camel case attributes #377

Closed
wants to merge 8 commits into from

Conversation

jmks
Copy link
Contributor

@jmks jmks commented Oct 20, 2022

Pull Request

Related issue

Fixes #320

What does this PR do?

When calling index#search with non-snake case attributes (e.g. camelCase or weirdMixed_Case) a warning is emitted (to stderr). Here's an example:

Attributes will be expected to be snake_case in future versions of MeiliSearch.

Non-conforming attributes: attributesToHighlight

I have a few questions:

  1. Which attributes?

The issue mentioned sending the search attributes. Do you want this deprecation warning for just index#search or all methods (i.e. any caller of Utils.transform_attributes)?

Currently this just handles index#search but should be easy adapt for all callers.

  1. The deprecation warning message

I wrote something I would like to see but I'm open to suggestions.

  1. Utils.transform_attributes handles an Array argument.

I ran the test suite and did not find an example of an array passed to this function. Do you know when this could be called with an Array argument?

  1. I didn't see any examples in .code-samples.meilisearch.yml that needed changing (again, only for index#search).

However, I did update the specs.

Cheers!

PR checklist

Please check if your PR fulfills the following requirements:

  • Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
  • Have you read the contributing guidelines?
  • Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!

@jmks jmks force-pushed the deprecate-camel-case-attributes branch from bf46328 to 0fb81e4 Compare October 20, 2022 00:35
@brunoocasali brunoocasali self-requested a review October 21, 2022 17:36
@brunoocasali brunoocasali added the enhancement New feature or request label Oct 21, 2022
@brunoocasali
Copy link
Member

Hi, @jmks thank you so much for your contribution! It is amazing!

Let's answer your questions:

Which attributes?

I think we can use the same logic for every method that has a transform_attributes call because the transform_attributes is the one responsible for dealing with the possibility of handling snake/camel casing.

The deprecation warning message

I just sent a recommendation because of the Meilisearch name, but it is ok for me.

Utils.transform_attributes handles an Array argument.

Yeah, I didn't have much context of the code when I wrote it in the first place, but today I don't know any use case for that handler. But to be honest this code will be removed in a couple of releases after the next one, because now we will have the deprecation warning :)

brunoocasali
brunoocasali previously approved these changes Oct 21, 2022
Copy link
Member

@brunoocasali brunoocasali left a comment

Choose a reason for hiding this comment

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

@jmks your PR is approved in any case, but I would like to have the warning in every possible use case, so if you could do this change it would be awesome! :D

@brunoocasali
Copy link
Member

This message is sent automatically

Thanks again for contributing to Meilisearch ❤️
If you are participating in Hacktoberfest, and you would like to receive some gift from Meilisearch too, please complete this form.

@brunoocasali
Copy link
Member

Hi, @jmks do you still have time to finish this PR? Otherwise I can do it anyway :)

@jmks
Copy link
Contributor Author

jmks commented Nov 2, 2022

Sorry, didn't mean to sit on this for so long. I did start working on it again today and will update the PR in the next day or so.

@jmks
Copy link
Contributor Author

jmks commented Nov 7, 2022

Hi!

I've updated the all callers of transform_attributes to emit warnings now and updated all the specs to not emit warnings.

But to be honest this code will be removed in a couple of releases after the next one, because now we will have the deprecation warning :)

I'm not sure about that. My impression of this was that in the Ruby code, this is standardizing on snake_case (as per Ruby idiom) but when sending to the Meilisearch server (or receiving responses), the attributes will still be camelCase.

@brunoocasali
Copy link
Member

I continued your work in branch #470

Thank you very much for your work, and sorry for taking that long to make this move.

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

Successfully merging this pull request may close these issues.

Deprecate the usage of the camelCase attributes
3 participants