jdbc-helper 0.4.8 → 0.4.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -65,13 +65,43 @@ private
65
65
  @rset = rset
66
66
  @rsmd = @rset.get_meta_data
67
67
  @num_col = @rsmd.get_column_count
68
- @cols_meta = []
69
68
  @getters = []
70
69
  @col_labels = []
71
70
  @col_labels_d = []
72
71
  (1..@num_col).each do | i |
73
- @cols_meta << @rsmd.get_column_type(i)
74
- @getters << JDBCHelper::Connection::GETTER_MAP.fetch(@cols_meta.last, :get_string)
72
+ type = @rsmd.get_column_type(i)
73
+
74
+ @getters <<
75
+ case type
76
+ when java.sql.Types::NUMERIC, java.sql.Types::DECIMAL
77
+ precision = @rsmd.get_precision(i)
78
+ scale = @rsmd.get_scale(i)
79
+
80
+ if precision > 0 && scale >= 0
81
+ # Numbers with fractional parts
82
+ if scale > 0
83
+ if precision <= 16
84
+ :getFloat
85
+ else
86
+ :getString
87
+ end
88
+ # Numbers without fractional parts
89
+ else
90
+ if precision <= 9
91
+ :getInt
92
+ elsif precision <= 18
93
+ :getLong
94
+ else
95
+ :getString
96
+ end
97
+ end
98
+ # No guarantee
99
+ else
100
+ :getString
101
+ end
102
+ else
103
+ JDBCHelper::Connection::GETTER_MAP.fetch(type, :get_string)
104
+ end
75
105
 
76
106
  @col_labels << @rsmd.get_column_label(i)
77
107
  @col_labels_d << @col_labels.last.downcase
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: jdbc-helper
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.4.8
5
+ version: 0.4.10
6
6
  platform: ruby
7
7
  authors:
8
8
  - Junegunn Choi
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-07-12 00:00:00 Z
13
+ date: 2011-08-09 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
121
  requirements: []
122
122
 
123
123
  rubyforge_project:
124
- rubygems_version: 1.8.5
124
+ rubygems_version: 1.8.6
125
125
  signing_key:
126
126
  specification_version: 3
127
127
  summary: A JDBC helper for JRuby/Database developers.