-
Notifications
You must be signed in to change notification settings - Fork 50
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
Ability to preserve primary key type #390
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about this change to be honest, it seems like a lot of complexity, and like you said it's hard to test thoroughly. I see that you did a lot of work toward this, but I feel that this gem is messy to begin with and the added if
s would not help in that regard...
I'll leave it to @brunoocasali to decide if we should go in this direction.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #390 +/- ##
==========================================
- Coverage 89.13% 88.53% -0.61%
==========================================
Files 13 13
Lines 764 776 +12
==========================================
+ Hits 681 687 +6
- Misses 83 89 +6 ☔ View full report in Codecov by Sentry. |
11db591
to
e4f29b1
Compare
e4f29b1
to
62c27ed
Compare
It didn't take that much of my time really, so no worries if it doesn't get merged — at least it will give some context to people who might experience the same issue. It is possible to overcome it by putting an id in a separate custom attribute (those don't get stringified and remain integers, so will sort correctly). As far as I see, the whole stringified primary key came from Algolia, which I assume doesn't support integer primary keys. But since MeiliSearch itself has both string and integer in the spec for primary keys, I think it's better to have framework implementation match the spec. Full test suite can be ran twice by doing two rspec calls with different config, and all tests must pass with this setting on and off, I can add that to github workflow. And I can refactor it a bit to reduce the number of |
Pull Request
According to MeiliSearch docs
However, currently meilisearch-rails always stringifies primary keys before sending them to MeiliSearch. As a result, sorting by primary key becomes impossible, because hits will be sorted alphabetically:
What does this PR do?
Ideally full test suite will have to be ran twice, with this config set to true and false; I did so manually when submitting this PR. But I wasn't sure if this PR will be considered so didn't expand specs, other than adding a test which confirms that primary-key-sorted docs will preserve order.
PR checklist
Please check if your PR fulfills the following requirements: