Delegate to_s to terms
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user