Delegate to_s to terms

This commit is contained in:
Donal McBreen
2025-11-21 08:52:55 +00:00
parent ec06b7085b
commit 6dfb961b83
+2 -7
View File
@@ -5,6 +5,8 @@ class Search::Query < ApplicationRecord
validates :terms, presence: true
before_validation :sanitize_terms
delegate :to_s, to: :terms
class << self
def wrap(query)
if query.is_a?(self)
@@ -15,13 +17,6 @@ class Search::Query < ApplicationRecord
end
end
def to_s
# Return unstemmed terms - each adapter handles stemming appropriately:
# - SQLite: FTS5 Porter tokenizer stems automatically
# - MySQL: Search::Record.matching applies stemming
terms.to_s
end
private
def sanitize_terms
self.terms = sanitize(terms)