class DbFuel::Library::Dbee::Query

Executes a Dbee Query against a Dbee Model and stores the resulting records in the designated payload register.

Expected Payload input: nothing Payload output: array of objects.

Public Class Methods

new( name: '', model: {}, query: {}, register: Burner::DEFAULT_REGISTER, debug: false ) click to toggle source

Arguments:

  • name: Name of job.

  • model: Dbee Model configuration

  • query: Dbee Query configuration

  • register: Name of the register to use for gathering the IN clause values and where

    to store the resulting recordset.
  • debug: If debug is set to true (defaults to false) then the SQL statements

    will be printed in the output.  Only use this option while
    debugging issues as it will fill
    up the output with (potentially too much) data.
Calls superclass method DbFuel::Library::Dbee::Base::new
# File lib/db_fuel/library/dbee/query.rb, line 33
def initialize(
  name: '',
  model: {},
  query: {},
  register: Burner::DEFAULT_REGISTER,
  debug: false
)
  super(
    model: model,
    name: name,
    query: query,
    register: register,
    debug: debug
  )
end

Public Instance Methods

perform(output, payload) click to toggle source
# File lib/db_fuel/library/dbee/query.rb, line 49
def perform(output, payload)
  records = execute(sql(output))

  load_register(records, output, payload)
end

Private Instance Methods

sql(output) click to toggle source
# File lib/db_fuel/library/dbee/query.rb, line 57
def sql(output)
  sql_statement = ::Dbee.sql(model, query, provider)

  debug_detail(output, "Query SQL: #{sql_statement}")

  sql_statement
end