lib/dataminer/repositories/report_repo.rb
# Take a grid query definition and replace its where clause, returning the modified SQL.
# Assumes the where clause will be of the form: "WHERE id = value", but can be modified in other ways.
#
# @param id [string] the query definition file name (without 'yml')
# @param value [string, integer] the value to match.
# @param operator [string] the operator to apply to the column. Default "=".
# @param column [string] the column to match in the WHERE clause.
# @param data_type [Symbol] the data_type of the column. Defaults to :integer.
# @return [String] the SQL to be run.
Take a grid query definition and replace its where clause, returning the modified SQL.
Assumes the where clause will be of the form: "WHERE id = value", but can be modified in other ways.
Take a grid query definition and replace its where clause returning the modified SQL . Assumes the where clause will be of the form : " WHERE id = value " but can be modified in other ways .
def replace_grid_query_where_clause(id, value, operator: '=', column: 'id', data_type: :integer)
      persistor = Crossbeams::Dataminer::YamlPersistor.new(File.join(ENV['GRID_QUERIES_LOCATION'], "#{id}.yml"))
      rpt = Crossbeams::Dataminer::Report.load(persistor)
      params = [Crossbeams::Dataminer::QueryParameter.new(column, Crossbeams::Dataminer::OperatorValue.new(operator, value, data_type))]
      rpt.replace_where(params)
      rpt.runnable_sql
    end
def replace_grid_query_where_clause ( id , value , operator : '=' , column : 'id' , data_type : :integer ) persistor = Crossbeams :: Dataminer :: YamlPersistor . new ( File . join ( ENV [ 'GRID_QUERIES_LOCATION' ] , "#{id}.yml" ) ) rpt = Crossbeams :: Dataminer :: Report . load ( persistor ) params = [ Crossbeams :: Dataminer :: QueryParameter . new ( column , Crossbeams :: Dataminer :: OperatorValue . new ( operator , value , data_type ) ) ] rpt . replace_where ( params ) rpt . runnable_sql end
Take a grid query definition and replace its where clause, returning the modified SQL.
Take a grid query definition and replace its where clause returning the modified SQL .
the SQL to be run.
the SQL to be run .
String
id
the query definition file name (without 'yml')
the query definition file name ( without ' yml ' )
value
the value to match.
the value to match .
operator
the operator to apply to the column.
the operator to apply to the column .
column
the column to match in the WHERE clause.
the column to match in the WHERE clause .
data_type
the data_type of the column. Defaults to :integer.
the data_type of the column . Defaults to : integer .