Class: Sneaql::Core::Commands::SneaqlTest

Inherits:
SneaqlCommand show all
Defined in:
lib/sneaql_lib/core.rb

Overview

compares the result of a sql statement against an argument raises error if the comparison does not evaluate to true the first field of the first record is used for the comparison

Instance Method Summary collapse

Methods inherited from SneaqlCommand

#initialize, #valid_expression?, #valid_operator?, #valid_recordset?, #valid_symbol?, #valid_variable?, #validate_args

Constructor Details

This class inherits a constructor from Sneaql::Core::SneaqlCommand

Instance Method Details

#action(operator, value_to_test) ⇒ Object

Parameters:

  • operator (String)

    comparison operator supported by expression handler

  • value_to_test (String)

    expression as right operand



148
149
150
151
152
153
154
155
156
157
158
# File 'lib/sneaql_lib/core.rb', line 148

def action(operator, value_to_test)
  unless @expression_handler.compare_expressions(
    operator,
    sql_result,
    value_to_test
  )
    raise Sneaql::Exceptions::SQLTestExitCondition
  end
rescue => e
  @exception_manager.pending_error = e
end

#arg_definitionObject

argument types



161
162
163
# File 'lib/sneaql_lib/core.rb', line 161

def arg_definition
  [:operator, :expression]
end

#sql_resultObject

returns value at first row/field in result set



166
167
168
169
170
171
172
# File 'lib/sneaql_lib/core.rb', line 166

def sql_result
  JDBCHelpers::SingleValueFromQuery.new(
    @jdbc_connection,
    @statement,
    @logger
  ).result
end