File: delete.rb

package info (click to toggle)
ruby-riddle 2.3.1-2~deb10u1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 10,752 kB
  • sloc: sql: 25,022; php: 5,992; ruby: 4,757; sh: 59; makefile: 5
file content (16 lines) | stat: -rw-r--r-- 323 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# frozen_string_literal: true

class Riddle::Query::Delete
  def initialize(index, *ids)
    @index = index
    @ids   = ids.flatten
  end
  
  def to_sql
    if @ids.length > 1
      "DELETE FROM #{@index} WHERE id IN (#{@ids.join(', ')})"
    else
      "DELETE FROM #{@index} WHERE id = #{@ids.first}"
    end
  end
end