Method: GitHub::SQL#add_unless_empty

Defined in:
lib/github/sql.rb

#add_unless_empty(sql, extras = nil) ⇒ Object

Public: Add a chunk of SQL to the query, unless query generated so far is empty.

Example: use this for conditionally adding UNION when generating sets of SELECTs.

sql - A String containing a fragment of SQL. extras - A Hash of bind values keyed by Symbol (default: {}). These bind

values are only be used to interpolate this SQL fragment,and
aren't available to subsequent adds.

Returns self. Raises GitHub::SQL::BadBind for unknown keyword tokens.



192
193
194
195
# File 'lib/github/sql.rb', line 192

def add_unless_empty(sql, extras = nil)
  return self if query.empty?
  add sql, extras
end