Class: SQB::Delete
- Defined in:
- lib/sqb/delete.rb
Constant Summary
Constants included from Ordering
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods included from Limiting
Methods included from Ordering
Methods included from Filtering
Methods inherited from Base
Constructor Details
This class inherits a constructor from SQB::Base
Instance Method Details
#to_sql ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/sqb/delete.rb', line 13 def to_sql [].tap do |query| query << "DELETE FROM" query << escape_and_join(@options[:database_name], @table_name) if @where && !@where.empty? query << "WHERE" query << @where.join(' AND ') end if @orders && !@orders.empty? query << "ORDER BY" query << @orders.join(', ') end if @limit query << "LIMIT #{@limit.to_i}" end end.join(' ') end |