test/StatementTest.rb in rubyfb-0.5.9 vs test/StatementTest.rb in rubyfb-0.6

- old
+ new

@@ -38,89 +38,83 @@ def test01 @connections.push(@database.connect(DB_USER_NAME, DB_PASSWORD)) @transactions.push(@connections.last.start_transaction) - s1 = Statement.new(@connections[0], - @transactions[0], - "SELECT RDB$FIELD_NAME FROM RDB$FIELDS", 3) + s1 = @connections[0].create_statement("SELECT RDB$FIELD_NAME FROM RDB$FIELDS") assert(s1 != nil) assert(s1.sql == "SELECT RDB$FIELD_NAME FROM RDB$FIELDS") assert(s1.connection == @connections[0]) - assert(s1.transaction == @transactions[0]) assert(s1.dialect == 3) assert(s1.type == Statement::SELECT_STATEMENT) s1.close - s2 = Statement.new(@connections[0], - @transactions[0], - "DELETE FROM RDB$EXCEPTIONS", 1) + s2 = @connections[0].create_statement("DELETE FROM RDB$EXCEPTIONS") assert(s2 != nil) assert(s2.sql == "DELETE FROM RDB$EXCEPTIONS") assert(s2.connection == @connections[0]) - assert(s2.transaction == @transactions[0]) - assert(s2.dialect == 1) + assert(s2.dialect == 3) assert(s2.type == Statement::DELETE_STATEMENT) s2.close end def test02 @connections.push(@database.connect(DB_USER_NAME, DB_PASSWORD)) @transactions.push(@connections[0].start_transaction) - s = Statement.new(@connections[0], @transactions[0], + s = @connections[0].create_statement( "SELECT RDB$FIELD_NAME FROM RDB$FIELDS "\ - "WHERE RDB$FIELD_NAME LIKE ?", 3) + "WHERE RDB$FIELD_NAME LIKE ?") begin - r = s.execute + r = s.execute(@transactions[0]) r.close assert(false, "Executed statement that required parameter without the "\ "parameter being specified.") rescue Exception => error end begin - r = s.execute_for([]) + r = s.exec([], @transactions[0]) r.close assert(false, "Executed statement that required a parameter with an empty "\ "parameter set.") rescue Exception => error end begin - r = s.execute_for(['LALALA', 25]) + r = s.exec(['LALALA', 25], @transactions[0]) r.close assert(false, "Executed statement that required a parameter with too many "\ "parameters.") rescue Exception => error end - r = s.execute_for(['LALALA']) - assert(r != nil) - assert(r.class == ResultSet) + r = s.exec(['LALALA'], @transactions[0]) + assert_not_nil(r) + assert_equal(ResultSet, r.class) r.close total = 0 - s.execute_for(["%"]) do |row| - total = total + 1 + s.exec(["%"], @transactions[0]) do |row| + total += 1 end - assert(total = 88) + assert_equal(88, total) s.close end def test03 d = nil @database.connect(DB_USER_NAME, DB_PASSWORD) do |cxn| cxn.execute_immediate('CREATE TABLE STRING_TEST(TEXT VARCHAR(10))') cxn.start_transaction do |tx| # Perform an truncated insert. - s = Statement.new(cxn, tx, 'INSERT INTO STRING_TEST VALUES(?)', 3) - s.execute_for(['012345678901234']) + s = cxn.create_statement('INSERT INTO STRING_TEST VALUES(?)') + s.exec(['012345678901234'], tx) # Perform a select of the value inserted. r = cxn.execute('SELECT * FROM STRING_TEST', tx) d = r.fetch @@ -138,11 +132,11 @@ @database.connect(DB_USER_NAME, DB_PASSWORD) do |cxn| utf_str = 'utf кирилица'; cxn.execute_immediate('CREATE TABLE STRING_TEST(TEXT VARCHAR(100) CHARACTER SET UTF8)') cxn.start_transaction do |tx| # Perform an truncated insert. - s = Statement.new(cxn, tx, 'INSERT INTO STRING_TEST VALUES(?)', 3) - s.execute_for([utf_str]) + s = cxn.create_statement('INSERT INTO STRING_TEST VALUES(?)') + s.exec([utf_str], tx) # Perform a select of the value inserted. r = cxn.execute('SELECT * FROM STRING_TEST', tx) d = r.fetch