Class: Select

Inherits:
Expression show all
Defined in:
lib/eno.rb

Instance Attribute Summary

Attributes inherited from Expression

#members, #props

Instance Method Summary collapse

Methods inherited from Expression

#!=, #!@, #%, #&, #*, #+, #-, #/, #<, #<=, #==, #>, #>=, #as, #desc, #initialize, #inner_join, #join, #not_null?, #null?, #over, quote, #|

Constructor Details

This class inherits a constructor from Expression

Instance Method Details

#distinct_clauseObject



323
324
325
326
327
328
329
330
331
332
333
334
# File 'lib/eno.rb', line 323

def distinct_clause
  case (on = @props[:distinct])
  when nil
    nil
  when true
    "distinct "
  when Array
    "distinct on (%s) "  % on.map { |e| Expression.quote(e) }.join(', ')
  else
    "distinct on %s "  % Expression.quote(on)
  end
end

#to_sqlObject



319
320
321
# File 'lib/eno.rb', line 319

def to_sql
  "select %s%s" % [distinct_clause, @members.map { |e| Expression.quote(e) }.join(', ')]
end