class Nexter::Query::Section
Iterates over the columns, extracts their values and builds query part that says :
> “col1 = value1” > “col2 = value2”
then joins them with AND :
> “col1 = value1 AND col2 = value2”
Attributes
columns[R]
compass[R]
Public Class Methods
new(columns)
click to toggle source
TODO : check if compass is needed (don’t think so!)
# File lib/nexter/query/section.rb, line 17 def initialize(columns) @columns = columns @compass = compass end
Public Instance Methods
blank?()
click to toggle source
# File lib/nexter/query/section.rb, line 33 def blank? iterate.blank? end
iterate()
click to toggle source
# File lib/nexter/query/section.rb, line 22 def iterate @where ||= columns.map do |column| if column[:val] "#{column[:col]} = #{quote(column[:val])}" else "#{column[:col]} IS NULL" end end.join(' AND ') end
Also aliased as: sql
Private Instance Methods
quote(value)
click to toggle source
# File lib/nexter/query/section.rb, line 38 def quote(value) if value.is_a?(Integer) value # TODO: lookat numeric precision e.g. # round(vat::numeric, 2) = 19.66; elsif value.is_a?(Float) value else #value.is_a?(String) "'#{value}'" end end