Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When the column has :uuid type it's not possible to filter list by is present/is_blank filters #3669

Closed
tomajask opened this issue Jan 22, 2024 · 1 comment

Comments

@tomajask
Copy link

Describe the bug
When filtering the records in the list view for table where column has an :uuid type of column and using is present/is blank filters it raises an exception:

ActionView::Template::Error
PG::InvalidTextRepresentation: ERROR:  invalid input syntax for type uuid: "" (ActionView::Template::Error)
LINE 1: ...ND table.column_id != '')) ORDER...

Reproduction steps

  1. Add a column to existing table with uuid type but without null: false constraint
  2. Go to admin panel, list view, search by this column using is present/is blank filter.
  3. It will result in 500 error.

Expected behavior
When building a query, instead of:

WHERE ((table.column_id IS NOT NULL AND table.column_id != ''))

use just:

WHERE (table.column_id IS NOT NULL)

Additional context

  • rails version: 7.0.5.1
  • rails_admin version: 3.1.2
  • rails_admin npm package version:
  • full stack trace (if there's an exception)

It can be easily fixed by adjusting the following file: lib/rails_admin/adapters/active_record.rb

def unary_operators
  case @type
  when :boolean
    boolean_unary_operators
  when :integer, :decimal, :float
    numeric_unary_operators
  when :uuid
    uuid_unary_operators
  else
    generic_unary_operators
  end
end

(...)
alias_method :uuid_unary_operators, :boolean_unary_operators
@tomajask
Copy link
Author

tomajask commented Jan 22, 2024

Ok, now I noticed that the fix is there on master but it was not released yet 🤷🏼
647347c #3629

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant