Sha256: f749d1b79c3ec772559de55ce32ea6a45f33689921db28ad1fd258921d9d1517

Contents?: true

Size: 580 Bytes

Versions: 1

Compression:

Stored size: 580 Bytes

Contents

module FilterParam
  module Operators
    class Present < FieldFilterOperator
      operator_tag :pr

      def self.sql(field)
        return "#{field.actual_name} IS NOT NULL" unless field.type == :string

        "(#{field.actual_name} IS NOT NULL AND TRIM(#{field.actual_name}) != '')"
      end

      def self.negated_sql(field)
        return "#{field.actual_name} IS NULL" unless field.type == :string

        "(#{field.actual_name} IS NULL OR TRIM(#{field.actual_name}) = '')"
      end
    end
  end
end

FilterParam::Operator.register(FilterParam::Operators::Present)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
filter_param-0.1.2 lib/filter_param/operators/present.rb