Skip to content

Require Ransack 6 and keep searches case-insensitive - #6745

Open
scarroll32 wants to merge 1 commit into
solidusio:mainfrom
scarroll32:ransack-6
Open

scarroll32 wants to merge 1 commit into
solidusio:mainfrom
scarroll32:ransack-6

Conversation

@scarroll32

@scarroll32 scarroll32 commented Nov 20, 2026 •

Copy link
Copy Markdown

Summary

Hi! I'm one of the Ransack maintainers. solidus_core pins ransack ["~> 4.0", "< 5"], so Solidus stores can't upgrade to Ransack 5 or 6. This PR moves Solidus to Ransack 6. Tracked in activerecord-hackery/ransack#1810.

Why it's not just a version bump: Ransack 6.0 made cont, start and end case-sensitive on PostgreSQL (LIKE instead of ILIKE); see the upgrade guide. Solidus's admin, backend and API searches use those predicates in about 130 places. Raising the cap alone would quietly make every PostgreSQL store's admin search case-sensitive. For example, the admin feature specs that filter return reasons by reason stop finding "Good Reason".

What changes:

  • Every cont and start search becomes i_cont and i_start: admin index search keys, backend filters and pickers, the backend SearchController and TaxonsController, Spree::Core::Search::Variant, the promotions filters, and the JavaScript that builds q[...] params. These keep the current behaviour on every database. On MySQL and SQLite, LIKE follows the column collation, as before.
  • ransack becomes [">= 6.0", "< 7"]. i_start only exists from Ransack 6.0, so Ransack 6 has to be the minimum. 6.0 supports Ruby 3.2 and Rails 7.2, so Solidus drops no Ruby or Rails version. Bundler picks 6.0.x on Rails 7.2 and 8.0, and 6.1.x on Rails 8.1.
  • with_all_variant_sku_cont and with_kept_variant_sku_cont are Solidus's own product scopes built on Arel's matches, which is already case-insensitive, so they're unchanged.
  • The OpenAPI filtering guide now uses name_i_cont and explains the difference.
  • Adds a spec that searches admin users by an upper-cased email prefix.

For stores: API clients and custom code that send cont or start will be case-sensitive on PostgreSQL once Ransack 6 is installed, and should switch to the i_ forms. Ransack 5 and 6 have other behaviour changes too (see the upgrade guide). None of them affected Solidus's specs, but they're worth calling out in the release notes. ransack-enum 1.0 uses only ransacker and Ransack::Nodes::Value#cast, which are unchanged.

Tested locally on PostgreSQL:

Rails 8.1, Ransack 6.1.1 Rails 7.2, Ransack 6.0.1
core 4510 examples, 0 failures search, product and variant specs: 154, 0 failures
api 716, 0 failures 676, 0 failures
backend 793, 0 failures controllers and search feature specs: 438, 0 failures
admin 725, 0 failures* features and requests: 552, 0 failures
promotions 1145, 0 failures not run
legacy_promotions 818, 0 failures not run

* The first admin run had 9 failures, from feature specs whose URL-encoded queries (q%5Bname_cont%5D=reason) still used cont. Those queries now use i_cont, and the affected files pass (56 examples, 0 failures).

Checklist

Check out our PR guidelines for more details.

The following are mandatory for all PRs:

The following are not always needed:

  • 📖 I have updated the README to account for my changes.
  • 📑 I have documented new code with YARD.
  • 🛣️ I have opened a PR to update the guides.
  • ✅ I have added automated tests to cover my changes.
  • 📸 I have attached screenshots to demo visual changes.

🤖 Generated with Claude Code

Ransack 6.0 made `cont`, `start` and `end` case-sensitive on PostgreSQL:
they now generate LIKE instead of ILIKE. The admin, backend and API
searches all used them, so on PostgreSQL searching for "reason" would stop
finding "Good Reason". MySQL and SQLite are unaffected, as their LIKE
follows the column collation.

Switch every `cont` and `start` search to `i_cont` and `i_start`, which
keep the previous behaviour on every database. `i_start` only exists from
Ransack 6.0, so Ransack 6 becomes the minimum. Ransack 6.0 supports Ruby
3.2 and Rails 7.2, Solidus's own minimums; Bundler picks 6.1 on Rails 8.1.

The `with_all_variant_sku_cont` and `with_kept_variant_sku_cont` product
scopes are left as they are: they are Solidus scopes built on Arel's
`matches`, which is already case-insensitive.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added changelog:solidus_api Changes to the solidus_api gem changelog:solidus_backend Changes to the solidus_backend gem changelog:solidus_core Changes to the solidus_core gem changelog:solidus_admin changelog:solidus_legacy_promotions Changes to the solidus_legacy_promotions gem changelog:solidus_promotions Changes to the solidus_promotions gem labels Nov 20, 2026
@scarroll32
scarroll32 marked this pull request as ready for review November 20, 2026 10:56
@scarroll32
scarroll32 requested a review from a team as a code owner November 20, 2026 10:56
@jarednorman

Copy link
Copy Markdown
Member

Thank you for this!

@codecov

codecov Bot commented Nov 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 92.68%. Comparing base (b1e1977) to head (1fb6020).

Files with missing lines Patch % Lines
...d/app/controllers/spree/admin/taxons_controller.rb 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6745   +/-   ##
=======================================
  Coverage   92.68%   92.68%           
=======================================
  Files        1083     1083           
  Lines       22018    22018           
=======================================
  Hits        20407    20407           
  Misses       1611     1611           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jarednorman jarednorman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks again for doing this. @solidusio/core-team has some things to think about regarding how we roll this out. If merged, upgrading to Solidus 4.9 will force everyone to jump to major Ransack versions. That's not necessarily a problem, but it means we need to make sure the following gems with include affected Ransack params are ready to handle this update:

  • solidus_subscriptions (user_email_cont)
  • solidus_reviews (name_cont, title_cont, review_cont)
  • solidus_virtual_gift_card (redemption_code_cont, recipient_email_cont, order_number_cont)
  • solidus_gdpr (email_start)
  • technically solidus_graphql_api, but that's not maintained and should probably be archived. I don't know of any stores using it.

We can take on this work, but it'll require a little coordination on our side.

The only gotcha with the PR itself I found was that MySQL and SQLite SQL does change, contrary to the description. On non-PostgreSQL dialects, Ransack 6 renders i_start as LOWER(col) LIKE 'x%' (ransack-6.0.1/lib/ransack/nodes/condition.rb:357). The old number_start/email_start produced col LIKE 'x%', which can use an index. That affects:

  • the backend order filters (backend_configuration.rb:65-86);
  • the user pickers (backend/app/controllers/spree/admin/search_controller.rb:16).

On large MySQL stores these become full scans. Columns with a case-sensitive collation also start matching case-insensitively. Not ideal, but maybe we just have to live with that and stores can customize if it's a perf issue for them?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog:solidus_admin changelog:solidus_api Changes to the solidus_api gem changelog:solidus_backend Changes to the solidus_backend gem changelog:solidus_core Changes to the solidus_core gem changelog:solidus_legacy_promotions Changes to the solidus_legacy_promotions gem changelog:solidus_promotions Changes to the solidus_promotions gem

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants