123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
# File 'lib/sql/maker.rb', line 123
def delete(*args)
table, where, opt =
if args.size == 1 and args.first.is_a?(Hash)
args = args.first.dup
[args.delete(:table), args.delete(:where) || {}, args]
else
[args[0], args[1] || {}, args[2] || {}]
end
w = self._make_where_clause(where)
quoted_table = self._quote(table)
sql = "DELETE FROM #{quoted_table}"
if opt[:using]
tables = array_wrap(opt[:using])
sql += " USING " + tables.map {|t| self._quote(t) }.join(', ')
end
sql += w[0]
@auto_bind ? bind_param(sql, w[1]) : [sql, w[1]]
end
|