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
- Add a column to existing table with
uuid type but without null: false constraint
- Go to admin panel, list view, search by this column using
is present/is blank filter.
- 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
Describe the bug
When filtering the records in the list view for table where column has an
:uuidtype of column and usingis present/is blankfilters it raises an exception:Reproduction steps
uuidtype but withoutnull: falseconstraintis present/is blankfilter.Expected behavior
When building a query, instead of:
use just:
Additional context
railsversion:7.0.5.1rails_adminversion: 3.1.2rails_adminnpm package version:It can be easily fixed by adjusting the following file:
lib/rails_admin/adapters/active_record.rb