Permalink
Browse files

Disable eager loading, fixes #14

Eager loading doesn't work because of the way pg_search_rank is added
into the SELECT for the query.
  • Loading branch information...
1 parent 170d06a commit 47b2a0b3f5789e581c3c946efa71cdaf7eb69b8a @nertzy nertzy committed Apr 2, 2013
Showing with 13 additions and 1 deletion.
  1. +13 −1 lib/pg_search/scope_options.rb
@@ -13,7 +13,19 @@ def initialize(config)
end
def apply(scope)
- scope.select("#{quoted_table_name}.*, (#{rank}) AS pg_search_rank").where(conditions).order("pg_search_rank DESC, #{order_within_rank}").joins(joins)
+ scope.
+ select("#{quoted_table_name}.*, (#{rank}) AS pg_search_rank").
+ where(conditions).
+ order("pg_search_rank DESC, #{order_within_rank}").
+ joins(joins).
+ extend(DisableEagerLoading)
+ end
+
+ # workaround for https://github.com/Casecommons/pg_search/issues/14
+ module DisableEagerLoading
+ def eager_loading?
+ return false
+ end
end
private

0 comments on commit 47b2a0b

Please sign in to comment.