Module: ClickHouse::Util::Statement

Defined in:
lib/click_house/util/statement.rb

Constant Summary collapse

END_OF_STATEMENT =
';'
END_OF_STATEMENT_RE =
/#{END_OF_STATEMENT}(\s+|\Z)/.freeze

Class Method Summary collapse

Class Method Details

.ensure(truthful, value, fallback = nil) ⇒ Object


11
12
13
# File 'lib/click_house/util/statement.rb', line 11

def ensure(truthful, value, fallback = nil)
  truthful ? value : fallback
end

.format(sql, format) ⇒ Object


15
16
17
18
19
# File 'lib/click_house/util/statement.rb', line 15

def format(sql, format)
  return sql if sql.match?(/FORMAT/i)

  "#{sql.sub(END_OF_STATEMENT_RE, '')} FORMAT #{format};"
end