Hello, I have an UUID column as ID column. When I do:
Campaign.search(id_cont: 'abc').result
I get this error:
HINT: No operator matches the given name and argument type(s).
You might need to add explicit type casts.
SELECT "campaigns".* FROM "campaigns" WHERE "campaigns"."pro_user_id" = $1
AND "campaigns"."aasm_state" = 'drafted'
AND ("campaigns"."id" ILIKE NULL)
ORDER BY "campaigns"."created_at" DESC
LIMIT 25
OFFSET 0
PG::UndefinedFunction: ERROR: operator does not exist: uuid ~~* unknown
LINE 1: ...s"."aasm_state" = 'drafted' AND ("campaigns"."id" ILIKE NULL...
Any idea? Thanks.
Hello @zenati, to help people help you, could you provide a gist to reproduce your issue?
Please see CONTRIBUTING.md file for more information and a bug report template.
Stalled. Closing for now.
same issue here. the IDs in the tables are not of type Integer, they are UUIDs. When passing the ids to ransacker, it tries to find the objects with 'ILIKE' method, instead of simple 'IN'
Here's a solution:
module RansackUUIDHelper
extend ActiveSupport::Concern
included do
ransacker :id do
Arel.sql("\"#{table_name}\".\"id\"::varchar")
end
end
end
All you need to do then is include RansackUUIDHelper in your model.
Most helpful comment
Here's a solution:
All you need to do then is
include RansackUUIDHelperin your model.