fireruby 0.3.2-mswin32 → 0.4.0-mswin32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. data/doc/CVS/Entries +3 -2
  2. data/doc/CVS/Repository +1 -1
  3. data/doc/README +86 -34
  4. data/doc/classes/CVS/Entries +1 -1
  5. data/doc/classes/CVS/Repository +1 -1
  6. data/doc/classes/FireRuby/CVS/Entries +7 -1
  7. data/doc/classes/FireRuby/CVS/Repository +1 -1
  8. data/doc/classes/FireRuby/Connection.src/CVS/Repository +1 -1
  9. data/doc/classes/FireRuby/Database.src/CVS/Repository +1 -1
  10. data/doc/classes/FireRuby/FireRubyError.src/CVS/Repository +1 -1
  11. data/doc/classes/FireRuby/Generator.src/CVS/Repository +1 -1
  12. data/doc/classes/FireRuby/ResultSet.src/CVS/Repository +1 -1
  13. data/doc/classes/FireRuby/Statement.src/CVS/Repository +1 -1
  14. data/doc/classes/FireRuby/Transaction.src/CVS/Repository +1 -1
  15. data/doc/files/CVS/Repository +1 -1
  16. data/examples/CVS/Entries +1 -1
  17. data/examples/CVS/Repository +1 -1
  18. data/examples/example01.rb +9 -4
  19. data/lib/CVS/Entries +3 -1
  20. data/lib/CVS/Repository +1 -1
  21. data/lib/SQLType.rb +228 -0
  22. data/lib/fireruby.rb +22 -0
  23. data/lib/fr_lib.so +0 -0
  24. data/lib/src.rb +53 -7
  25. data/test/AddRemoveUserTest.rb +7 -2
  26. data/test/BackupRestoreTest.rb +3 -1
  27. data/test/CVS/Entries +19 -16
  28. data/test/CVS/Repository +1 -1
  29. data/test/CharacterSetTest.rb +5 -2
  30. data/test/ConnectionTest.rb +3 -1
  31. data/test/DDLTest.rb +3 -1
  32. data/test/DatabaseTest.rb +3 -1
  33. data/test/GeneratorTest.rb +3 -1
  34. data/test/KeyTest.rb +140 -0
  35. data/test/ResultSetTest.rb +34 -3
  36. data/test/RowCountTest.rb +3 -1
  37. data/test/RowTest.rb +90 -24
  38. data/test/SQLTest.rb +4 -1
  39. data/test/SQLTypeTest.rb +101 -0
  40. data/test/ServiceManagerTest.rb +10 -2
  41. data/test/StatementTest.rb +18 -7
  42. data/test/TestSetup.rb +1 -0
  43. data/test/TransactionTest.rb +4 -1
  44. data/test/TypeTest.rb +92 -0
  45. data/test/UnitTest.rb +61 -15
  46. metadata +59 -57
  47. data/doc/CVS/Entries.Log +0 -2
  48. data/doc/classes/CVS/Entries.Log +0 -1
  49. data/doc/classes/FireRuby/CVS/Entries.Log +0 -7
  50. data/lib/fireruby.so +0 -0
data/lib/src.rb CHANGED
@@ -241,7 +241,7 @@ module FireRuby
241
241
  # the method or an issue occurs establishing the database
242
242
  # connection.
243
243
  #
244
- def initialize(database, user=nil, password=nil, options=nil)
244
+ def initialize(database, user, password, options)
245
245
  end
246
246
 
247
247
 
@@ -682,6 +682,8 @@ module FireRuby
682
682
  # and can no longer be used.
683
683
  #
684
684
  class ResultSet
685
+ include Enumerable
686
+
685
687
  #
686
688
  # This is the constructor for the ResultSet object.
687
689
  #
@@ -833,6 +835,18 @@ module FireRuby
833
835
  #
834
836
  def close
835
837
  end
838
+
839
+ #
840
+ # This method retrieves the base SQL type for a column of data within a
841
+ # ResultSet object. The method returns one of the base types defined in
842
+ # the SQLType class but does not return an actual SQLType object.
843
+ #
844
+ # ==== Parameters
845
+ # index:: The offset from the ResultSet first column of the column to
846
+ # return the type information for.
847
+ #
848
+ def get_base_type(index)
849
+ end
836
850
  end
837
851
 
838
852
 
@@ -840,6 +854,8 @@ module FireRuby
840
854
  # This class models a row of data fetched as part of a SQL query.
841
855
  #
842
856
  class Row
857
+ include Enumerable
858
+
843
859
  #
844
860
  # This is the constructor for the Row class. This method shouldn't really
845
861
  # be used as Row objects are automatically created by ResultSets.
@@ -897,7 +913,7 @@ module FireRuby
897
913
  #
898
914
  # ==== Parameters
899
915
  # index:: Either the offset of the column to retrieve the value of or
900
- # the name of the column to retrieve the value of (column name
916
+ # the alias of the column to retrieve the value of (column alias
901
917
  # comparisons are case sensitive).
902
918
  #
903
919
  def [](index)
@@ -907,7 +923,7 @@ module FireRuby
907
923
  #
908
924
  # This method iterates over the contents of a Row object. The block
909
925
  # specified for the method should accept two parameters; one for the
910
- # column name and one for the column value.
926
+ # column alias and one for the column value.
911
927
  #
912
928
  def each
913
929
  yield column, vlaue
@@ -936,7 +952,7 @@ module FireRuby
936
952
  # for the alternative parameter is specified.
937
953
  #
938
954
  # ==== Parameters
939
- # key:: A string containing the column name to retrieve.
955
+ # key:: A string containing the column alias to retrieve.
940
956
  # alternative:: A reference to the alternative value to be returned if
941
957
  # the keyed value is not found. Defaults to nil.
942
958
  #
@@ -947,7 +963,7 @@ module FireRuby
947
963
 
948
964
  #
949
965
  # This method is used to determine whether a Row object contains a given
950
- # column name.
966
+ # column alias.
951
967
  #
952
968
  # ==== Parameters
953
969
  # name:: A String containing the column name to check for.
@@ -956,6 +972,17 @@ module FireRuby
956
972
  end
957
973
 
958
974
 
975
+ #
976
+ # This method is used to determine whether a Row object contains a given
977
+ # column name.
978
+ #
979
+ # ==== Parameters
980
+ # name:: A String containing the column name to check for.
981
+ #
982
+ def has_column?(name)
983
+ end
984
+
985
+
959
986
  #
960
987
  # This method is used to determine whether a Row object contains a given
961
988
  # column alias.
@@ -979,12 +1006,19 @@ module FireRuby
979
1006
 
980
1007
 
981
1008
  #
982
- # This method retrieves an array of column names for a Row object.
1009
+ # This method retrieves an array of column aliases for a Row object.
983
1010
  #
984
1011
  def keys
985
1012
  end
986
1013
 
987
1014
 
1015
+ #
1016
+ # This method retrieves an array of column names for a Row object.
1017
+ #
1018
+ def names
1019
+ end
1020
+
1021
+
988
1022
  #
989
1023
  # This method retrieves an array of column aliases for a Row object.
990
1024
  #
@@ -1027,7 +1061,7 @@ module FireRuby
1027
1061
 
1028
1062
  #
1029
1063
  # This method returns an array of column values based on a list of column
1030
- # names.
1064
+ # aliases.
1031
1065
  #
1032
1066
  # ==== Parameters
1033
1067
  # names:: One or more Strings containing the names of the columns to
@@ -1035,6 +1069,18 @@ module FireRuby
1035
1069
  #
1036
1070
  def values_at(*names)
1037
1071
  end
1072
+
1073
+ #
1074
+ # This method retrieves the base SQL type for a column of data within a
1075
+ # Row object. The method returns one of the base types defined in the
1076
+ # SQLType class but does not return an actual SQLType object.
1077
+ #
1078
+ # ==== Parameters
1079
+ # index:: The offset from the Row first column of the column to return
1080
+ # the type information for.
1081
+ #
1082
+ def get_base_type(index)
1083
+ end
1038
1084
  end
1039
1085
 
1040
1086
  #
@@ -3,7 +3,7 @@
3
3
  require 'TestSetup'
4
4
  require 'test/unit'
5
5
  require 'rubygems'
6
- require_gem 'fireruby'
6
+ require 'fireruby'
7
7
 
8
8
  include FireRuby
9
9
 
@@ -12,6 +12,7 @@ class AddRemoveUserTest < Test::Unit::TestCase
12
12
  DB_FILE = "#{CURDIR}#{File::SEPARATOR}add_remove_user_unit_test.fdb"
13
13
 
14
14
  def setup
15
+ puts "#{self.class.name} started." if TEST_LOGGING
15
16
  # Remove existing database files.
16
17
  @database = Database.new(DB_FILE)
17
18
  if File.exist?(DB_FILE)
@@ -25,6 +26,7 @@ class AddRemoveUserTest < Test::Unit::TestCase
25
26
  if File.exist?(DB_FILE)
26
27
  @database.drop(DB_USER_NAME, DB_PASSWORD)
27
28
  end
29
+ puts "#{self.class.name} finished." if TEST_LOGGING
28
30
  end
29
31
 
30
32
  def test01
@@ -33,12 +35,15 @@ class AddRemoveUserTest < Test::Unit::TestCase
33
35
 
34
36
  au = AddUser.new('newuser', 'password', 'first', 'middle', 'last')
35
37
  au.execute(sm)
38
+ sleep(3)
36
39
 
37
40
  cxn = @database.connect('newuser', 'password')
38
41
  cxn.close
39
42
 
40
43
  ru = RemoveUser.new('newuser')
41
44
  ru.execute(sm)
45
+
46
+ sm.disconnect
42
47
 
43
48
  begin
44
49
  cxn = @database.connect('newuser', 'password')
@@ -47,4 +52,4 @@ class AddRemoveUserTest < Test::Unit::TestCase
47
52
  rescue FireRubyException
48
53
  end
49
54
  end
50
- end
55
+ end
@@ -3,7 +3,7 @@
3
3
  require 'TestSetup'
4
4
  require 'test/unit'
5
5
  require 'rubygems'
6
- require_gem 'fireruby'
6
+ require 'fireruby'
7
7
 
8
8
  include FireRuby
9
9
 
@@ -13,6 +13,7 @@ class BackupRestoreTest < Test::Unit::TestCase
13
13
  BACKUP_FILE = "#{CURDIR}#{File::SEPARATOR}database.bak"
14
14
 
15
15
  def setup
16
+ puts "#{self.class.name} started." if TEST_LOGGING
16
17
  # Remove existing database files.
17
18
  if File.exist?(DB_FILE)
18
19
  db = Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
@@ -43,6 +44,7 @@ class BackupRestoreTest < Test::Unit::TestCase
43
44
  if File.exist?(BACKUP_FILE)
44
45
  File.delete(BACKUP_FILE)
45
46
  end
47
+ puts "#{self.class.name} finished." if TEST_LOGGING
46
48
  end
47
49
 
48
50
  def test01
data/test/CVS/Entries CHANGED
@@ -1,17 +1,20 @@
1
- /AddRemoveUserTest.rb/1.1/Mon May 9 09:11:29 2005//
2
- /BackupRestoreTest.rb/1.1/Mon May 9 09:11:29 2005//
3
- /CharacterSetTest.rb/1.1/Fri Jun 10 12:15:42 2005//
4
- /ConnectionTest.rb/1.5/Tue Jun 7 13:20:24 2005//
5
- /DDLTest.rb/1.5/Wed May 18 09:13:26 2005//
6
- /DatabaseTest.rb/1.3/Thu Mar 31 08:28:48 2005//
7
- /GeneratorTest.rb/1.3/Mon May 9 09:08:34 2005//
8
- /ResultSetTest.rb/1.3/Mon May 9 09:08:34 2005//
9
- /RowCountTest.rb/1.2/Mon May 9 09:11:29 2005//
10
- /RowTest.rb/1.2/Mon May 9 09:08:34 2005//
11
- /SQLTest.rb/1.4/Wed May 18 09:07:52 2005//
12
- /ServiceManagerTest.rb/1.1/Mon May 9 09:11:29 2005//
13
- /StatementTest.rb/1.4/Mon May 9 09:08:34 2005//
14
- /TestSetup.rb/1.1.1.1/Tue Mar 15 10:37:07 2005//
15
- /TransactionTest.rb/1.5/Wed May 18 09:07:52 2005//
16
- /UnitTest.rb/1.6/Fri Jun 10 12:15:42 2005//
1
+ /AddRemoveUserTest.rb/1.2/Sat Oct 22 09:32:00 2005//
2
+ /BackupRestoreTest.rb/1.2/Sat Oct 22 08:23:48 2005//
3
+ /CharacterSetTest.rb/1.2/Sat Oct 22 08:07:40 2005//
4
+ /ConnectionTest.rb/1.6/Sat Oct 22 08:09:00 2005//
5
+ /DDLTest.rb/1.6/Sat Oct 22 08:09:42 2005//
6
+ /DatabaseTest.rb/1.4/Sat Oct 22 08:21:18 2005//
7
+ /GeneratorTest.rb/1.4/Sat Oct 22 08:21:10 2005//
8
+ /ResultSetTest.rb/1.4/Sat Oct 29 17:00:15 2005//
9
+ /RowCountTest.rb/1.3/Sat Oct 22 08:20:44 2005//
10
+ /RowTest.rb/1.3/Sat Oct 29 14:49:15 2005//
11
+ /SQLTest.rb/1.5/Sat Oct 22 08:27:06 2005//
12
+ /ServiceManagerTest.rb/1.2/Sat Oct 22 08:23:22 2005//
13
+ /StatementTest.rb/1.5/Sat Oct 22 08:22:58 2005//
14
+ /TestSetup.rb/1.2/Sat Oct 22 08:16:26 2005//
15
+ /TransactionTest.rb/1.6/Sat Oct 22 08:22:38 2005//
16
+ /UnitTest.rb/1.7/Sat Oct 29 15:03:24 2005//
17
+ /KeyTest.rb/1.1/Sat Oct 22 09:26:20 2005//
18
+ /SQLTypeTest.rb/1.1/Thu Oct 27 19:22:34 2005//
19
+ /TypeTest.rb/1.1/Sat Oct 29 16:58:35 2005//
17
20
  D
data/test/CVS/Repository CHANGED
@@ -1 +1 @@
1
- /var/cvs/fireruby/fireruby/test
1
+ fireruby/test
@@ -3,7 +3,7 @@
3
3
  require 'TestSetup'
4
4
  require 'test/unit'
5
5
  require 'rubygems'
6
- require_gem 'fireruby'
6
+ require 'fireruby'
7
7
 
8
8
  include FireRuby
9
9
 
@@ -13,6 +13,7 @@ class CharacterSetTest < Test::Unit::TestCase
13
13
  CHAR_SET = 'WIN1251'
14
14
 
15
15
  def setup
16
+ puts "#{self.class.name} started." if TEST_LOGGING
16
17
  if File::exist?(DB_FILE)
17
18
  Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
18
19
  end
@@ -25,6 +26,7 @@ class CharacterSetTest < Test::Unit::TestCase
25
26
  if File::exist?(DB_FILE)
26
27
  Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
27
28
  end
29
+ puts "#{self.class.name} finished." if TEST_LOGGING
28
30
  end
29
31
 
30
32
  def test01
@@ -47,7 +49,8 @@ class CharacterSetTest < Test::Unit::TestCase
47
49
  end
48
50
  cxn.start_transaction do |tr|
49
51
  cxn.execute("INSERT INTO SAMPLE_TABLE VALUES ('#{win1251_str}')",tr)
50
- cxn.execute("SELECT * FROM SAMPLE_TABLE WHERE SAMPLE_FIELD = '#{win1251_str}'",tr) do |row|
52
+ cxn.execute("SELECT * FROM SAMPLE_TABLE WHERE SAMPLE_FIELD = "\
53
+ "'#{win1251_str}'",tr) do |row|
51
54
  # here we have an exception:
52
55
  some_var = row['SAMPLE_FIELD']
53
56
  end
@@ -3,7 +3,7 @@
3
3
  require 'TestSetup'
4
4
  require 'test/unit'
5
5
  require 'rubygems'
6
- require_gem 'fireruby'
6
+ require 'fireruby'
7
7
 
8
8
  include FireRuby
9
9
 
@@ -12,6 +12,7 @@ class ConnectionTest < Test::Unit::TestCase
12
12
  DB_FILE = "#{CURDIR}#{File::SEPARATOR}con_unit_test.fdb"
13
13
 
14
14
  def setup
15
+ puts "#{self.class.name} started." if TEST_LOGGING
15
16
  if File::exist?(DB_FILE)
16
17
  Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
17
18
  end
@@ -27,6 +28,7 @@ class ConnectionTest < Test::Unit::TestCase
27
28
  if File::exist?(DB_FILE)
28
29
  Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
29
30
  end
31
+ puts "#{self.class.name} finished." if TEST_LOGGING
30
32
  end
31
33
 
32
34
  def test01
data/test/DDLTest.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  require 'TestSetup'
4
4
  require 'test/unit'
5
5
  require 'rubygems'
6
- require_gem 'fireruby'
6
+ require 'fireruby'
7
7
 
8
8
  include FireRuby
9
9
 
@@ -12,6 +12,7 @@ class DDLTest < Test::Unit::TestCase
12
12
  DB_FILE = "#{CURDIR}#{File::SEPARATOR}ddl_unit_test.fdb"
13
13
 
14
14
  def setup
15
+ puts "#{self.class.name} started." if TEST_LOGGING
15
16
  if File::exist?(DB_FILE)
16
17
  Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
17
18
  end
@@ -22,6 +23,7 @@ class DDLTest < Test::Unit::TestCase
22
23
  if File::exist?(DB_FILE)
23
24
  Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
24
25
  end
26
+ puts "#{self.class.name} finished." if TEST_LOGGING
25
27
  end
26
28
 
27
29
  def test01
data/test/DatabaseTest.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  require 'TestSetup'
4
4
  require 'test/unit'
5
5
  require 'rubygems'
6
- require_gem 'fireruby'
6
+ require 'fireruby'
7
7
 
8
8
  include FireRuby
9
9
 
@@ -13,6 +13,7 @@ class DatabaseTest < Test::Unit::TestCase
13
13
  CREATE_FILE = "#{CURDIR}#{File::SEPARATOR}db_create_test.fdb"
14
14
 
15
15
  def setup
16
+ puts "#{self.class.name} started." if TEST_LOGGING
16
17
  if File.exist?(DB_FILE)
17
18
  db = Database.new(DB_FILE)
18
19
  db.drop
@@ -34,6 +35,7 @@ class DatabaseTest < Test::Unit::TestCase
34
35
  db = Database.new(CREATE_FILE)
35
36
  db.drop(DB_USER_NAME, DB_PASSWORD)
36
37
  end
38
+ puts "#{self.class.name} finished." if TEST_LOGGING
37
39
  end
38
40
 
39
41
 
@@ -3,7 +3,7 @@
3
3
  require 'TestSetup'
4
4
  require 'test/unit'
5
5
  require 'rubygems'
6
- require_gem 'fireruby'
6
+ require 'fireruby'
7
7
 
8
8
  include FireRuby
9
9
 
@@ -12,6 +12,7 @@ class GeneratorTest < Test::Unit::TestCase
12
12
  DB_FILE = "#{CURDIR}#{File::SEPARATOR}generator_unit_test.fdb"
13
13
 
14
14
  def setup
15
+ puts "#{self.class.name} started." if TEST_LOGGING
15
16
  if File::exist?(DB_FILE)
16
17
  Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
17
18
  end
@@ -29,6 +30,7 @@ class GeneratorTest < Test::Unit::TestCase
29
30
  if File::exist?(DB_FILE)
30
31
  Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
31
32
  end
33
+ puts "#{self.class.name} finished." if TEST_LOGGING
32
34
  end
33
35
 
34
36
  def test01
