fb 0.5.9 → 0.5.10
Sign up to get free protection for your applications and to get access to all the features.
- data/fb.c +10 -5
- data/test/DataTypesTestCases.rb +68 -0
- data/test/FbTestCases.rb +1 -1
- metadata +6 -4
data/fb.c
CHANGED
@@ -1924,8 +1924,7 @@ static VALUE fb_cursor_fetch(struct FbCursor *fb_cursor)
|
|
1924
1924
|
case SQL_SHORT:
|
1925
1925
|
if (var->sqlscale < 0) {
|
1926
1926
|
ratio = 1;
|
1927
|
-
for (scnt = 0; scnt > var->sqlscale; scnt--)
|
1928
|
-
ratio *= 10;
|
1927
|
+
for (scnt = 0; scnt > var->sqlscale; scnt--) ratio *= 10;
|
1929
1928
|
dval = (double)*(short*)var->sqldata/ratio;
|
1930
1929
|
val = rb_float_new(dval);
|
1931
1930
|
} else {
|
@@ -1936,8 +1935,7 @@ static VALUE fb_cursor_fetch(struct FbCursor *fb_cursor)
|
|
1936
1935
|
case SQL_LONG:
|
1937
1936
|
if (var->sqlscale < 0) {
|
1938
1937
|
ratio = 1;
|
1939
|
-
for (scnt = 0; scnt > var->sqlscale; scnt--)
|
1940
|
-
ratio *= 10;
|
1938
|
+
for (scnt = 0; scnt > var->sqlscale; scnt--) ratio *= 10;
|
1941
1939
|
dval = (double)*(long*)var->sqldata/ratio;
|
1942
1940
|
val = rb_float_new(dval);
|
1943
1941
|
} else {
|
@@ -1954,7 +1952,14 @@ static VALUE fb_cursor_fetch(struct FbCursor *fb_cursor)
|
|
1954
1952
|
break;
|
1955
1953
|
#if HAVE_LONG_LONG
|
1956
1954
|
case SQL_INT64:
|
1957
|
-
|
1955
|
+
if (var->sqlscale < 0) {
|
1956
|
+
ratio = 1;
|
1957
|
+
for (scnt = 0; scnt > var->sqlscale; scnt--) ratio *= 10;
|
1958
|
+
dval = (double)*(long*)var->sqldata/ratio;
|
1959
|
+
val = rb_float_new(dval);
|
1960
|
+
} else {
|
1961
|
+
val = LL2NUM(*(LONG_LONG*)var->sqldata);
|
1962
|
+
}
|
1958
1963
|
break;
|
1959
1964
|
#endif
|
1960
1965
|
case SQL_TIMESTAMP:
|
data/test/DataTypesTestCases.rb
CHANGED
@@ -68,6 +68,34 @@ class DataTypesTestCases < Test::Unit::TestCase
|
|
68
68
|
i * 100
|
69
69
|
end
|
70
70
|
|
71
|
+
def sum_i(range)
|
72
|
+
range.inject(0) { |m, i| m + gen_i(i) }
|
73
|
+
end
|
74
|
+
|
75
|
+
def sum_si(range)
|
76
|
+
range.inject(0) { |m, i| m + gen_si(i) }
|
77
|
+
end
|
78
|
+
|
79
|
+
def sum_bi(range)
|
80
|
+
range.inject(0) { |m, i| m + gen_bi(i) }
|
81
|
+
end
|
82
|
+
|
83
|
+
def sum_f(range)
|
84
|
+
range.inject(0) { |m, i| m + gen_f(i) }
|
85
|
+
end
|
86
|
+
|
87
|
+
def sum_d(range)
|
88
|
+
range.inject(0) { |m, i| m + gen_d(i) }
|
89
|
+
end
|
90
|
+
|
91
|
+
def sum_n92(range)
|
92
|
+
range.inject(0) { |m, i| m + gen_n92(i) }
|
93
|
+
end
|
94
|
+
|
95
|
+
def sum_d92(range)
|
96
|
+
range.inject(0) { |m, i| m + gen_d92(i) }
|
97
|
+
end
|
98
|
+
|
71
99
|
def test_insert_basic_types
|
72
100
|
sql_schema = <<-END
|
73
101
|
create table TEST (
|
@@ -94,6 +122,10 @@ class DataTypesTestCases < Test::Unit::TestCase
|
|
94
122
|
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);
|
95
123
|
END
|
96
124
|
sql_select = "select * from TEST order by I"
|
125
|
+
sql_sum = "select sum(I), sum(SI), sum(BI), sum(F), sum(D), sum(N92), sum(D92) from TEST"
|
126
|
+
sql_avg = "select avg(I), avg(SI), avg(BI), avg(F), avg(D), avg(N92), avg(D92) from TEST"
|
127
|
+
sql_max = "select max(I), max(SI), max(BI), max(F), max(D), max(N92), max(D92) from TEST"
|
128
|
+
sql_min = "select min(I), min(SI), min(BI), min(F), min(D), min(N92), min(D92) from TEST"
|
97
129
|
Database.create(@parms) do |connection|
|
98
130
|
connection.execute(sql_schema);
|
99
131
|
connection.transaction do
|
@@ -128,6 +160,42 @@ class DataTypesTestCases < Test::Unit::TestCase
|
|
128
160
|
i += 1
|
129
161
|
end
|
130
162
|
end
|
163
|
+
|
164
|
+
sums = connection.query(sql_sum).first
|
165
|
+
assert_equal sum_i(0...10), sums[0], "INTEGER"
|
166
|
+
assert_equal sum_si(0...10), sums[1], "SMALLINT"
|
167
|
+
assert_equal sum_bi(0...10), sums[2], "BIGINT"
|
168
|
+
assert_equal sum_f(0...10), sums[3], "FLOAT"
|
169
|
+
assert_equal sum_d(0...10), sums[4], "DOUBLE PRECISION"
|
170
|
+
assert_equal sum_n92(0...10), sums[5], "NUMERIC" # 4500.00
|
171
|
+
assert_equal sum_d92(0...10), sums[6], "DECIMAL" # 4500.00
|
172
|
+
|
173
|
+
avgs = connection.query(sql_avg).first
|
174
|
+
assert_equal sum_i(0...10) / 10, avgs[0], "INTEGER"
|
175
|
+
assert_equal sum_si(0...10) / 10, avgs[1], "SMALLINT"
|
176
|
+
assert_equal sum_bi(0...10) / 10, avgs[2], "BIGINT"
|
177
|
+
assert_equal sum_f(0...10) / 10, avgs[3], "FLOAT"
|
178
|
+
assert_equal sum_d(0...10) / 10, avgs[4], "DOUBLE PRECISION"
|
179
|
+
assert_equal sum_n92(0...10) / 10, avgs[5], "NUMERIC" # 450.00
|
180
|
+
assert_equal sum_d92(0...10) / 10, avgs[6], "DECIMAL" # 450.00
|
181
|
+
|
182
|
+
maxs = connection.query(sql_max).first
|
183
|
+
assert_equal gen_i(9), maxs[0], "INTEGER"
|
184
|
+
assert_equal gen_si(9), maxs[1], "SMALLINT"
|
185
|
+
assert_equal gen_bi(9), maxs[2], "BIGINT"
|
186
|
+
assert_equal gen_f(9), maxs[3], "FLOAT"
|
187
|
+
assert_equal gen_d(9), maxs[4], "DOUBLE PRECISION"
|
188
|
+
assert_equal gen_n92(9), maxs[5], "NUMERIC"
|
189
|
+
assert_equal gen_d92(9), maxs[6], "DECIMAL"
|
190
|
+
|
191
|
+
mins = connection.query(sql_min).first
|
192
|
+
assert_equal gen_i(0), mins[0], "INTEGER"
|
193
|
+
assert_equal gen_si(0), mins[1], "SMALLINT"
|
194
|
+
assert_equal gen_bi(0), mins[2], "BIGINT"
|
195
|
+
assert_equal gen_f(0), mins[3], "FLOAT"
|
196
|
+
assert_equal gen_d(0), mins[4], "DOUBLE PRECISION"
|
197
|
+
assert_equal gen_n92(0), mins[5], "NUMERIC"
|
198
|
+
assert_equal gen_d92(0), mins[6], "DECIMAL"
|
131
199
|
connection.drop
|
132
200
|
end
|
133
201
|
end
|
data/test/FbTestCases.rb
CHANGED
@@ -8,7 +8,7 @@ module FbTestCases
|
|
8
8
|
def setup
|
9
9
|
@db_file = case RUBY_PLATFORM
|
10
10
|
when /win32/ then 'c:/var/fbdata/drivertest.fdb'
|
11
|
-
when /darwin/ then '
|
11
|
+
when /darwin/ then File.join(File.expand_path(File.dirname(__FILE__)), 'drivertest.fdb')
|
12
12
|
else '/var/fbdata/drivertest.fdb'
|
13
13
|
end
|
14
14
|
@db_host = 'localhost'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brent Rowland
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-05-26 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -34,6 +34,8 @@ files:
|
|
34
34
|
- test/TransactionTestCases.rb
|
35
35
|
has_rdoc: true
|
36
36
|
homepage: http://www.rowlandresearch.com/ruby/
|
37
|
+
licenses: []
|
38
|
+
|
37
39
|
post_install_message:
|
38
40
|
rdoc_options:
|
39
41
|
- --title
|
@@ -59,9 +61,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
59
61
|
requirements:
|
60
62
|
- Firebird client library fbclient.dll
|
61
63
|
rubyforge_project: fblib
|
62
|
-
rubygems_version: 1.3.
|
64
|
+
rubygems_version: 1.3.3
|
63
65
|
signing_key:
|
64
|
-
specification_version:
|
66
|
+
specification_version: 3
|
65
67
|
summary: Firebird and Interbase driver
|
66
68
|
test_files:
|
67
69
|
- test/FbTestSuite.rb
|