Class: Sqlbuilder::Statements::Sqlite::Sequence
- Inherits:
-
Object
- Object
- Sqlbuilder::Statements::Sqlite::Sequence
- Defined in:
- lib/sqlbuilder/statements/sqlite/sequence.rb
Instance Method Summary collapse
- #create ⇒ Object
- #create_unless_exists ⇒ Object
- #current_val ⇒ Object
-
#initialize(name) ⇒ Sequence
constructor
A new instance of Sequence.
- #next_val ⇒ Object
- #set_val(new_value) ⇒ Object
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
#create ⇒ Object
9 10 11 |
# File 'lib/sqlbuilder/statements/sqlite/sequence.rb', line 9 def create "CREATE TABLE #{@name} (id INTEGER)" end |
#create_unless_exists ⇒ Object
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_val ⇒ Object
21 22 23 |
# File 'lib/sqlbuilder/statements/sqlite/sequence.rb', line 21 def current_val "SELECT currval('#{@name}')" end |
#next_val ⇒ Object
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 |