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

Is present and Is blank filter #1099

Closed
kweejibow opened this issue Apr 25, 2012 · 9 comments
Closed

Is present and Is blank filter #1099

kweejibow opened this issue Apr 25, 2012 · 9 comments

Comments

@kweejibow
Copy link

Apologies in advance I'm quite new to rails and rails_admin.

Seem like the 'Is Present' and 'Is blank' column filters fail for any boolean value

It also fails when checking against the integer value of a FK object.

To better explain: I have a relationship between Client and Appointment, in my appointment list I include the field :client <-- where some automagick seems to display the clients name and create a link to that object. I can use all the other filters on the :client field just fine but if i try and check on Is Present or Is Blank the sql generated seems to try and check if client_id is not null and client_id != '' <-- which I believe is the issue.

Thanks!

@mshibuya
Copy link
Member

Merging this into #1114.

@nroose
Copy link
Contributor

nroose commented Aug 15, 2012

Part of this issue is related to 1114, but not the boolean part. The fact is that the filter on boolean columns includes the is present and is blank entries on the list, but they cause a postgres error.

@mshibuya
Copy link
Member

I know it, of course :)
My intention is that these tasks can be combined in that both of two require capability to build database column type sensitive SQL query in RailsAdmin ActiveRecord adapter.

@nicolasfranck
Copy link

The issue still exists in rails_admin/adapters/active_record.rb:

def unary_operators
          {
            '_blank' => ["(#{@column} IS NULL OR #{@column} = '')"],
            '_present' => ["(#{@column} IS NOT NULL AND #{@column} != '')"],
            '_null' => ["(#{@column} IS NULL)"],
            '_not_null' => ["(#{@column} IS NOT NULL)"],
            '_empty' => ["(#{@column} = '')"],
            '_not_empty' => ["(#{@column} != '')"]
          }
end

The line with '_present' leads to the postgres error:

ERROR:  invalid input syntax for type boolean

Reason: a column of type boolean is compared with an empty string.

@eminnett
Copy link

eminnett commented Apr 7, 2014

I can also replicate this issue. I may end up removing the options with JS which is a pretty dirty and unfortunate hack.

@nlsrchtr
Copy link

nlsrchtr commented May 4, 2015

This is still relevant in 0.6.7. Is there some work going into the Postgres specifics?

@coorasse
Copy link
Contributor

coorasse commented Jun 3, 2015

This error still exists. please reopen the issue.

@jhilden
Copy link

jhilden commented Aug 4, 2015

also still having the issue with 0.6.8

@hasan-aa
Copy link

No fix yet? Same issue exists with 0.8.1

HashNotAdam pushed a commit to HashNotAdam/rails_admin that referenced this issue Jul 25, 2016
Filtering a boolean field on "Is present" or "Is blank" produces SQL that
includes checking against an empty string. Since a boolean field can only be
true, false, or null, this causes errors in some databases.

This commit removes the empty string search for boolean field types.
HashNotAdam pushed a commit to HashNotAdam/rails_admin that referenced this issue Jul 29, 2016
Filtering a boolean field on "Is present" or "Is blank" produces SQL that
includes checking against an empty string. Since a boolean field can only be
true, false, or null, this causes errors in some databases.

This commit removes the empty string search for boolean field types.
mshibuya added a commit that referenced this issue Aug 22, 2016
…ng_on_boolean_columns

Issue #1099: Filtering on "Is present" and "Is blank" on boolean columns
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

9 participants