Class: Join
- Inherits:
-
Expression
- Object
- Expression
- Join
- Defined in:
- lib/eno.rb
Constant Summary collapse
- H_JOIN_TYPES =
{ nil: 'join', inner: 'inner join', outer: 'outer join' }
Instance Attribute Summary
Attributes inherited from Expression
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
#condition_sql ⇒ Object
284 285 286 287 288 289 290 291 292 293 |
# File 'lib/eno.rb', line 284 def condition_sql if @props[:on] 'on %s' % Expression.quote(@props[:on]) elsif using_fields = @props[:using] fields = using_fields.is_a?(Array) ? using_fields : [using_fields] 'using (%s)' % fields.map { |f| Expression.quote(f) }.join(', ') else nil end end |
#to_sql ⇒ Object
275 276 277 278 279 280 281 282 |
# File 'lib/eno.rb', line 275 def to_sql ("%s %s %s %s" % [ Expression.quote(@members[0]), H_JOIN_TYPES[@props[:type]], Expression.quote(@members[1]), condition_sql ]).strip end |