Module: Veritas::SQL::Generator::Function::Predicate

Includes:
Veritas::SQL::Generator::Function
Included in:
Relation::Unary
Defined in:
lib/veritas/sql/generator/function/predicate.rb

Overview

Generates an SQL statement for a predicate function

Constant Summary collapse

EQUAL_TO =
'='.freeze
EQUAL_TO_NULL =
'IS'.freeze
NOT_EQUAL_TO =
'<>'.freeze
NOT_EQUAL_TO_NULL =
'IS NOT'.freeze
GREATER_THAN =
'>'.freeze
GREATER_THAN_OR_EQUAL_TO =
'>='.freeze
LESS_THAN =
'<'.freeze
LESS_THAN_OR_EQUAL_TO =
'<='.freeze
IN =
'IN'.freeze
NOT_IN =
'NOT IN'.freeze
BETWEEN =
'BETWEEN'.freeze
NOT_BETWEEN =
'NOT BETWEEN'.freeze
EMPTY_ARRAY =
[].freeze

Constants included from Identifier

Identifier::ESCAPED_QUOTE, Identifier::QUOTE

Constants included from Literal

Literal::ESCAPED_QUOTE, Literal::FALSE, Literal::NULL, Literal::QUOTE, Literal::SEPARATOR, Literal::TIME_SCALE, Literal::TRUE

Instance Method Summary collapse

Methods included from Attribute

#visit_veritas_attribute

Methods included from Identifier

#visit_identifier

Methods included from Literal

dup_frozen, #visit_class, #visit_date, #visit_date_time, #visit_enumerable, #visit_false_class, #visit_nil_class, #visit_numeric, #visit_string, #visit_time, #visit_true_class

Instance Method Details

#visit_veritas_function_predicate_equality(equality) ⇒ #to_s

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Visit an Equality predicate

Parameters:

  • equality (Function::Predicate::Equality)

Returns:

  • (#to_s)


33
34
35
# File 'lib/veritas/sql/generator/function/predicate.rb', line 33

def visit_veritas_function_predicate_equality(equality)
  binary_infix_operation_sql(equality.right.nil? ? EQUAL_TO_NULL : EQUAL_TO, equality)
end

#visit_veritas_function_predicate_exclusion(exclusion) ⇒ #to_s

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Visit an Exclusion predicate

Parameters:

  • exclusion (Function::Predicate::Exclusion)

Returns:

  • (#to_s)


116
117
118
119
120
121
122
123
# File 'lib/veritas/sql/generator/function/predicate.rb', line 116

def visit_veritas_function_predicate_exclusion(exclusion)
  case exclusion.right
  when Range       then range_exclusion_sql(exclusion)
  when EMPTY_ARRAY then TRUE
  else
    binary_infix_operation_sql(NOT_IN, exclusion)
  end
end

#visit_veritas_function_predicate_greater_than(greater_than) ⇒ #to_s

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Visit an GreaterThan predicate

Parameters:

  • greater_than (Function::Predicate::GreaterThan)

Returns:

  • (#to_s)


56
57
58
# File 'lib/veritas/sql/generator/function/predicate.rb', line 56

def visit_veritas_function_predicate_greater_than(greater_than)
  binary_infix_operation_sql(GREATER_THAN, greater_than)
end

#visit_veritas_function_predicate_greater_than_or_equal_to(greater_than_or_equal_to) ⇒ #to_s

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Visit an GreaterThanOrEqualTo predicate

Parameters:

  • greater_than_or_equal_to (Function::Predicate::GreaterThanOrEqualTo)

Returns:

  • (#to_s)


67
68
69
# File 'lib/veritas/sql/generator/function/predicate.rb', line 67

def visit_veritas_function_predicate_greater_than_or_equal_to(greater_than_or_equal_to)
  binary_infix_operation_sql(GREATER_THAN_OR_EQUAL_TO, greater_than_or_equal_to)
end

#visit_veritas_function_predicate_inclusion(inclusion) ⇒ #to_s

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Visit an Inclusion predicate

Parameters:

  • inclusion (Function::Predicate::Inclusion)

Returns:

  • (#to_s)


100
101
102
103
104
105
106
107
# File 'lib/veritas/sql/generator/function/predicate.rb', line 100

def visit_veritas_function_predicate_inclusion(inclusion)
  case inclusion.right
  when Range       then range_inclusion_sql(inclusion)
  when EMPTY_ARRAY then FALSE
  else
    binary_infix_operation_sql(IN, inclusion)
  end
end

#visit_veritas_function_predicate_inequality(inequality) ⇒ #to_s

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Visit an Inequality predicate

Parameters:

  • inequality (Function::Predicate::Inequality)

Returns:

  • (#to_s)


44
45
46
47
# File 'lib/veritas/sql/generator/function/predicate.rb', line 44

def visit_veritas_function_predicate_inequality(inequality)
  expressions = inequality_expressions(inequality)
  expressions.one? ? expressions.first : Generator.parenthesize!(expressions.join(' OR '))
end

#visit_veritas_function_predicate_less_than(less_than) ⇒ #to_s

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Visit an LessThan predicate

Parameters:

  • less_than (Function::Predicate::LessThan)

Returns:

  • (#to_s)


78
79
80
# File 'lib/veritas/sql/generator/function/predicate.rb', line 78

def visit_veritas_function_predicate_less_than(less_than)
  binary_infix_operation_sql(LESS_THAN, less_than)
end

#visit_veritas_function_predicate_less_than_or_equal_to(less_than_or_equal_to) ⇒ #to_s

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Visit an LessThanOrEqualTo predicate

Parameters:

  • less_than_or_equal_to (Function::Predicate::LessThanOrEqualTo)

Returns:

  • (#to_s)


89
90
91
# File 'lib/veritas/sql/generator/function/predicate.rb', line 89

def visit_veritas_function_predicate_less_than_or_equal_to(less_than_or_equal_to)
  binary_infix_operation_sql(LESS_THAN_OR_EQUAL_TO, less_than_or_equal_to)
end