Module: Sqlbuilder::Statements::Builders::UpdateBuilder

Included in:
Update
Defined in:
lib/sqlbuilder/statements/builders/update_builder.rb

Instance Method Summary collapse

Instance Method Details

#build_setObject



14
15
16
17
18
19
20
# File 'lib/sqlbuilder/statements/builders/update_builder.rb', line 14

def build_set
  set_list = @set.map do |key, value|
    "#{@utils.format_column(key)} = #{@utils.format_value(value)}"
  end

  "SET #{set_list.join(", ")}"
end

#build_whereObject



5
6
7
8
9
10
11
12
# File 'lib/sqlbuilder/statements/builders/update_builder.rb', line 5

def build_where
  where_clause = @where.map do |key, value|
    escaped = @utils.escape_value(value)
    "#{key} = #{@utils.format_value(escaped)}"
  end

  "WHERE #{where_clause.join(" AND ")}"
end