diff --git a/CHANGELOG.md b/CHANGELOG.md index dc44329..b1070ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## 5.0.0 (unreleased) - Dropped support for Ruby < 2.6 and Active Record < 5.2 +- Dropped support for NoBrainer and Cequel ## 4.6.3 (2021-11-19) diff --git a/README.md b/README.md index 7c7bd1d..d8826bd 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Plus: - autocomplete - “Did you mean” suggestions - supports many languages -- works with Active Record, Mongoid, and NoBrainer +- works with Active Record and Mongoid Check out [Searchjoy](https://github.com/ankane/searchjoy) for analytics and [Autosuggest](https://github.com/ankane/autosuggest) for query suggestions diff --git a/gemfiles/cequel.gemfile b/gemfiles/cequel.gemfile deleted file mode 100644 index 6707378..0000000 --- a/gemfiles/cequel.gemfile +++ /dev/null @@ -1,9 +0,0 @@ -source "https://rubygems.org" - -gemspec path: ".." - -gem "rake" -gem "minitest", ">= 5" -gem "cequel" -gem "activejob" -gem "redis" diff --git a/gemfiles/nobrainer.gemfile b/gemfiles/nobrainer.gemfile deleted file mode 100644 index c1b0563..0000000 --- a/gemfiles/nobrainer.gemfile +++ /dev/null @@ -1,9 +0,0 @@ -source "https://rubygems.org" - -gemspec path: ".." - -gem "rake" -gem "minitest", ">= 5" -gem "nobrainer", ">= 0.21.0" -gem "activejob" -gem "redis" diff --git a/lib/searchkick.rb b/lib/searchkick.rb index b7bf2b5..c6ca3a4 100644 --- a/lib/searchkick.rb +++ b/lib/searchkick.rb @@ -223,9 +223,6 @@ module Searchkick elsif records.respond_to?(:queryable) # Mongoid 3+ records.queryable.for_ids(ids) - elsif records.respond_to?(:unscoped) && :id.respond_to?(:in) - # Nobrainer - records.unscoped.where(:id.in => ids) elsif records.respond_to?(:key_column_names) records.where(records.key_column_names.first => ids) end diff --git a/lib/searchkick/model.rb b/lib/searchkick/model.rb index fe8d14e..18f04f0 100644 --- a/lib/searchkick/model.rb +++ b/lib/searchkick/model.rb @@ -99,12 +99,6 @@ module Searchkick def should_index? true end unless method_defined?(:should_index?) - - if defined?(Cequel) && self < Cequel::Record && !method_defined?(:destroyed?) - def destroyed? - transient? - end - end end end end diff --git a/lib/searchkick/reindex_v2_job.rb b/lib/searchkick/reindex_v2_job.rb index 03c8bb8..3696305 100644 --- a/lib/searchkick/reindex_v2_job.rb +++ b/lib/searchkick/reindex_v2_job.rb @@ -2,9 +2,7 @@ module Searchkick class ReindexV2Job < ActiveJob::Base RECORD_NOT_FOUND_CLASSES = [ "ActiveRecord::RecordNotFound", - "Mongoid::Errors::DocumentNotFound", - "NoBrainer::Error::DocumentNotFound", - "Cequel::Record::RecordNotFound" + "Mongoid::Errors::DocumentNotFound" ] queue_as { Searchkick.queue_name } diff --git a/lib/searchkick/results.rb b/lib/searchkick/results.rb index c02480d..da44598 100644 --- a/lib/searchkick/results.rb +++ b/lib/searchkick/results.rb @@ -309,16 +309,7 @@ module Searchkick combine_includes(included_relations, options[:includes]) combine_includes(included_relations, options[:model_includes][records]) if options[:model_includes] - records = - if defined?(NoBrainer::Document) && records < NoBrainer::Document - if Gem.loaded_specs["nobrainer"].version >= Gem::Version.new("0.21") - records.eager_load(included_relations) - else - records.preload(included_relations) - end - else - records.includes(included_relations) - end + records = records.includes(included_relations) end if options[:scope_results] diff --git a/test/boost_test.rb b/test/boost_test.rb index bc6040c..79d9083 100644 --- a/test/boost_test.rb +++ b/test/boost_test.rb @@ -171,8 +171,6 @@ class BoostTest < Minitest::Test end def test_boost_by_indices - skip if cequel? - store_names ["Rex"], Animal store_names ["Rexx"], Product diff --git a/test/index_test.rb b/test/index_test.rb index bcc3ad6..e1e40a6 100644 --- a/test/index_test.rb +++ b/test/index_test.rb @@ -87,7 +87,6 @@ class IndexTest < Minitest::Test end def test_large_value - skip if nobrainer? large_value = 1000.times.map { "hello" }.join(" ") store [{name: "Product A", text: large_value}], Region assert_search "product", ["Product A"], {}, Region @@ -97,7 +96,6 @@ class IndexTest < Minitest::Test end def test_very_large_value - skip if nobrainer? large_value = 10000.times.map { "hello" }.join(" ") store [{name: "Product A", text: large_value}], Region assert_search "product", ["Product A"], {}, Region diff --git a/test/inheritance_test.rb b/test/inheritance_test.rb index 83792cc..579a570 100644 --- a/test/inheritance_test.rb +++ b/test/inheritance_test.rb @@ -1,11 +1,6 @@ require_relative "test_helper" class InheritanceTest < Minitest::Test - def setup - skip if cequel? - super - end - def test_child_reindex store_names ["Max"], Cat assert Dog.reindex diff --git a/test/order_test.rb b/test/order_test.rb index 3cb0a2e..f9afaf9 100644 --- a/test/order_test.rb +++ b/test/order_test.rb @@ -14,8 +14,6 @@ class OrderTest < Minitest::Test # TODO no longer map id to _id in Searchkick 5 # since sorting on _id is deprecated in Elasticsearch def test_id - skip if cequel? - store_names ["Product A", "Product B"] product_a = Product.where(name: "Product A").first product_b = Product.where(name: "Product B").first diff --git a/test/reindex_test.rb b/test/reindex_test.rb index 7f8f299..33a3f44 100644 --- a/test/reindex_test.rb +++ b/test/reindex_test.rb @@ -37,8 +37,6 @@ class ReindexTest < Minitest::Test end def test_relation_inline - skip if nobrainer? || cequel? - store_names ["Product A"] store_names ["Product B", "Product C"], reindex: false Product.where(name: "Product B").reindex(refresh: true) @@ -46,8 +44,6 @@ class ReindexTest < Minitest::Test end def test_relation_associations - skip if nobrainer? || cequel? - store_names ["Product A"] store = Store.create!(name: "Test") Product.create!(name: "Product B", store_id: store.id) @@ -56,8 +52,6 @@ class ReindexTest < Minitest::Test end def test_relation_should_index - skip if nobrainer? || cequel? - skip "TODO make pass in Searchkick 5" store_names ["Product A", "Product B"] diff --git a/test/support/cequel.rb b/test/support/cequel.rb deleted file mode 100644 index fc5bd14..0000000 --- a/test/support/cequel.rb +++ /dev/null @@ -1,95 +0,0 @@ -cequel = - Cequel.connect( - host: "127.0.0.1", - port: 9042, - keyspace: "searchkick_test", - default_consistency: :all - ) -cequel.logger = $logger -cequel.schema.drop! if cequel.schema.exists? -cequel.schema.create! -Cequel::Record.connection = cequel - -class Product - include Cequel::Record - - key :id, :uuid, auto: true - column :name, :text, index: true - column :store_id, :int - column :in_stock, :boolean - column :backordered, :boolean - column :orders_count, :int - column :found_rate, :decimal - column :price, :int - column :color, :text - column :latitude, :decimal - column :longitude, :decimal - column :description, :text - column :alt_description, :text - column :created_at, :timestamp -end - -class Store - include Cequel::Record - - key :id, :timeuuid, auto: true - column :name, :text - - # has issue with id serialization - def search_data - { - name: name - } - end -end - -class Region - include Cequel::Record - - key :id, :timeuuid, auto: true - column :name, :text - column :text, :text -end - -class Speaker - include Cequel::Record - - key :id, :timeuuid, auto: true - column :name, :text -end - -class Animal - include Cequel::Record - - key :id, :timeuuid, auto: true - column :name, :text - - # has issue with id serialization - def search_data - { - name: name - } - end -end - -class Dog < Animal -end - -class Cat < Animal -end - -class Sku - include Cequel::Record - - key :id, :uuid - column :name, :text -end - -class Song - include Cequel::Record - - key :id, :timeuuid, auto: true - column :name, :text -end - -[Product, Store, Region, Speaker, Animal, Sku, Song].each(&:synchronize_schema) diff --git a/test/support/nobrainer.rb b/test/support/nobrainer.rb deleted file mode 100644 index a10c19a..0000000 --- a/test/support/nobrainer.rb +++ /dev/null @@ -1,73 +0,0 @@ -NoBrainer.configure do |config| - config.app_name = :searchkick - config.environment = :test -end - -class Product - include NoBrainer::Document - include NoBrainer::Document::Timestamps - - field :id, type: Object - field :name, type: Text - field :in_stock, type: Boolean - field :backordered, type: Boolean - field :orders_count, type: Integer - field :found_rate - field :price, type: Integer - field :color, type: String - field :latitude - field :longitude - field :description, type: String - field :alt_description, type: String - - belongs_to :store, validates: false -end - -class Store - include NoBrainer::Document - - field :id, type: Object - field :name, type: String -end - -class Region - include NoBrainer::Document - - field :id, type: Object - field :name, type: String - field :text, type: Text -end - -class Speaker - include NoBrainer::Document - - field :id, type: Object - field :name, type: String -end - -class Animal - include NoBrainer::Document - - field :id, type: Object - field :name, type: String -end - -class Dog < Animal -end - -class Cat < Animal -end - -class Sku - include NoBrainer::Document - - field :id, type: String - field :name, type: String -end - -class Song - include NoBrainer::Document - - field :id, type: Object - field :name, type: String -end diff --git a/test/test_helper.rb b/test/test_helper.rb index 492bd90..fe3a7c8 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -2,7 +2,6 @@ require "bundler/setup" Bundler.require(:default) require "minitest/autorun" require "minitest/pride" -require "active_support/core_ext" if defined?(NoBrainer) require "active_support/notifications" ENV["RACK_ENV"] = "test" @@ -47,10 +46,6 @@ ActiveSupport::LogSubscriber.logger = ActiveSupport::Logger.new(STDOUT) if ENV[" if defined?(Mongoid) require_relative "support/mongoid" -elsif defined?(NoBrainer) - require_relative "support/nobrainer" -elsif defined?(Cequel) - require_relative "support/cequel" else require_relative "support/activerecord" end @@ -147,14 +142,6 @@ class Minitest::Test defined?(ActiveRecord) end - def nobrainer? - defined?(NoBrainer) - end - - def cequel? - defined?(Cequel) - end - def default_model Product end diff --git a/test/where_test.rb b/test/where_test.rb index f41fd62..d0645e9 100644 --- a/test/where_test.rb +++ b/test/where_test.rb @@ -15,14 +15,11 @@ class WhereTest < Minitest::Test assert_search "product", ["Product A"], where: {user_ids: 2} assert_search "product", ["Product A", "Product C"], where: {user_ids: [2, 3]} - # due to precision - unless cequel? - # date - assert_search "product", ["Product A"], where: {created_at: {gt: now - 1}} - assert_search "product", ["Product A", "Product B"], where: {created_at: {gte: now - 1}} - assert_search "product", ["Product D"], where: {created_at: {lt: now - 2}} - assert_search "product", ["Product C", "Product D"], where: {created_at: {lte: now - 2}} - end + # date + assert_search "product", ["Product A"], where: {created_at: {gt: now - 1}} + assert_search "product", ["Product A", "Product B"], where: {created_at: {gte: now - 1}} + assert_search "product", ["Product D"], where: {created_at: {lt: now - 2}} + assert_search "product", ["Product C", "Product D"], where: {created_at: {lte: now - 2}} # integer assert_search "product", ["Product A"], where: {store_id: {lt: 2}} -- libgit2 0.21.0