activerecord-jdbc-adapter 1.3.8 → 1.3.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bdd070e64ed269bffd40cf0a8664f09964f771d5
4
- data.tar.gz: 1e14ca7c497d7bddb3bbdca2bcfa4da04acfebcf
3
+ metadata.gz: fb8275489a147bf60f8705498a80efe51ec395cc
4
+ data.tar.gz: 757b6d0d663b6d94499d42bb4aa27873456b1034
5
5
  SHA512:
6
- metadata.gz: 19d45b4f7f4edcace3341a1641b24ee7e3e98bb8e2f7a4853cfa9cc6877eeffbbc5e56f86e2f98e37c9df6af3a85a0afa02a346f381498a87e71d36ddffa3eae
7
- data.tar.gz: 349a9d32b318d73fc0f549a81c2dc5d38367629e1694597e47efae4aeea2ff6ca70e1f07cb750d453955781378f021149a2ae46994b111667db66d39a3a5f87c
6
+ metadata.gz: 309e8913e85548dc626989380c8b6d0f3cd5cd66e98912b30d160995cb69e1b984a2671004c7ca26b8e5c5b2e4b0ab003e451958fa6656f25643a03aca296e09
7
+ data.tar.gz: 67e41e8ef986c2d4bc113f8d85a5ed5e2ef947e353ca6dd75fa607ebb1cbbc09a0d502afafc017a29e9927bd248dd5d05c6b44ccbd8cadfe72f1ddfa3618ff63
data/Appraisals CHANGED
@@ -12,17 +12,17 @@ appraise "rails31" do
12
12
  end
13
13
 
14
14
  appraise "rails32" do
15
- gem "activerecord", "~> 3.2.18", :require => false
15
+ gem "activerecord", "~> 3.2.19", :require => false
16
16
  end
17
17
 
18
18
  appraise "rails40" do
19
19
  # NOTE: make sure you're using --1.9 with AR-4.0
20
- gem "activerecord", "~> 4.0.6", :require => false
20
+ gem "activerecord", "~> 4.0.8", :require => false
21
21
  end
22
22
 
23
23
  appraise "rails41" do
24
24
  # NOTE: make sure you're using --1.9 with AR-4.0
25
- gem "activerecord", "~> 4.1.2", :require => false
25
+ gem "activerecord", "~> 4.1.4", :require => false
26
26
  end
27
27
 
28
28
  appraise "rails42" do
data/History.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 1.3.9 (07/07/14)
2
+
3
+ - [postgres] improve Range's type cast - fixing minor quoting failure on AR 4.x
4
+ - [postgres] range type's :exclude_start is actually += 1 (align with AR 4.1)
5
+ - [postgres] correctly quote numeric values with string/text column types
6
+ - [postgres] backport CVE-2014-3483 and protect against CVE-2014-3482 (from AR)
7
+
1
8
  ## 1.3.8 (06/27/14)
2
9
 
3
10
  - [mysql] updated so that we can run with non-official driver (+ against MariaDB)
