test/RowTest.rb in rubyfb-0.6.3 vs test/RowTest.rb in rubyfb-0.6.4
- old
+ new
@@ -18,24 +18,10 @@
database = Database::create(DB_FILE, DB_USER_NAME, DB_PASSWORD)
@connection = database.connect(DB_USER_NAME, DB_PASSWORD)
@transaction = @connection.start_transaction
@results = @connection.execute('SELECT * FROM RDB$FIELDS', @transaction)
- @empty = [[0, SQLType::INTEGER], [0, SQLType::INTEGER],
- [0, SQLType::INTEGER], [0, SQLType::INTEGER],
- [0, SQLType::INTEGER], [0, SQLType::INTEGER],
- [0, SQLType::INTEGER], [0, SQLType::INTEGER],
- [0, SQLType::INTEGER], [0, SQLType::INTEGER],
- [0, SQLType::INTEGER], [0, SQLType::INTEGER],
- [0, SQLType::INTEGER], [0, SQLType::INTEGER],
- [0, SQLType::INTEGER], [0, SQLType::INTEGER],
- [0, SQLType::INTEGER], [0, SQLType::INTEGER],
- [0, SQLType::INTEGER], [0, SQLType::INTEGER],
- [0, SQLType::INTEGER], [0, SQLType::INTEGER],
- [0, SQLType::INTEGER], [0, SQLType::INTEGER],
- [0, SQLType::INTEGER], [0, SQLType::INTEGER],
- [0, SQLType::INTEGER], [0, SQLType::INTEGER]]
@connection.start_transaction do |tx|
tx.execute('create table rowtest (COL01 integer, COL02 varchar(10), '\
'COL03 integer)')
tx.execute('create table all_types (col01 bigint, col02 blob, '\
@@ -66,29 +52,18 @@
Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
end
puts "#{self.class.name} finished." if TEST_LOGGING
end
- def test01
- row = Row.new(@results, @empty, 100)
-
- assert(row.column_count == 28)
- assert(row.number == 100)
- assert(row.column_name(0) == 'RDB$FIELD_NAME')
- assert(row.column_alias(10) == 'RDB$FIELD_TYPE')
- assert(row[0] == 0)
- assert(row['RDB$FIELD_TYPE'] == 0)
- end
-
def test02
sql = 'select COL01 one, COL02 two, COL03 three from rowtest'
rows = @connection.execute_immediate(sql)
data = rows.fetch
count = 0
data.each do |name, value|
- assert(['ONE', 'TWO', 'THREE'].include?(name))
+ assert(['ONE', 'TWO', 'THREE'].include?(name), name)
assert([1, 'Two', 3].include?(value))
count += 1
end
assert(count == 3)
@@ -179,11 +154,11 @@
begin
results = @connection.execute_immediate('select * from all_types')
row = results.fetch
- assert(row.get_base_type(0) == SQLType::BIGINT)
+ assert_equal(SQLType::BIGINT, row.get_base_type(0))
assert(row.get_base_type(1) == SQLType::BLOB)
assert(row.get_base_type(2) == SQLType::CHAR)
assert(row.get_base_type(3) == SQLType::DATE)
assert(row.get_base_type(4) == SQLType::DECIMAL)
assert(row.get_base_type(5) == SQLType::DOUBLE)
@@ -211,7 +186,25 @@
assert_equal(-5, row.column_scale(0))
assert_equal(-1, row.column_scale(1))
assert_equal(0, row.column_scale(2))
ensure
results.close if results
+ end
+
+ def test05
+ @connection.start_transaction do |tx|
+ tx.execute('create table rowtest2 (COL01 varchar(5000), COL02 varchar(5000), '\
+ 'COL03 integer)')
+ end
+ 1000.times do |i|
+ begin
+ st = @connection.create_statement("insert into rowtest2 values (?, ?, ?)")
+ st.exec(['a'*5000, 'b'*5000, i])
+ ensure
+ st.close
+ end
+ end
+ @connection.execute_immediate("select * from rowtest2") do |row|
+ puts "#{row}\n"
+ end
end
end