I am having issues making an ActiveRecord query in Ruby on Rails that gives me back all users, whose blocked_dates (autogenerated string value) do not intersect with the formatted_dates (autogenerated string value) of a given event.
The problem I'm having is that, for example:
User.where.not("string_to_array(blocked_dates, ',') && string_to_array(?, ',')", "26.12.2015")
Gives back an empty list, whereby:
User.where("string_to_array(blocked_dates, ',') && string_to_array(?, ',')", "26.12.2015")
Gives back the correct users whose blocked_dates actually contain '26.12.2015'.
Is there a reason for this strange behavior? Or does the Postgres overlap operator && not work in conjunction with NOT?
In case the question arises, here is the generated SQL query:
SELECT "users".* FROM "users"  WHERE (NOT (string_to_array(blocked_dates, ',') && string_to_array('26.12.2015', ',')))
 
     
    