data/Rakefile CHANGED
@@ -20,21 +20,19 @@ ADAPTERS = %w[derby h2 hsqldb mssql mysql postgresql sqlite3].map { |a| "activer
20
20
  DRIVERS = %w[derby h2 hsqldb jtds mysql postgres sqlite3].map { |a| "jdbc-#{a}" }
21
21
  TARGETS = ( ADAPTERS + DRIVERS )
22
22
 
23
- def rake(*args)
24
- ruby "-S", "rake", *args
25
- end
23
+ rake = lambda { |task| ruby "-S", "rake", task }
26
24
 
27
25
  TARGETS.each do |target|
28
26
  namespace target do
29
27
  task :build do
30
- Dir.chdir(target) { rake "build" }
28
+ Dir.chdir(target) { rake.call "build" }
31
29
  cp FileList["#{target}/pkg/#{target}-*.gem"], "pkg"
32
30
  end
33
31
  task :install do
34
- Dir.chdir(target) { rake "install" }
32
+ Dir.chdir(target) { rake.call "install" }
35
33
  end
36
34
  task :release do
37
- Dir.chdir(target) { rake "release" }
35
+ Dir.chdir(target) { rake.call "release" }
38
36
  end
39
37
  end
40
38
  end
@@ -43,37 +41,44 @@ end
43
41
 
44
42
  desc "Build drivers"
45
43
  task "build:drivers" => DRIVERS.map { |name| "#{name}:build" }
46
- task "drivers:build" => DRIVERS.map { |name| "#{name}:build" }
44
+ task "drivers:build" => 'build:drivers'
47
45
 
48
46
  desc "Install drivers"
49
47
  task "install:drivers" => DRIVERS.map { |name| "#{name}:install" }
50
- task "drivers:install" => DRIVERS.map { |name| "#{name}:install" }
48
+ task "drivers:install" => 'install:drivers'
51
49
 
52
- desc "Release drivers"
53
- task "release:drivers" => DRIVERS.map { |name| "#{name}:release" }
54
- task "drivers:release" => DRIVERS.map { |name| "#{name}:release" }
50
+ # desc "Release drivers"
51
+ # task "release:drivers" => DRIVERS.map { |name| "#{name}:release" }
52
+ # task "drivers:release" => DRIVERS.map { |name| "#{name}:release" }
55
53
 
56
54
  # ADAPTERS
57
55
 
58
56
  desc "Build adapters"
59
57
  task "build:adapters" => [ 'build' ] + ADAPTERS.map { |name| "#{name}:build" }
60
- task "adapters:build" => [ 'build' ] + ADAPTERS.map { |name| "#{name}:build" }
58
+ task "adapters:build" => 'build:adapters'
61
59
 
62
60
  desc "Install adapters"
63
61
  task "install:adapters" => [ 'install' ] + ADAPTERS.map { |name| "#{name}:install" }
64
- task "adapters:install" => [ 'install' ] + ADAPTERS.map { |name| "#{name}:install" }
62
+ task "adapters:install" => 'install:adapters'
65
63
 
66
64
  desc "Release adapters"
67
65
  task "release:adapters" => [ 'release' ] + ADAPTERS.map { |name| "#{name}:release" }
68
- task "adapters:release" => [ 'release' ] + ADAPTERS.map { |name| "#{name}:release" }
66
+ task "adapters:release" => 'release:adapters'
67
+
68
+ task 'release:do' => 'build:adapters' do
69
+ gemspec = Bundler.load_gemspec('activerecord-jdbc-adapter.gemspec')
70
+ version = gemspec.version; version_tag = "v#{version}"
71
+
72
+ sh("git diff --no-patch --exit-code") { |ok| fail "git working dir is not clean" unless ok }
73
+ sh("git diff-index --quiet --cached HEAD") { |ok| fail "git index is not clean" unless ok }
74
+
75
+ sh "git tag -a -m \"AR-JDBC #{version}\" #{version_tag}"
76
+ sh "for gem in `ls pkg/*-#{version}.gem`; do gem push $gem; done"
77
+ end
69
78
 
70
79
  # ALL
71
80
 
72
81
  task "build:all" => [ 'build' ] + TARGETS.map { |name| "#{name}:build" }
73
- task "all:build" => [ 'build' ] + TARGETS.map { |name| "#{name}:build" }
82
+ task "all:build" => 'build:all'
74
83
  task "install:all" => [ 'install' ] + TARGETS.map { |name| "#{name}:install" }
75
- task "all:install" => [ 'install' ] + TARGETS.map { |name| "#{name}:install" }
76
-
77
- task :filelist do
78
- puts FileList['pkg/**/*'].inspect
79
- end
84
+ task "all:install" => 'install:all'
@@ -818,8 +818,9 @@ module ArJdbc
818
818
  end
819
819
  when Numeric
820
820
  if column.respond_to?(:sql_type) && column.sql_type == 'money'
821
- # not truly string input, so doesn't require (or allow) escape syntax :
822
- ( column.type == :string || column.type == :text ) ? "'#{value}'" : super
821
+ "'#{value}'"
822
+ elsif column.type == :string || column.type == :text
823
+ "'#{value}'"
823
824
  else super
824
825
  end
825
826
  when String
@@ -849,9 +850,11 @@ module ArJdbc
849
850
  else super
850
851
  end
851
852
  when Range
852
- if column.type.to_s[-5..-1] == 'range' # :'xxxrange' only in AR-4.0
853
+ sql_type = column.respond_to?(:sql_type) && column.sql_type
854
+ if sql_type && sql_type[-5, 5] == 'range' && AR4_COMPAT
853
855
  column_class = ::ActiveRecord::ConnectionAdapters::PostgreSQLColumn
854
- "'#{column_class.range_to_string(value)}'::#{column.sql_type}"
856
+ escaped = quote_string(column_class.range_to_string(value))
857
+ "'#{escaped}'::#{sql_type}"
855
858
  else super
856
859
  end
857
860
  when IPAddr
@@ -885,8 +888,8 @@ module ArJdbc
885
888
  # "0101" will be treated as binary string
886
889
  # "0100" will be treated as binary string
887
890
  # ... but is kept due Rails compatibility
888
- when /^[01]*$/ then "B'#{value}'" # Bit-string notation
889
- when /^[0-9A-F]*$/i then "X'#{value}'" # Hexadecimal notation
891
+ when /\A[01]*\Z/ then "B'#{value}'" # Bit-string notation
892
+ when /\A[0-9A-F]*\Z/i then "X'#{value}'" # Hexadecimal notation
890
893
  end
891
894
  end
892
895
 
@@ -1272,9 +1275,9 @@ module ActiveRecord::ConnectionAdapters
1272
1275
  else # NOTE: AR <= 3.2 : (name, default, sql_type = nil, null = true)
1273
1276
  null, sql_type, oid_type = !! sql_type, oid_type, nil
1274
1277
  end
1275
- if sql_type =~ /\[\]$/ && ArJdbc::PostgreSQL::AR4_COMPAT
1278
+ if sql_type.to_s[-2, 2] == '[]' && ArJdbc::PostgreSQL::AR4_COMPAT
1276
1279
  @array = true if respond_to?(:array)
1277
- super(name, default, sql_type[0..sql_type.length - 3], null)
1280
+ super(name, default, sql_type[0..-3], null)
1278
1281
  else
1279
1282
  @array = false if respond_to?(:array)
1280
1283
  super(name, default, sql_type, null)
@@ -147,41 +147,47 @@ module ArJdbc
147
147
  when :tsvector then value
148
148
  when :datetime, :timestamp then self.class.string_to_time value
149
149
  else
150
- case sql_type
151
- when 'money'
150
+ if ( sql_type = self.sql_type.to_s ) == 'money'
152
151
  self.class.string_to_money(value)
153
- when /^point/
152
+ elsif sql_type[0, 5] == 'point'
154
153
  value.is_a?(String) ? self.class.string_to_point(value) : value
155
- when /^(bit|varbit)/
154
+ elsif sql_type[0, 3] == 'bit' || sql_type[0, 6] == 'varbit'
156
155
  value.is_a?(String) ? self.class.string_to_bit(value) : value
157
- when /(.*?)range$/
156
+ elsif sql_type[-5, 5] == 'range'
158
157
  return if value.nil? || value == 'empty'
159
158
  return value if value.is_a?(::Range)
160
159
 
161
160
  extracted = extract_bounds(value)
162
161
 
163
- case $1 # subtype
162
+ case sql_type[0...-5] # range sub-type
164
163
  when 'date' # :date
165
164
  from = self.class.value_to_date(extracted[:from])
166
- from -= 1.day if extracted[:exclude_start]
165
+ from += 1.day if extracted[:exclude_start]
167
166
  to = self.class.value_to_date(extracted[:to])
168
167
  when 'num' # :decimal
169
- from = BigDecimal.new(extracted[:from].to_s)
168
+ from = ::BigDecimal.new(extracted[:from].to_s)
170
169
  # FIXME: add exclude start for ::Range, same for timestamp ranges
171
- to = BigDecimal.new(extracted[:to].to_s)
170
+ to = ::BigDecimal.new(extracted[:to].to_s)
172
171
  when 'ts', 'tstz' # :time
173
172
  from = self.class.string_to_time(extracted[:from])
174
173
  to = self.class.string_to_time(extracted[:to])
175
174
  when 'int4', 'int8' # :integer
176
- from = to_integer(extracted[:from]) rescue value ? 1 : 0
177
- from -= 1 if extracted[:exclude_start]
178
- to = to_integer(extracted[:to]) rescue value ? 1 : 0
175
+ from = extracted[:from]
176
+ unless (from.respond_to?(:infinite?) && from.infinite?)
177
+ from = from.respond_to?(:to_i) ? from.to_i : ( value ? 1 : 0 )
178
+ end
179
+ from += 1 if extracted[:exclude_start]
180
+ to = extracted[:to]
181
+ unless (to.respond_to?(:infinite?) && to.infinite?)
182
+ to = to.respond_to?(:to_i) ? to.to_i : ( value ? 1 : 0 )
183
+ end
179
184
  else
180
185
  return value
181
186
  end
182
187
 
183
188
  ::Range.new(from, to, extracted[:exclude_end])
184
- else super(value)
189
+ else
190
+ super(value)
185
191
  end
186
192
  end
187
193
  end if AR4_COMPAT
@@ -321,10 +327,6 @@ module ArJdbc
321
327
  ::Float::INFINITY * (options[:negative] ? -1 : 1)
322
328
  end if AR4_COMPAT
323
329
 
324
- def to_integer(value)
325
- (value.respond_to?(:infinite?) && value.infinite?) ? value : value.to_i
326
- end if AR4_COMPAT
327
-
328
330
  # @note Based on *active_record/connection_adapters/postgresql/cast.rb* (4.0).
329
331
  module Cast
330
332
 
@@ -1,5 +1,6 @@
1
1
  module ArJdbc
2
2
  module PostgreSQL
3
+ # @private
3
4
  module ExplainSupport
4
5
  def supports_explain?
5
6
  true
@@ -10,8 +11,8 @@ module ArJdbc
10
11
  result = exec_query(sql, "EXPLAIN", binds)
11
12
  ExplainPrettyPrinter.new.pp result # we can assume AR >= 3.1
12
13
  end
13
-
14
- class ExplainPrettyPrinter # :nodoc:
14
+ # @private
15
+ class ExplainPrettyPrinter
15
16
  # Pretty prints the result of a EXPLAIN in a way that resembles the output of the
16
17
  # PostgreSQL shell:
17
18
  #
@@ -3,6 +3,7 @@ require 'thread'
3
3
 
4
4
  module ArJdbc
5
5
  module PostgreSQL
6
+ # @private
6
7
  module OIDTypes
7
8
 
8
9
  OID = ActiveRecord::ConnectionAdapters::PostgreSQL::OID
@@ -1,8 +1,8 @@
1
1
  module ArJdbc
2
- VERSION = "1.3.8"
2
+ VERSION = "1.3.9"
3
3
  # @deprecated
4
4
  module Version
5
5
  # @private 1.2.x compatibility
6
6
  VERSION = ArJdbc::VERSION
7
7
  end
8
- end
8
+ end
@@ -215,7 +215,7 @@ public class MySQLRubyJdbcConnection extends RubyJdbcConnection {
215
215
  }
216
216
  }
217
217
 
218
- return runtime.newArray(indexes);
218
+ return indexes;
219
219
  }
220
220
  finally {
221
221
  close(keySet);
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-jdbc-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.8
4
+ version: 1.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Sieger, Ola Bini, Karol Bucek and JRuby contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-27 00:00:00.000000000 Z
11
+ date: 2014-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord