Skip to content

A platform for community discussion. Free, open, simple.

FIX: searching for bookmarks with : resulted in error (#35850)

Sam65860073b27a
diff --git a/app/services/registered_bookmarkable.rb b/app/services/registered_bookmarkable.rb
index 0c1b145a336..3591e784464 100644
--- a/app/services/registered_bookmarkable.rb
+++ b/app/services/registered_bookmarkable.rb
@@ -41,7 +41,7 @@ class RegisteredBookmarkable
# See BaseBookmarkable#search_query for argument docs.
def perform_search_query(bookmarks, query, ts_query)
bookmarkable_klass.search_query(bookmarks, query, ts_query) do |bookmarks_joined, where_sql|
- bookmarks_joined.where("#{where_sql} OR bookmarks.name ILIKE :q", q: query)
+ bookmarks_joined.where("#{where_sql} OR bookmarks.name ILIKE ?", query)
end
end
diff --git a/spec/lib/bookmark_query_spec.rb b/spec/lib/bookmark_query_spec.rb
index ec5af4d61dd..ea0a6791049 100644
--- a/spec/lib/bookmark_query_spec.rb
+++ b/spec/lib/bookmark_query_spec.rb
@@ -81,10 +81,19 @@ RSpec.describe BookmarkQuery do
Fabricate(:bookmark, user: user, name: "Check up later", bookmarkable: Fabricate(:post))
end
let(:bookmark4) { Fabricate(:bookmark, user: user, bookmarkable: post) }
+ let!(:bookmark_with_colon) do
+ Fabricate(
+ :bookmark,
+ user: user,
+ name: "Review with:images filter",
+ bookmarkable: Fabricate(:post),
+ )
+ end
before do
Fabricate(:topic_user, user: user, topic: bookmark3.bookmarkable.topic)
Fabricate(:topic_user, user: user, topic: bookmark4.bookmarkable.topic)
+ Fabricate(:topic_user, user: user, topic: bookmark_with_colon.bookmarkable.topic)
end
it "can search by bookmark name" do
@@ -102,6 +111,11 @@ RSpec.describe BookmarkQuery do
expect(bookmarks.map(&:id)).to eq([bookmark4.id])
end
+ it "allows searching when the search term contains a colon" do
+ bookmarks = bookmark_query(search_term: "with:images").list_all
+ expect(bookmarks.map(&:id)).to eq([bookmark_with_colon.id])
+ end
+
context "with custom bookmarkable fitering" do
before { register_test_bookmarkable }