Commit 58af0f694baeca9e2e6b28a758c950894dc9078d

Authored by Andrew Kane
1 parent 5f145277

Fixed reindex async for non-numeric primary keys in Postgres - fixes #983

Showing 2 changed files with 8 additions and 1 deletions   Show diff stats
CHANGELOG.md
... ... @@ -7,6 +7,7 @@
7 7 - Raise error for `reindex_status` when Redis not configured
8 8 - Warn when incompatible options used with `body` option
9 9 - Fixed bug where `routing` and `type` options were silently ignored with `body` option
  10 +- Fixed `reindex(async: true)` for non-numeric primary keys in Postgres
10 11  
11 12 ## 2.3.1
12 13  
... ...
lib/searchkick/index.rb
... ... @@ -446,7 +446,13 @@ module Searchkick
446 446 # TODO expire Redis key
447 447 primary_key = scope.primary_key
448 448  
449   - starting_id = scope.minimum(primary_key)
  449 + starting_id =
  450 + begin
  451 + scope.minimum(primary_key)
  452 + rescue ActiveRecord::StatementInvalid
  453 + false
  454 + end
  455 +
450 456 if starting_id.nil?
451 457 # no records, do nothing
452 458 elsif starting_id.is_a?(Numeric)
... ...