jbox-web / ajax-datatables-rails

A wrapper around DataTable's ajax methods that allow synchronization with server-side pagination in a Rails app
MIT License
584 stars 228 forks source link

Searching on a text field does not work #377

Closed snex closed 3 years ago

snex commented 3 years ago

When searching on a text field, using the default conditions, I get the following error:

ActiveRecord::StatementInvalid (PG::UndefinedObject: ERROR:  type "VARCHAR" does not exist

The full query being generated is:

SELECT
  COUNT(*)
FROM
  (
    SELECT
      DISTINCT "hand_histories"."id"
    FROM
      "hand_histories"
      INNER JOIN "hands" ON "hands"."id" = "hand_histories"."hand_id"
      INNER JOIN "positions" ON "positions"."id" = "hand_histories"."position_id"
      INNER JOIN "bet_sizes" ON "bet_sizes"."id" = "hand_histories"."bet_size_id"
      INNER JOIN "table_sizes" ON "table_sizes"."id" = "hand_histories"."table_size_id"
    WHERE
      CAST("hand_histories"."note" AS "VARCHAR") ILIKE '%man%'
  ) subquery_for_count

If I copy the query directly into psql console, I get the same error. If I remove the quote marks around "VARCHAR" then it works. These quote marks seem to be the problem.

snex commented 3 years ago

Issue appears to be caused by arel_extensions gem (https://github.com/Faveod/arel-extensions/).