fireruby 0.4.1-i586-linux → 0.4.2-i586-linux
Sign up to get free protection for your applications and to get access to all the features.
- data/doc/README +456 -456
- data/doc/license.txt +0 -0
- data/examples/example01.rb +65 -65
- data/lib/SQLType.rb +223 -227
- data/lib/fireruby.rb +22 -22
- data/lib/fr_lib.so +0 -0
- data/lib/mkdoc +1 -1
- data/lib/src.rb +1795 -1795
- data/test/AddRemoveUserTest.rb +55 -55
- data/test/BackupRestoreTest.rb +99 -99
- data/test/BlobTest.rb +56 -0
- data/test/CharacterSetTest.rb +63 -63
- data/test/ConnectionTest.rb +111 -111
- data/test/DDLTest.rb +54 -54
- data/test/DatabaseTest.rb +83 -83
- data/test/GeneratorTest.rb +50 -50
- data/test/KeyTest.rb +140 -140
- data/test/ResultSetTest.rb +162 -162
- data/test/RoleTest.rb +71 -0
- data/test/RowCountTest.rb +65 -65
- data/test/RowTest.rb +203 -203
- data/test/SQLTest.rb +182 -182
- data/test/SQLTypeTest.rb +101 -101
- data/test/ServiceManagerTest.rb +29 -29
- data/test/StatementTest.rb +135 -135
- data/test/TestSetup.rb +11 -11
- data/test/TransactionTest.rb +112 -112
- data/test/TypeTest.rb +92 -92
- data/test/UnitTest.rb +65 -64
- metadata +47 -110
- data/doc/CVS/Entries +0 -3
- data/doc/CVS/Entries.Log +0 -2
- data/doc/CVS/Repository +0 -1
- data/doc/CVS/Root +0 -1
- data/doc/classes/CVS/Entries +0 -1
- data/doc/classes/CVS/Entries.Log +0 -1
- data/doc/classes/CVS/Repository +0 -1
- data/doc/classes/CVS/Root +0 -1
- data/doc/classes/FireRuby/CVS/Entries +0 -1
- data/doc/classes/FireRuby/CVS/Entries.Log +0 -7
- data/doc/classes/FireRuby/CVS/Repository +0 -1
- data/doc/classes/FireRuby/CVS/Root +0 -1
- data/doc/classes/FireRuby/Connection.src/CVS/Entries +0 -1
- data/doc/classes/FireRuby/Connection.src/CVS/Repository +0 -1
- data/doc/classes/FireRuby/Connection.src/CVS/Root +0 -1
- data/doc/classes/FireRuby/Database.src/CVS/Entries +0 -1
- data/doc/classes/FireRuby/Database.src/CVS/Repository +0 -1
- data/doc/classes/FireRuby/Database.src/CVS/Root +0 -1
- data/doc/classes/FireRuby/FireRubyError.src/CVS/Entries +0 -1
- data/doc/classes/FireRuby/FireRubyError.src/CVS/Repository +0 -1
- data/doc/classes/FireRuby/FireRubyError.src/CVS/Root +0 -1
- data/doc/classes/FireRuby/Generator.src/CVS/Entries +0 -1
- data/doc/classes/FireRuby/Generator.src/CVS/Repository +0 -1
- data/doc/classes/FireRuby/Generator.src/CVS/Root +0 -1
- data/doc/classes/FireRuby/ResultSet.src/CVS/Entries +0 -1
- data/doc/classes/FireRuby/ResultSet.src/CVS/Repository +0 -1
- data/doc/classes/FireRuby/ResultSet.src/CVS/Root +0 -1
- data/doc/classes/FireRuby/Statement.src/CVS/Entries +0 -1
- data/doc/classes/FireRuby/Statement.src/CVS/Repository +0 -1
- data/doc/classes/FireRuby/Statement.src/CVS/Root +0 -1
- data/doc/classes/FireRuby/Transaction.src/CVS/Entries +0 -1
- data/doc/classes/FireRuby/Transaction.src/CVS/Repository +0 -1
- data/doc/classes/FireRuby/Transaction.src/CVS/Root +0 -1
- data/doc/files/CVS/Entries +0 -1
- data/doc/files/CVS/Repository +0 -1
- data/doc/files/CVS/Root +0 -1
- data/examples/CVS/Entries +0 -2
- data/examples/CVS/Repository +0 -1
- data/examples/CVS/Root +0 -1
- data/lib/CVS/Entries +0 -6
- data/lib/CVS/Repository +0 -1
- data/lib/CVS/Root +0 -1
- data/test/CVS/Entries +0 -20
- data/test/CVS/Repository +0 -1
- data/test/CVS/Root +0 -1
data/test/SQLTest.rb
CHANGED
@@ -1,182 +1,182 @@
|
|
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 SQLTest < Test::Unit::TestCase
|
11
|
-
CURDIR = "#{Dir.getwd}"
|
12
|
-
DB_FILE = "#{CURDIR}#{File::SEPARATOR}sql_unit_test.fdb"
|
13
|
-
ITERATIONS = 100
|
14
|
-
|
15
|
-
INSERT_SQL = "INSERT INTO TEST_TABLE VALUES(?, ?, ?, ?, ?, ?)"
|
16
|
-
|
17
|
-
def setup
|
18
|
-
puts "#{self.class.name} started." if TEST_LOGGING
|
19
|
-
if File::exist?(DB_FILE)
|
20
|
-
Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
|
21
|
-
end
|
22
|
-
@database = Database::create(DB_FILE, DB_USER_NAME, DB_PASSWORD)
|
23
|
-
@connections = []
|
24
|
-
@transactions = []
|
25
|
-
|
26
|
-
@database.connect(DB_USER_NAME, DB_PASSWORD) do |cxn|
|
27
|
-
cxn.execute_immediate('CREATE TABLE TEST_TABLE (TESTID INTEGER '\
|
28
|
-
'NOT NULL PRIMARY KEY, TESTTEXT VARCHAR(100), '\
|
29
|
-
'TESTFLOAT NUMERIC(8,2), TESTDATE DATE, TESTTIME '\
|
30
|
-
'TIME, TESTSTAMP TIMESTAMP)')
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def teardown
|
35
|
-
@transactions.each do |tx|
|
36
|
-
tx.rollback if tx.active?
|
37
|
-
end
|
38
|
-
|
39
|
-
@connections.each do |cxn|
|
40
|
-
cxn.close if cxn.open?
|
41
|
-
end
|
42
|
-
|
43
|
-
if File::exist?(DB_FILE)
|
44
|
-
Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
|
45
|
-
end
|
46
|
-
puts "#{self.class.name} finished." if TEST_LOGGING
|
47
|
-
end
|
48
|
-
|
49
|
-
def test01
|
50
|
-
@database.connect(DB_USER_NAME, DB_PASSWORD) do |cxn|
|
51
|
-
cxn.start_transaction do |tx|
|
52
|
-
s = Statement.new(cxn, tx, INSERT_SQL, 3)
|
53
|
-
f = 0.0
|
54
|
-
t = Time.new
|
55
|
-
|
56
|
-
1.upto(ITERATIONS) do |i|
|
57
|
-
f += 0.321
|
58
|
-
t = Time.at(t.to_i + 5)
|
59
|
-
s.execute_for([i, i.to_s, f, t, nil, t])
|
60
|
-
end
|
61
|
-
|
62
|
-
s.close
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
@connections.push(@database.connect(DB_USER_NAME, DB_PASSWORD))
|
67
|
-
@connections[0].start_transaction do |tx|
|
68
|
-
r = tx.execute("SELECT COUNT(*) FROM TEST_TABLE")
|
69
|
-
assert(r.fetch[0] == ITERATIONS)
|
70
|
-
r.close
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
def test02
|
75
|
-
f = 0.0
|
76
|
-
@database.connect(DB_USER_NAME, DB_PASSWORD) do |cxn|
|
77
|
-
1.upto(20) do |i|
|
78
|
-
f += i
|
79
|
-
sql = "INSERT INTO TEST_TABLE VALUES (#{i}, "\
|
80
|
-
"#{f.to_s}, #{f}, NULL, NULL, 'NOW')"
|
81
|
-
cxn.execute_immediate(sql)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
@connections.push(@database.connect(DB_USER_NAME, DB_PASSWORD))
|
86
|
-
@transactions.push(@connections[0].start_transaction)
|
87
|
-
r = @transactions[0].execute("SELECT COUNT(*) FROM TEST_TABLE")
|
88
|
-
assert(r.fetch[0] == 20)
|
89
|
-
r.close
|
90
|
-
|
91
|
-
r = @transactions[0].execute("SELECT * FROM TEST_TABLE WHERE TESTID IN "\
|
92
|
-
"(2, 4, 6, 8, 10) ORDER BY TESTID ASCENDING")
|
93
|
-
a = r.fetch
|
94
|
-
assert(a[0] == 2)
|
95
|
-
assert(a[1] == '3.0')
|
96
|
-
assert(a[2] == 3.0)
|
97
|
-
assert(a[3] == nil)
|
98
|
-
assert(a[4] == nil)
|
99
|
-
|
100
|
-
a = r.fetch
|
101
|
-
assert(a[0] == 4)
|
102
|
-
assert(a[1] == '10.0')
|
103
|
-
assert(a[2] == 10.0)
|
104
|
-
assert(a[3] == nil)
|
105
|
-
assert(a[4] == nil)
|
106
|
-
|
107
|
-
a = r.fetch
|
108
|
-
assert(a[0] == 6)
|
109
|
-
assert(a[1] == '21.0')
|
110
|
-
assert(a[2] == 21.0)
|
111
|
-
assert(a[3] == nil)
|
112
|
-
assert(a[4] == nil)
|
113
|
-
|
114
|
-
a = r.fetch
|
115
|
-
assert(a[0] == 8)
|
116
|
-
assert(a[1] == '36.0')
|
117
|
-
assert(a[2] == 36.0)
|
118
|
-
assert(a[3] == nil)
|
119
|
-
assert(a[4] == nil)
|
120
|
-
|
121
|
-
a = r.fetch
|
122
|
-
assert(a[0] == 10)
|
123
|
-
assert(a[1] == '55.0')
|
124
|
-
assert(a[2] == 55.0)
|
125
|
-
assert(a[3] == nil)
|
126
|
-
assert(a[4] == nil)
|
127
|
-
|
128
|
-
r.close
|
129
|
-
|
130
|
-
@transactions[0].commit
|
131
|
-
|
132
|
-
@connections[0].start_transaction do |tx|
|
133
|
-
s = Statement.new(@connections[0], tx,
|
134
|
-
"UPDATE TEST_TABLE SET TESTSTAMP = NULL", 3)
|
135
|
-
s.execute()
|
136
|
-
s.close
|
137
|
-
|
138
|
-
r = tx.execute("SELECT TESTSTAMP FROM TEST_TABLE")
|
139
|
-
total = 0
|
140
|
-
r.each do |row|
|
141
|
-
assert(row[0] == nil)
|
142
|
-
total = total + 1
|
143
|
-
end
|
144
|
-
assert(total == 20)
|
145
|
-
r.close
|
146
|
-
end
|
147
|
-
|
148
|
-
a = []
|
149
|
-
t = nil
|
150
|
-
@connections[0].start_transaction do |tx|
|
151
|
-
# Perform an insert via a parameterized statement.
|
152
|
-
s = Statement.new(@connections[0], tx,
|
153
|
-
"INSERT INTO TEST_TABLE (TESTID, TESTTEXT, "\
|
154
|
-
"TESTFLOAT, TESTSTAMP) VALUES(?, ?, ?, ?)", 3)
|
155
|
-
t = Time.new
|
156
|
-
s.execute_for([25000, 'La la la', 3.14, t])
|
157
|
-
s.close
|
158
|
-
|
159
|
-
# Fetch the record and check the data.
|
160
|
-
r = tx.execute("SELECT TESTTEXT, TESTFLOAT, TESTSTAMP FROM "\
|
161
|
-
"TEST_TABLE WHERE TESTID = 25000")
|
162
|
-
a = r.fetch
|
163
|
-
r.close
|
164
|
-
end
|
165
|
-
assert(a[0] == 'La la la')
|
166
|
-
assert(a[1] == 3.14)
|
167
|
-
assert(a[2].to_i == t.to_i)
|
168
|
-
|
169
|
-
@connections[0].execute_immediate("DELETE FROM TEST_TABLE WHERE TESTID "\
|
170
|
-
"IN (1, 3, 5, 7, 9, 12, 14, 16, 18, 20)")
|
171
|
-
@database.connect(DB_USER_NAME, DB_PASSWORD) do |cxn|
|
172
|
-
a = []
|
173
|
-
cxn.start_transaction do |tx|
|
174
|
-
r = tx.execute("SELECT COUNT(*) FROM TEST_TABLE")
|
175
|
-
a = r.fetch
|
176
|
-
r.close
|
177
|
-
end
|
178
|
-
assert(a[0] == 11)
|
179
|
-
end
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
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 SQLTest < Test::Unit::TestCase
|
11
|
+
CURDIR = "#{Dir.getwd}"
|
12
|
+
DB_FILE = "#{CURDIR}#{File::SEPARATOR}sql_unit_test.fdb"
|
13
|
+
ITERATIONS = 100
|
14
|
+
|
15
|
+
INSERT_SQL = "INSERT INTO TEST_TABLE VALUES(?, ?, ?, ?, ?, ?)"
|
16
|
+
|
17
|
+
def setup
|
18
|
+
puts "#{self.class.name} started." if TEST_LOGGING
|
19
|
+
if File::exist?(DB_FILE)
|
20
|
+
Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
|
21
|
+
end
|
22
|
+
@database = Database::create(DB_FILE, DB_USER_NAME, DB_PASSWORD)
|
23
|
+
@connections = []
|
24
|
+
@transactions = []
|
25
|
+
|
26
|
+
@database.connect(DB_USER_NAME, DB_PASSWORD) do |cxn|
|
27
|
+
cxn.execute_immediate('CREATE TABLE TEST_TABLE (TESTID INTEGER '\
|
28
|
+
'NOT NULL PRIMARY KEY, TESTTEXT VARCHAR(100), '\
|
29
|
+
'TESTFLOAT NUMERIC(8,2), TESTDATE DATE, TESTTIME '\
|
30
|
+
'TIME, TESTSTAMP TIMESTAMP)')
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def teardown
|
35
|
+
@transactions.each do |tx|
|
36
|
+
tx.rollback if tx.active?
|
37
|
+
end
|
38
|
+
|
39
|
+
@connections.each do |cxn|
|
40
|
+
cxn.close if cxn.open?
|
41
|
+
end
|
42
|
+
|
43
|
+
if File::exist?(DB_FILE)
|
44
|
+
Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
|
45
|
+
end
|
46
|
+
puts "#{self.class.name} finished." if TEST_LOGGING
|
47
|
+
end
|
48
|
+
|
49
|
+
def test01
|
50
|
+
@database.connect(DB_USER_NAME, DB_PASSWORD) do |cxn|
|
51
|
+
cxn.start_transaction do |tx|
|
52
|
+
s = Statement.new(cxn, tx, INSERT_SQL, 3)
|
53
|
+
f = 0.0
|
54
|
+
t = Time.new
|
55
|
+
|
56
|
+
1.upto(ITERATIONS) do |i|
|
57
|
+
f += 0.321
|
58
|
+
t = Time.at(t.to_i + 5)
|
59
|
+
s.execute_for([i, i.to_s, f, t, nil, t])
|
60
|
+
end
|
61
|
+
|
62
|
+
s.close
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
@connections.push(@database.connect(DB_USER_NAME, DB_PASSWORD))
|
67
|
+
@connections[0].start_transaction do |tx|
|
68
|
+
r = tx.execute("SELECT COUNT(*) FROM TEST_TABLE")
|
69
|
+
assert(r.fetch[0] == ITERATIONS)
|
70
|
+
r.close
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def test02
|
75
|
+
f = 0.0
|
76
|
+
@database.connect(DB_USER_NAME, DB_PASSWORD) do |cxn|
|
77
|
+
1.upto(20) do |i|
|
78
|
+
f += i
|
79
|
+
sql = "INSERT INTO TEST_TABLE VALUES (#{i}, "\
|
80
|
+
"#{f.to_s}, #{f}, NULL, NULL, 'NOW')"
|
81
|
+
cxn.execute_immediate(sql)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
@connections.push(@database.connect(DB_USER_NAME, DB_PASSWORD))
|
86
|
+
@transactions.push(@connections[0].start_transaction)
|
87
|
+
r = @transactions[0].execute("SELECT COUNT(*) FROM TEST_TABLE")
|
88
|
+
assert(r.fetch[0] == 20)
|
89
|
+
r.close
|
90
|
+
|
91
|
+
r = @transactions[0].execute("SELECT * FROM TEST_TABLE WHERE TESTID IN "\
|
92
|
+
"(2, 4, 6, 8, 10) ORDER BY TESTID ASCENDING")
|
93
|
+
a = r.fetch
|
94
|
+
assert(a[0] == 2)
|
95
|
+
assert(a[1] == '3.0')
|
96
|
+
assert(a[2] == 3.0)
|
97
|
+
assert(a[3] == nil)
|
98
|
+
assert(a[4] == nil)
|
99
|
+
|
100
|
+
a = r.fetch
|
101
|
+
assert(a[0] == 4)
|
102
|
+
assert(a[1] == '10.0')
|
103
|
+
assert(a[2] == 10.0)
|
104
|
+
assert(a[3] == nil)
|
105
|
+
assert(a[4] == nil)
|
106
|
+
|
107
|
+
a = r.fetch
|
108
|
+
assert(a[0] == 6)
|
109
|
+
assert(a[1] == '21.0')
|
110
|
+
assert(a[2] == 21.0)
|
111
|
+
assert(a[3] == nil)
|
112
|
+
assert(a[4] == nil)
|
113
|
+
|
114
|
+
a = r.fetch
|
115
|
+
assert(a[0] == 8)
|
116
|
+
assert(a[1] == '36.0')
|
117
|
+
assert(a[2] == 36.0)
|
118
|
+
assert(a[3] == nil)
|
119
|
+
assert(a[4] == nil)
|
120
|
+
|
121
|
+
a = r.fetch
|
122
|
+
assert(a[0] == 10)
|
123
|
+
assert(a[1] == '55.0')
|
124
|
+
assert(a[2] == 55.0)
|
125
|
+
assert(a[3] == nil)
|
126
|
+
assert(a[4] == nil)
|
127
|
+
|
128
|
+
r.close
|
129
|
+
|
130
|
+
@transactions[0].commit
|
131
|
+
|
132
|
+
@connections[0].start_transaction do |tx|
|
133
|
+
s = Statement.new(@connections[0], tx,
|
134
|
+
"UPDATE TEST_TABLE SET TESTSTAMP = NULL", 3)
|
135
|
+
s.execute()
|
136
|
+
s.close
|
137
|
+
|
138
|
+
r = tx.execute("SELECT TESTSTAMP FROM TEST_TABLE")
|
139
|
+
total = 0
|
140
|
+
r.each do |row|
|
141
|
+
assert(row[0] == nil)
|
142
|
+
total = total + 1
|
143
|
+
end
|
144
|
+
assert(total == 20)
|
145
|
+
r.close
|
146
|
+
end
|
147
|
+
|
148
|
+
a = []
|
149
|
+
t = nil
|
150
|
+
@connections[0].start_transaction do |tx|
|
151
|
+
# Perform an insert via a parameterized statement.
|
152
|
+
s = Statement.new(@connections[0], tx,
|
153
|
+
"INSERT INTO TEST_TABLE (TESTID, TESTTEXT, "\
|
154
|
+
"TESTFLOAT, TESTSTAMP) VALUES(?, ?, ?, ?)", 3)
|
155
|
+
t = Time.new
|
156
|
+
s.execute_for([25000, 'La la la', 3.14, t])
|
157
|
+
s.close
|
158
|
+
|
159
|
+
# Fetch the record and check the data.
|
160
|
+
r = tx.execute("SELECT TESTTEXT, TESTFLOAT, TESTSTAMP FROM "\
|
161
|
+
"TEST_TABLE WHERE TESTID = 25000")
|
162
|
+
a = r.fetch
|
163
|
+
r.close
|
164
|
+
end
|
165
|
+
assert(a[0] == 'La la la')
|
166
|
+
assert(a[1] == 3.14)
|
167
|
+
assert(a[2].to_i == t.to_i)
|
168
|
+
|
169
|
+
@connections[0].execute_immediate("DELETE FROM TEST_TABLE WHERE TESTID "\
|
170
|
+
"IN (1, 3, 5, 7, 9, 12, 14, 16, 18, 20)")
|
171
|
+
@database.connect(DB_USER_NAME, DB_PASSWORD) do |cxn|
|
172
|
+
a = []
|
173
|
+
cxn.start_transaction do |tx|
|
174
|
+
r = tx.execute("SELECT COUNT(*) FROM TEST_TABLE")
|
175
|
+
a = r.fetch
|
176
|
+
r.close
|
177
|
+
end
|
178
|
+
assert(a[0] == 11)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
data/test/SQLTypeTest.rb
CHANGED
@@ -1,101 +1,101 @@
|
|
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 SQLTypeTest < Test::Unit::TestCase
|
11
|
-
CURDIR = "#{Dir.getwd}"
|
12
|
-
DB_FILE = "#{CURDIR}#{File::SEPARATOR}sql_type_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
|
-
@database = Database.create(DB_FILE, DB_USER_NAME, DB_PASSWORD)
|
21
|
-
@connection = @database.connect(DB_USER_NAME, DB_PASSWORD)
|
22
|
-
|
23
|
-
@connection.start_transaction do |tx|
|
24
|
-
tx.execute("create table all_types (col01 bigint, col02 blob, "\
|
25
|
-
"col03 char(100), col04 date, col05 decimal(5,2), "\
|
26
|
-
"col06 double precision, col07 float, col08 integer, "\
|
27
|
-
"col09 numeric(10,3), col10 smallint, col11 time, "\
|
28
|
-
"col12 timestamp, col13 varchar(23))")
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def teardown
|
33
|
-
@connection.close if @connection != nil && @connection.open?
|
34
|
-
|
35
|
-
if File::exist?(DB_FILE)
|
36
|
-
Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
|
37
|
-
end
|
38
|
-
puts "#{self.class.name} finished." if TEST_LOGGING
|
39
|
-
end
|
40
|
-
|
41
|
-
def test01
|
42
|
-
types = []
|
43
|
-
types.push(SQLType.new(SQLType::BIGINT))
|
44
|
-
types.push(SQLType.new(SQLType::VARCHAR, 1000))
|
45
|
-
types.push(SQLType.new(SQLType::DECIMAL, nil, 10))
|
46
|
-
types.push(SQLType.new(SQLType::NUMERIC, nil, 5, 3))
|
47
|
-
types.push(SQLType.new(SQLType::BLOB, nil, nil, nil, 1))
|
48
|
-
|
49
|
-
assert(types[0] == types[0])
|
50
|
-
assert(!(types[0] == types[1]))
|
51
|
-
assert(types[1] == SQLType.new(SQLType::VARCHAR, 1000))
|
52
|
-
|
53
|
-
assert(types[0].type == SQLType::BIGINT)
|
54
|
-
assert(types[0].length == nil)
|
55
|
-
assert(types[0].precision == nil)
|
56
|
-
assert(types[0].scale == nil)
|
57
|
-
assert(types[0].subtype == nil)
|
58
|
-
|
59
|
-
assert(types[1].type == SQLType::VARCHAR)
|
60
|
-
assert(types[1].length == 1000)
|
61
|
-
assert(types[1].precision == nil)
|
62
|
-
assert(types[1].scale == nil)
|
63
|
-
assert(types[1].subtype == nil)
|
64
|
-
|
65
|
-
assert(types[2].type == SQLType::DECIMAL)
|
66
|
-
assert(types[2].length == nil)
|
67
|
-
assert(types[2].precision == 10)
|
68
|
-
assert(types[2].scale == nil)
|
69
|
-
assert(types[2].subtype == nil)
|
70
|
-
|
71
|
-
assert(types[3].type == SQLType::NUMERIC)
|
72
|
-
assert(types[3].length == nil)
|
73
|
-
assert(types[3].precision == 5)
|
74
|
-
assert(types[3].scale == 3)
|
75
|
-
assert(types[3].subtype == nil)
|
76
|
-
|
77
|
-
assert(types[4].type == SQLType::BLOB)
|
78
|
-
assert(types[4].length == nil)
|
79
|
-
assert(types[4].precision == nil)
|
80
|
-
assert(types[4].scale == nil)
|
81
|
-
assert(types[4].subtype == 1)
|
82
|
-
end
|
83
|
-
|
84
|
-
def test02
|
85
|
-
types = SQLType.for_table("all_types", @connection)
|
86
|
-
|
87
|
-
assert(types['COL01'] == SQLType.new(SQLType::BIGINT))
|
88
|
-
assert(types['COL02'] == SQLType.new(SQLType::BLOB, nil, nil, nil, 0))
|
89
|
-
assert(types['COL03'] == SQLType.new(SQLType::CHAR, 100))
|
90
|
-
assert(types['COL04'] == SQLType.new(SQLType::DATE))
|
91
|
-
assert(types['COL05'] == SQLType.new(SQLType::DECIMAL, nil, 5, 2))
|
92
|
-
assert(types['COL06'] == SQLType.new(SQLType::DOUBLE))
|
93
|
-
assert(types['COL07'] == SQLType.new(SQLType::FLOAT))
|
94
|
-
assert(types['COL08'] == SQLType.new(SQLType::INTEGER))
|
95
|
-
assert(types['COL09'] == SQLType.new(SQLType::NUMERIC, nil, 10, 3))
|
96
|
-
assert(types['COL10'] == SQLType.new(SQLType::SMALLINT))
|
97
|
-
assert(types['COL11'] == SQLType.new(SQLType::TIME))
|
98
|
-
assert(types['COL12'] == SQLType.new(SQLType::TIMESTAMP))
|
99
|
-
assert(types['COL13'] == SQLType.new(SQLType::VARCHAR, 23))
|
100
|
-
end
|
101
|
-
end
|
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 SQLTypeTest < Test::Unit::TestCase
|
11
|
+
CURDIR = "#{Dir.getwd}"
|
12
|
+
DB_FILE = "#{CURDIR}#{File::SEPARATOR}sql_type_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
|
+
@database = Database.create(DB_FILE, DB_USER_NAME, DB_PASSWORD)
|
21
|
+
@connection = @database.connect(DB_USER_NAME, DB_PASSWORD)
|
22
|
+
|
23
|
+
@connection.start_transaction do |tx|
|
24
|
+
tx.execute("create table all_types (col01 bigint, col02 blob, "\
|
25
|
+
"col03 char(100), col04 date, col05 decimal(5,2), "\
|
26
|
+
"col06 double precision, col07 float, col08 integer, "\
|
27
|
+
"col09 numeric(10,3), col10 smallint, col11 time, "\
|
28
|
+
"col12 timestamp, col13 varchar(23))")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def teardown
|
33
|
+
@connection.close if @connection != nil && @connection.open?
|
34
|
+
|
35
|
+
if File::exist?(DB_FILE)
|
36
|
+
Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
|
37
|
+
end
|
38
|
+
puts "#{self.class.name} finished." if TEST_LOGGING
|
39
|
+
end
|
40
|
+
|
41
|
+
def test01
|
42
|
+
types = []
|
43
|
+
types.push(SQLType.new(SQLType::BIGINT))
|
44
|
+
types.push(SQLType.new(SQLType::VARCHAR, 1000))
|
45
|
+
types.push(SQLType.new(SQLType::DECIMAL, nil, 10))
|
46
|
+
types.push(SQLType.new(SQLType::NUMERIC, nil, 5, 3))
|
47
|
+
types.push(SQLType.new(SQLType::BLOB, nil, nil, nil, 1))
|
48
|
+
|
49
|
+
assert(types[0] == types[0])
|
50
|
+
assert(!(types[0] == types[1]))
|
51
|
+
assert(types[1] == SQLType.new(SQLType::VARCHAR, 1000))
|
52
|
+
|
53
|
+
assert(types[0].type == SQLType::BIGINT)
|
54
|
+
assert(types[0].length == nil)
|
55
|
+
assert(types[0].precision == nil)
|
56
|
+
assert(types[0].scale == nil)
|
57
|
+
assert(types[0].subtype == nil)
|
58
|
+
|
59
|
+
assert(types[1].type == SQLType::VARCHAR)
|
60
|
+
assert(types[1].length == 1000)
|
61
|
+
assert(types[1].precision == nil)
|
62
|
+
assert(types[1].scale == nil)
|
63
|
+
assert(types[1].subtype == nil)
|
64
|
+
|
65
|
+
assert(types[2].type == SQLType::DECIMAL)
|
66
|
+
assert(types[2].length == nil)
|
67
|
+
assert(types[2].precision == 10)
|
68
|
+
assert(types[2].scale == nil)
|
69
|
+
assert(types[2].subtype == nil)
|
70
|
+
|
71
|
+
assert(types[3].type == SQLType::NUMERIC)
|
72
|
+
assert(types[3].length == nil)
|
73
|
+
assert(types[3].precision == 5)
|
74
|
+
assert(types[3].scale == 3)
|
75
|
+
assert(types[3].subtype == nil)
|
76
|
+
|
77
|
+
assert(types[4].type == SQLType::BLOB)
|
78
|
+
assert(types[4].length == nil)
|
79
|
+
assert(types[4].precision == nil)
|
80
|
+
assert(types[4].scale == nil)
|
81
|
+
assert(types[4].subtype == 1)
|
82
|
+
end
|
83
|
+
|
84
|
+
def test02
|
85
|
+
types = SQLType.for_table("all_types", @connection)
|
86
|
+
|
87
|
+
assert(types['COL01'] == SQLType.new(SQLType::BIGINT))
|
88
|
+
assert(types['COL02'] == SQLType.new(SQLType::BLOB, nil, nil, nil, 0))
|
89
|
+
assert(types['COL03'] == SQLType.new(SQLType::CHAR, 100))
|
90
|
+
assert(types['COL04'] == SQLType.new(SQLType::DATE))
|
91
|
+
assert(types['COL05'] == SQLType.new(SQLType::DECIMAL, nil, 5, 2))
|
92
|
+
assert(types['COL06'] == SQLType.new(SQLType::DOUBLE))
|
93
|
+
assert(types['COL07'] == SQLType.new(SQLType::FLOAT))
|
94
|
+
assert(types['COL08'] == SQLType.new(SQLType::INTEGER))
|
95
|
+
assert(types['COL09'] == SQLType.new(SQLType::NUMERIC, nil, 10, 3))
|
96
|
+
assert(types['COL10'] == SQLType.new(SQLType::SMALLINT))
|
97
|
+
assert(types['COL11'] == SQLType.new(SQLType::TIME))
|
98
|
+
assert(types['COL12'] == SQLType.new(SQLType::TIMESTAMP))
|
99
|
+
assert(types['COL13'] == SQLType.new(SQLType::VARCHAR, 23))
|
100
|
+
end
|
101
|
+
end
|