Sha256: 5ea73a531c8f55df71586f8ed16f300d6fbb0bed982818d0468ce536ace35a5b

Contents?: true

Size: 1.58 KB

Versions: 7

Compression:

Stored size: 1.58 KB

Contents

class TestODBCTransaction < DBDConfig.testbase(:odbc)
    def test_rollback
        dbh = get_dbh
        dbh["AutoCommit"] = false
        @sth = dbh.prepare('insert into names (name, age) values (?, ?)')
        @sth.execute("Foo", 51)
        dbh.rollback
        assert_equal 1, @sth.rows
        @sth.finish


        @sth = dbh.prepare('select name, age from names where name=?')
        @sth.execute("Foo")
        assert !@sth.fetch
        @sth.finish
        dbh.disconnect 
    end

    def test_commit
        dbh = get_dbh
        dbh["AutoCommit"] = false
        @sth = dbh.prepare('insert into names (name, age) values (?, ?)')
        @sth.execute("Foo", 51)
        dbh.commit
        assert_equal 1, @sth.rows
        @sth.finish
        
        @sth = dbh.prepare('select name, age from names where name=?')
        @sth.execute("Foo")
        row = @sth.fetch
        assert row
        assert_equal "Foo", row[0]
        assert_equal 51, row[1]
        @sth.finish
        dbh.disconnect 
    end

    def test_select_transaction
        # per bug #10466
        dbh = get_dbh
        dbh["AutoCommit"] = false
        @sth = dbh.prepare('select * from test_insert(?, ?)');
        @sth.execute("Foo", 51)
        dbh.rollback
        @sth.finish

        @sth = dbh.prepare('select name, age from names where name=?')
        @sth.execute("Foo")
        assert !@sth.fetch
        @sth.finish
        dbh.disconnect 
    end

    def get_dbh
        config = DBDConfig.get_config['odbc']
        DBI.connect("dbi:ODBC:#{config['dbname']}", config['username'], config['password'])
    end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
ydbi-0.6.0 test/dbd/odbc/test_transactions.rb
ydbi-0.5.7 test/dbd/odbc/test_transactions.rb
ydbi-0.5.0 test/dbd/odbc/test_transactions.rb
dbd-odbc-0.2.5 test/dbd/odbc/test_transactions.rb
dbd-odbc-0.2.2 test/dbd/odbc/test_transactions.rb
dbd-odbc-0.2.4 test/dbd/odbc/test_transactions.rb
dbd-odbc-0.2.3 test/dbd/odbc/test_transactions.rb