Class: From

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

Constant Summary collapse

S_FROM =
'from %s'
S_T1 =
'%s t1'
S_ALIAS =
'%s %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

#members, #props

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

#member_sql(member, sql) ⇒ Object



471
472
473
474
475
476
477
478
479
# File 'lib/eno/expressions.rb', line 471

def member_sql(member, sql)
  if Query::Query === member
    S_T1 % sql.quote(member)
  elsif Alias === member && Query::Query === member.members[0]
    S_ALIAS % [sql.quote(member.members[0]), sql.quote(member.members[1])]
  else
    sql.quote(member)
  end
end

#to_sql(sql) ⇒ Object



467
468
469
# File 'lib/eno/expressions.rb', line 467

def to_sql(sql)
  S_FROM % @members.map { |m| member_sql(m, sql) }.join(S_COMMA)
end