Class: Sqlbuilder::Statements::Sqlite::Sequence

Inherits:
Object
  • Object
show all
Defined in:
lib/sqlbuilder/statements/sqlite/sequence.rb

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Sequence

Returns a new instance of Sequence.



5
6
7
# File 'lib/sqlbuilder/statements/sqlite/sequence.rb', line 5

def initialize(name)
  @name = name
end

Instance Method Details

#createObject



9
10
11
# File 'lib/sqlbuilder/statements/sqlite/sequence.rb', line 9

def create
  "CREATE TABLE #{@name} (id INTEGER)"
end

#create_unless_existsObject



13
14
15
# File 'lib/sqlbuilder/statements/sqlite/sequence.rb', line 13

def create_unless_exists
  "CREATE TABLE IF NOT EXISTS #{@name} (id INTEGER)"
end

#current_valObject



21
22
23
# File 'lib/sqlbuilder/statements/sqlite/sequence.rb', line 21

def current_val
  "SELECT currval('#{@name}')"
end

#next_valObject



17
18
19
# File 'lib/sqlbuilder/statements/sqlite/sequence.rb', line 17

def next_val
  "SELECT nextval('#{@name}')"
end

#set_val(new_value) ⇒ Object



25
26
27
# File 'lib/sqlbuilder/statements/sqlite/sequence.rb', line 25

def set_val(new_value)
  "setval('#{@name}', '#{new_value}')"
end