Sha256: 8961ea160c37bd47df153b47e328b8faaf7ec120fcca26f88a9e072cd5f09412

Contents?: true

Size: 1.07 KB

Versions: 109

Compression:

Stored size: 1.07 KB

Contents

require 'helper'

module SQLite3
  class TestStatementExecute < SQLite3::TestCase
    def setup
      @db   = SQLite3::Database.new(':memory:')
      @db.execute_batch(
        "CREATE TABLE items (id integer PRIMARY KEY, number integer)")
    end

    def teardown
      @db.close
    end

    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

    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

    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
  end
end

Version data entries

109 entries across 109 versions & 2 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/sqlite3-1.7.3-arm64-darwin/test/test_statement_execute.rb
sqlite3-1.7.3 test/test_statement_execute.rb
sqlite3-1.7.3-x86_64-linux test/test_statement_execute.rb
sqlite3-1.7.3-x86_64-darwin test/test_statement_execute.rb
sqlite3-1.7.3-x86-linux test/test_statement_execute.rb
sqlite3-1.7.3-x64-mingw32 test/test_statement_execute.rb
sqlite3-1.7.3-x64-mingw-ucrt test/test_statement_execute.rb
sqlite3-1.7.3-arm64-darwin test/test_statement_execute.rb
sqlite3-1.7.3-arm-linux test/test_statement_execute.rb
sqlite3-1.7.3-aarch64-linux test/test_statement_execute.rb
sqlite3-1.7.2 test/test_statement_execute.rb
sqlite3-1.7.2-x86_64-linux test/test_statement_execute.rb
sqlite3-1.7.2-x86_64-darwin test/test_statement_execute.rb
sqlite3-1.7.2-x86-linux test/test_statement_execute.rb
sqlite3-1.7.2-x64-mingw32 test/test_statement_execute.rb
sqlite3-1.7.2-x64-mingw-ucrt test/test_statement_execute.rb
sqlite3-1.7.2-arm64-darwin test/test_statement_execute.rb
sqlite3-1.7.2-arm-linux test/test_statement_execute.rb
sqlite3-1.7.2-aarch64-linux test/test_statement_execute.rb
sqlite3-1.7.1 test/test_statement_execute.rb