Closed
Description
I'm using Ransack with a custom is_distinct_from predicate to compare JSONB columns.
Here's ransack configuration:
Ransack.configure do |config|
config.add_predicate(
'jdistinct',
arel_predicate: 'is_distinct_from',
formatter: proc { |v| JSON.parse(v) },
)
end
Expect this query:
(promotion field's data type is jsonb)
Cart.ransack(promotion_jdistinct: '[]').result.to_sql
=> "SELECT "carts".* FROM "carts" WHERE "carts"."promotion" IS DISTINCT FROM '[]'"
But when using Torque, get this query:
Cart.ransack(promotion_jdistinct: '[]').result.to_sql
=> "SELECT "carts".* FROM "carts" WHERE "carts"."promotion" IS DISTINCT FROM ARRAY[]"
This generated SQL is causing errors.
Tried creating the query using Arel, but it's more complex and hoping for a simpler solution.
Having trouble with this. Could you please help me determine if it's a bug or a configuration issue?
Environment:
Ruby: 3.2.2
Rails: 7.0.4
Torque: 3.4.0
Ransack: 3.1.0