data/test/KeyTest.rb ADDED
@@ -0,0 +1,140 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'TestSetup'
4
+ require 'test/unit'
5
+ require 'rubygems'
6
+ require 'fireruby'
7
+
8
+ include FireRuby
9
+
10
+ class KeyTest < Test::Unit::TestCase
11
+ CURDIR = "#{Dir.getwd}"
12
+ DB_FILE = "#{CURDIR}#{File::SEPARATOR}key_unit_test.fdb"
13
+
14
+ def setup
15
+ puts "#{self.class.name} started." if TEST_LOGGING
16
+ if File::exist?(DB_FILE)
17
+ Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
18
+ end
19
+
20
+ # Switch to the old way of keying.
21
+ $FireRubySettings[:ALIAS_KEYS] = false
22
+
23
+ database = Database::create(DB_FILE, DB_USER_NAME, DB_PASSWORD)
24
+ @connection = database.connect(DB_USER_NAME, DB_PASSWORD)
25
+ @transaction = @connection.start_transaction
26
+ @results = ResultSet.new(@connection, @transaction,
27
+ 'SELECT * FROM RDB$FIELDS', 3, nil)
28
+ @empty = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
29
+ 0, 0, 0, 0, 0, 0, 0, 0, 0]
30
+
31
+ @connection.execute_immediate('create table keytest (COL01 integer, '\
32
+ 'COL02 varchar(10), COL03 integer)')
33
+ @connection.execute_immediate("insert into keytest values (1, 'Two', 3)")
34
+ end
35
+
36
+ def teardown
37
+ @results.close
38
+ @transaction.rollback
39
+ @connection.close
40
+ if File::exist?(DB_FILE)
41
+ Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
42
+ end
43
+ $FireRubySettings[:ALIAS_KEYS] = true
44
+ puts "#{self.class.name} finished." if TEST_LOGGING
45
+ end
46
+
47
+ def test_01
48
+ sql = 'select COL01 one, COL02 two, COL03 three from keytest'
49
+ rows = @connection.execute_immediate(sql)
50
+ data = rows.fetch
51
+
52
+ count = 0
53
+ data.each do |name, value|
54
+ assert(['COL01', 'COL02', 'COL03'].include?(name))
55
+ assert([1, 'Two', 3].include?(value))
56
+ count += 1
57
+ end
58
+ assert(count == 3)
59
+
60
+ count = 0
61
+ data.each_key do |name|
62
+ assert(['COL01', 'COL02', 'COL03'].include?(name))
63
+ count += 1
64
+ end
65
+ assert(count == 3)
66
+
67
+ count = 0
68
+ data.each_value do |value|
69
+ assert([1, 'Two', 3].include?(value))
70
+ count += 1
71
+ end
72
+ assert(count == 3)
73
+
74
+ assert(data.fetch('COL02') == 'Two')
75
+ assert(data.fetch('COL04', 'LALALA') == 'LALALA')
76
+ assert(data.fetch('COL00') {'NOT FOUND'} == 'NOT FOUND')
77
+ begin
78
+ data.fetch('COL05')
79
+ assert(false, 'Row#fetch succeeded for non-existent column name.')
80
+ rescue IndexError
81
+ end
82
+
83
+ assert(data.has_key?('COL01'))
84
+ assert(data.has_key?('COL10') == false)
85
+
86
+ assert(data.has_column?('COL02'))
87
+ assert(data.has_column?('COL22') == false)
88
+
89
+ assert(data.has_alias?('TWO'))
90
+ assert(data.has_alias?('FOUR') == false)
91
+
92
+ assert(data.has_value?(3))
93
+ assert(data.has_value?('LALALA') == false)
94
+
95
+ assert(data.keys.size == 3)
96
+ data.keys.each do |name|
97
+ assert(['COL01', 'COL02', 'COL03'].include?(name))
98
+ end
99
+
100
+ assert(data.names.size == 3)
101
+ data.names.each do |name|
102
+ assert(['COL01', 'COL02', 'COL03'].include?(name))
103
+ end
104
+
105
+ assert(data.aliases.size == 3)
106
+ data.aliases.each do |name|
107
+ assert(['ONE', 'TWO', 'THREE'].include?(name))
108
+ end
109
+
110
+ assert(data.values.size == 3)
111
+ data.values.each do |value|
112
+ assert([1, 'Two', 3].include?(value))
113
+ end
114
+
115
+ array = data.select {|name, value| name == 'COL02'}
116
+ assert(array.size == 1)
117
+ assert(array[0][0] == 'COL02')
118
+ assert(array[0][1] == 'Two')
119
+
120
+ array = data.to_a
121
+ assert(array.size == 3)
122
+ assert(array.include?(['COL01', 1]))
123
+ assert(array.include?(['COL02', 'Two']))
124
+ assert(array.include?(['COL03', 3]))
125
+
126
+ hash = data.to_hash
127
+ assert(hash.length == 3)
128
+ assert(hash['COL01'] == 1)
129
+ assert(hash['COL02'] == 'Two')
130
+ assert(hash['COL03'] == 3)
131
+
132
+ array = data.values_at('COL10', 'COL02', 'COL03')
133
+ assert(array.size == 3)
134
+ assert(array.include?('Two'))
135
+ assert(array.include?(3))
136
+ assert(array.include?(nil))
137
+
138
+ rows.close
139
+ end
140
+ end
@@ -3,7 +3,7 @@
3
3
  require 'TestSetup'
4
4
  require 'test/unit'
5
5
  require 'rubygems'
6
- require_gem 'fireruby'
6
+ require 'fireruby'
7
7
 
8
8
  include FireRuby
9
9
 
@@ -12,6 +12,7 @@ class ResultSetTest < Test::Unit::TestCase
12
12
  DB_FILE = "#{CURDIR}#{File::SEPARATOR}result_set_unit_test.fdb"
