Class: Join
- Inherits:
-
Expression
- Object
- Expression
- Join
- Defined in:
- lib/eno/expressions.rb
Constant Summary collapse
- H_JOIN_TYPES =
{ nil: 'join', inner: 'inner join', outer: 'outer join' }
- S_JOIN =
'%s %s %s %s'
- S_ON =
'on %s'
- S_USING =
'using (%s)'
Constants inherited from Expression
Expression::S_AND, Expression::S_DIV, Expression::S_EQ, Expression::S_GT, Expression::S_GTE, Expression::S_LT, Expression::S_LTE, Expression::S_MINUS, Expression::S_MOD, Expression::S_MUL, Expression::S_NEQ, Expression::S_OR, Expression::S_PLUS, Expression::S_TILDE
Instance Attribute Summary
Attributes inherited from Expression
Instance Method Summary collapse
Methods inherited from Expression
#!=, #!@, #%, #&, #*, #+, #-, #/, #<, #<=, #==, #=~, #>, #>=, #^, #as, #cast, #desc, #in, #initialize, #inner_join, #join, #not_in, #not_null?, #null?, #over, #|
Constructor Details
This class inherits a constructor from Expression
Instance Method Details
#condition_sql(sql) ⇒ Object
315 316 317 318 319 320 321 322 323 324 |
# File 'lib/eno/expressions.rb', line 315 def condition_sql(sql) if @props[:on] S_ON % sql.quote(@props[:on]) elsif using_fields = @props[:using] fields = using_fields.is_a?(Array) ? using_fields : [using_fields] S_USING % fields.map { |f| sql.quote(f) }.join(S_COMMA) else nil end end |
#to_sql(sql) ⇒ Object
306 307 308 309 310 311 312 313 |
# File 'lib/eno/expressions.rb', line 306 def to_sql(sql) (S_JOIN % [ sql.quote(@members[0]), H_JOIN_TYPES[@props[:type]], sql.quote(@members[1]), condition_sql(sql) ]).strip end |