Class: SQLite3::TestStatementExecute
- Defined in:
- lib/sqlite3-1.5.3-arm64-darwin/test/test_statement_execute.rb,
lib/sqlite3-1.5.3-x86_64-darwin/test/test_statement_execute.rb
Instance Method Summary collapse
- #setup ⇒ Object
- #test_execute_delete ⇒ Object
- #test_execute_insert ⇒ Object
- #test_execute_update ⇒ Object
Methods inherited from TestCase
Instance Method Details
#setup ⇒ Object
5 6 7 8 9 |
# File 'lib/sqlite3-1.5.3-arm64-darwin/test/test_statement_execute.rb', line 5 def setup @db = SQLite3::Database.new(':memory:') @db.execute_batch( "CREATE TABLE items (id integer PRIMARY KEY, number integer)") end |
#test_execute_delete ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/sqlite3-1.5.3-arm64-darwin/test/test_statement_execute.rb', line 27 def test_execute_delete @db.execute("INSERT INTO items (number) VALUES (?)", [20]) ps = @db.prepare("DELETE FROM items WHERE number = :n") ps.execute('n' => 20) assert_equal 0, @db.get_first_value("SELECT count(*) FROM items") ps.close end |
#test_execute_insert ⇒ Object
11 12 13 14 15 16 |
# File 'lib/sqlite3-1.5.3-arm64-darwin/test/test_statement_execute.rb', line 11 def test_execute_insert ps = @db.prepare("INSERT INTO items (number) VALUES (:n)") ps.execute('n'=>10) assert_equal 1, @db.get_first_value("SELECT count(*) FROM items") ps.close end |
#test_execute_update ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/sqlite3-1.5.3-arm64-darwin/test/test_statement_execute.rb', line 18 def test_execute_update @db.execute("INSERT INTO items (number) VALUES (?)", [10]) ps = @db.prepare("UPDATE items SET number = :new WHERE number = :old") ps.execute('old'=>10, 'new'=>20) assert_equal 20, @db.get_first_value("SELECT number FROM items") ps.close end |