class MdlSql::Join

Attributes

cond1[RW]

@!attribute type [Symbol] @!attribute table [Table] @!attribute col1 [Symbol/String] @!attribute col2 [Symbol/String] @!attribute op [Symbol]

cond2[RW]

@!attribute type [Symbol] @!attribute table [Table] @!attribute col1 [Symbol/String] @!attribute col2 [Symbol/String] @!attribute op [Symbol]

op[RW]

@!attribute type [Symbol] @!attribute table [Table] @!attribute col1 [Symbol/String] @!attribute col2 [Symbol/String] @!attribute op [Symbol]

table[RW]

@!attribute type [Symbol] @!attribute table [Table] @!attribute col1 [Symbol/String] @!attribute col2 [Symbol/String] @!attribute op [Symbol]

type[RW]

@!attribute type [Symbol] @!attribute table [Table] @!attribute col1 [Symbol/String] @!attribute col2 [Symbol/String] @!attribute op [Symbol]

Public Class Methods

new(opts={}) click to toggle source
# File lib/mdlsql/join.rb, line 28
def initialize opts={}
        @cond1 = opts[:cond1]
        @cond2 = opts[:cond2]
        @table = Table.new opts[:table]
        @type = opts[:type]

        opts[:op].to_sym if opts[:op].is_a? String
        @op = opts[:op]
        @op ||= '='.to_sym
end

Public Instance Methods

to_mysql() click to toggle source

Literals must be made explicit with apostrophes.

# File lib/mdlsql/join.rb, line 40
def to_mysql
        # query = String.new
        query = "\n"
        query << @type.to_s.upcase << ' ' if @type
        query << 'JOIN'
        query << " " << @table.to_mysql
        query << "\nON #{@cond1} #{@op} #{@cond2}"
        return query
end