class ActiveRecord::Relation::QueryAttribute

def nil?

def nil?
  unless value_before_type_cast.is_a?(StatementCache::Substitute)
    value_before_type_cast.nil? ||
      (type.respond_to?(:subtype) || type.respond_to?(:normalizer)) && serializable? && value_for_database.nil?
  end
end