class MysqlFramework::SqlColumn

This class is used to represent a sql column within a table

Public Class Methods

new(table:, column:) click to toggle source
# File lib/mysql_framework/sql_column.rb, line 6
def initialize(table:, column:)
  @table = table
  @column = column
end

Public Instance Methods

as(name) click to toggle source

This method is called to generate an alias statement for this column.

# File lib/mysql_framework/sql_column.rb, line 54
def as(name)
  "#{self} as `#{name}`"
end
eq(value) click to toggle source

This method is called to create a equals (=) condition for this column.

# File lib/mysql_framework/sql_column.rb, line 20
def eq(value)
  SqlCondition.new(column: to_s, comparison: '=', value: value)
end
gt(value) click to toggle source

This method is called to create a greater than (>) condition for this column.

# File lib/mysql_framework/sql_column.rb, line 30
def gt(value)
  SqlCondition.new(column: to_s, comparison: '>', value: value)
end
gte(value) click to toggle source

This method is called to create a greater than or equal (>=) condition for this column.

# File lib/mysql_framework/sql_column.rb, line 35
def gte(value)
  SqlCondition.new(column: to_s, comparison: '>=', value: value)
end
in(*values) click to toggle source
# File lib/mysql_framework/sql_column.rb, line 49
def in(*values)
  InCondition.new(column: to_s, comparison: 'IN', value: values)
end
lt(value) click to toggle source

This method is called to create a less than (<) condition for this column.

# File lib/mysql_framework/sql_column.rb, line 40
def lt(value)
  SqlCondition.new(column: to_s, comparison: '<', value: value)
end
lte(value) click to toggle source

This method is called to create a less than or equal (<=) condition for this column.

# File lib/mysql_framework/sql_column.rb, line 45
def lte(value)
  SqlCondition.new(column: to_s, comparison: '<=', value: value)
end
not_eq(value) click to toggle source

This method is called to create a not equal (<>) condition for this column.

# File lib/mysql_framework/sql_column.rb, line 25
def not_eq(value)
  SqlCondition.new(column: to_s, comparison: '<>', value: value)
end
to_s() click to toggle source
# File lib/mysql_framework/sql_column.rb, line 11
def to_s
  "`#{@table}`.`#{@column}`"
end
to_sym() click to toggle source
# File lib/mysql_framework/sql_column.rb, line 15
def to_sym
  @column.to_sym
end