Skip to content

fix(ruby): Set default hits_per_page for SearchClient#browse_objects using accessor #4253

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

Conversation

dtyoung
Copy link
Contributor

@dtyoung dtyoung commented Dec 17, 2024

🧭 What and Why

SearchClient#browse_objects is attempting to set a default hits_per_page value on browse_params using [] syntax, but Search::BrowseParamsObject doesn't implement the [] method so any call to browse_objects using either the default or a custom BrowseParamsObject param throws an error.

irb(main):001> client = Algolia::SearchClient.create("application_id", "api_key"))
=> #<Algolia::SearchClient:0x00000001674d0f40 ...

irb(main):002> client.browse_objects("index_name")
(irb):2:in `<main>': undefined method `[]' for an instance of Algolia::Search::BrowseParamsObject (NoMethodError)
browse_params[:hits_per_page] = browse_params[:hits_per_page] || 1000

Changes included:

  • Use the setter defined by the hits_per_pageattr_accessor in BrowseParamsObject to set the default value on the provided BrowseParamsObject param.

…using accessor

`[]` access is not defined for the Search::BrowseParamsObject param
@dtyoung dtyoung requested a review from a team as a code owner December 17, 2024 03:07
@dtyoung dtyoung requested review from Fluf22 and shortcuts December 17, 2024 03:07
Copy link
Member

@shortcuts shortcuts left a comment

Choose a reason for hiding this comment

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

thanks a lot!!!!!!!!

@shortcuts shortcuts merged commit 2856fa3 into algolia:main Dec 17, 2024
3 checks passed
algolia-bot added a commit that referenced this pull request Dec 17, 2024
…using accessor (#4253) (generated) [skip ci]

Co-authored-by: Daniel Young <[email protected]>
Co-authored-by: Dan Young <[email protected]>
Co-authored-by: Clément Vannicatte <[email protected]>
algolia-bot added a commit to algolia/algoliasearch-client-ruby that referenced this pull request Dec 17, 2024
…using accessor (generated)

algolia/api-clients-automation#4253

Co-authored-by: algolia-bot <[email protected]>
Co-authored-by: Daniel Young <[email protected]>
Co-authored-by: Dan Young <[email protected]>
Co-authored-by: Clément Vannicatte <[email protected]>
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.

2 participants