Class: DbFuel::Library::Dbee::Query

Inherits:
Base
  • Object
show all
Defined in:
lib/db_fuel/library/dbee/query.rb

Overview

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.

Instance Attribute Summary

Attributes inherited from Base

#debug, #model, #provider, #query

Instance Method Summary collapse

Constructor Details

#initialize(name: '', model: {}, query: {}, register: Burner::DEFAULT_REGISTER, debug: false) ⇒ Query

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.
    


33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# 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

Instance Method Details

#perform(output, payload) ⇒ Object



49
50
51
52
53
# File 'lib/db_fuel/library/dbee/query.rb', line 49

def perform(output, payload)
  records = execute(sql(output))

  load_register(records, output, payload)
end