13
13
 
14
14
  def setup
15
+ puts "#{self.class.name} started." if TEST_LOGGING
15
16
  if File::exist?(DB_FILE)
16
17
  Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
17
18
  end
@@ -24,6 +25,11 @@ class ResultSetTest < Test::Unit::TestCase
24
25
  @connections[0].start_transaction do |tx|
25
26
  tx.execute("CREATE TABLE TEST_TABLE (TESTID INTEGER NOT NULL "\
26
27
  "primary KEY, TESTINFO VARCHAR(100))")
28
+ tx.execute('create table all_types (col01 bigint, col02 blob, '\
29
+ 'col03 char(100), col04 date, col05 decimal(5,2), '\
30
+ 'col06 double precision, col07 float, col08 integer, '\
31
+ 'col09 numeric(10,3), col10 smallint, col11 time, '\
32
+ 'col12 timestamp, col13 varchar(23))')
27
33
  end
28
34
 
29
35
  @connections[0].start_transaction do |tx|
@@ -55,6 +61,7 @@ class ResultSetTest < Test::Unit::TestCase
55
61
  if File::exist?(DB_FILE)
56
62
  Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
57
63
  end
64
+ puts "#{self.class.name} finished." if TEST_LOGGING
58
65
  end
59
66
 
60
67
  def test01
@@ -98,7 +105,7 @@ class ResultSetTest < Test::Unit::TestCase
98
105
  total += 1
99
106
  end
100
107
  assert(total == 5)
101
- r.close
108
+ assert(r.exhausted?)
102
109
  end
103
110
 
104
111
  def test02
@@ -108,7 +115,8 @@ class ResultSetTest < Test::Unit::TestCase
108
115
  assert(r.exhausted? == false)
109
116
  total = 0
110
117
  r.each {|row| total += 1}
111
- assert(total ==3)
118
+ assert(total == 3)
119
+ assert(r.exhausted?)
112
120
  end
113
121
 
114
122
  def test03
@@ -128,4 +136,27 @@ class ResultSetTest < Test::Unit::TestCase
128
136
  rescue FireRubyException
129
137
  end
130
138
  end
139
+
140
+ def test04
141
+ results = nil
142
+ begin
143
+ results = @transactions[0].execute('select * from all_types')
144
+
145
+ assert(results.get_base_type(0) == SQLType::BIGINT)
146
+ assert(results.get_base_type(1) == SQLType::BLOB)
147
+ assert(results.get_base_type(2) == SQLType::CHAR)
148
+ assert(results.get_base_type(3) == SQLType::DATE)
149
+ assert(results.get_base_type(4) == SQLType::DECIMAL)
150
+ assert(results.get_base_type(5) == SQLType::DOUBLE)
151
+ assert(results.get_base_type(6) == SQLType::FLOAT)
152
+ assert(results.get_base_type(7) == SQLType::INTEGER)
153
+ assert(results.get_base_type(8) == SQLType::NUMERIC)
154
+ assert(results.get_base_type(9) == SQLType::SMALLINT)
155
+ assert(results.get_base_type(10) == SQLType::TIME)
156
+ assert(results.get_base_type(11) == SQLType::TIMESTAMP)
157
+ assert(results.get_base_type(12) == SQLType::VARCHAR)
158
+ ensure
159
+ results.close if results != nil
160
+ end
161
+ end
131
162
  end
data/test/RowCountTest.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  require 'TestSetup'
4
4
  require 'test/unit'
5
5
  require 'rubygems'
6
- require_gem 'fireruby'
6
+ require 'fireruby'
7
7
 
8
8
  include FireRuby
9
9
 
@@ -12,6 +12,7 @@ class RowCountTest < Test::Unit::TestCase
12
12
  DB_FILE = "#{CURDIR}#{File::SEPARATOR}row_count_test.fdb"
13
13
 
14
14
  def setup
15
+ puts "#{self.class.name} started." if TEST_LOGGING
15
16
  # Create the database for use in testing.
16
17
  if File.exist?(DB_FILE)
17
18
  Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
@@ -29,6 +30,7 @@ class RowCountTest < Test::Unit::TestCase
29
30
  if File.exist?(DB_FILE)
30
31
  @database.drop(DB_USER_NAME, DB_PASSWORD)
31
32
  end
33
+ puts "#{self.class.name} finished." if TEST_LOGGING
32
34
  end
33
35
 
34
36
  def test01