activerecord-jdbc-adapter 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,11 @@
1
+ == 1.1.1
2
+
3
+ - Arel 2.0.7 compatibility: fix bugs arising from use of Arel 2.0.7 +
4
+ ArJdbc 1.1.0.
5
+ - Gracefully handle changes to limit in Arel's AST
6
+ - Avoid conflict with Arel 2.0.7's mssql visitor
7
+ - Upgrade to PostgreSQL 9.0.801 JDBC drivers (David Kellum)
8
+
1
9
  == 1.1.0 (12/09/10)
2
10
 
3
11
  - Don't narrow platform to '-java' only: revert back to 0.9.2 where
data/Manifest.txt CHANGED
@@ -25,10 +25,11 @@ lib/arel/engines/sql/compilers/h2_compiler.rb
25
25
  lib/arel/engines/sql/compilers/hsqldb_compiler.rb
26
26
  lib/arel/engines/sql/compilers/jdbc_compiler.rb
27
27
  lib/arel/engines/sql/compilers/mssql_compiler.rb
28
+ lib/arel/visitors/compat.rb
28
29
  lib/arel/visitors/db2.rb
29
30
  lib/arel/visitors/derby.rb
30
31
  lib/arel/visitors/hsqldb.rb
31
- lib/arel/visitors/mssql.rb
32
+ lib/arel/visitors/sql_server.rb
32
33
  lib/arjdbc/db2.rb
33
34
  lib/arjdbc/derby.rb
34
35
  lib/arjdbc/discover.rb
@@ -1,6 +1,8 @@
1
1
  require 'arjdbc'
2
- begin
3
- require 'arjdbc/jdbc/railtie'
4
- rescue LoadError
5
- # Assume we don't have railties in this version of AR
2
+ if ActiveRecord::VERSION::MAJOR >= 3
3
+ begin
4
+ require 'arjdbc/jdbc/railtie'
5
+ rescue LoadError
6
+ # Assume we don't have railties in this version of AR
7
+ end
6
8
  end
@@ -0,0 +1,13 @@
1
+ module Arel
2
+ module Visitors
3
+ module ArJdbcCompat
4
+ def limit_for(limit_or_node)
5
+ limit_or_node.respond_to?(:expr) ? limit_or_node.expr.to_i : limit_or_node
6
+ end
7
+ end
8
+
9
+ class ToSql
10
+ include ArJdbcCompat
11
+ end
12
+ end
13
+ end
@@ -1,3 +1,5 @@
1
+ require 'arel/visitors/compat'
2
+
1
3
  module Arel
2
4
  module Visitors
3
5
  class DB2 < Arel::Visitors::ToSql
@@ -8,7 +10,7 @@ module Arel
8
10
  end
9
11
 
10
12
  def add_limit_offset(sql, o)
11
- @connection.replace_limit_offset! sql, o.limit, o.offset && o.offset.value
13
+ @connection.replace_limit_offset! sql, limit_for(o.limit), o.offset && o.offset.value
12
14
  end
13
15
  end
14
16
  end
@@ -1,3 +1,5 @@
1
+ require 'arel/visitors/compat'
2
+
1
3
  module Arel
2
4
  module Visitors
3
5
  class Derby < Arel::Visitors::ToSql
@@ -5,7 +7,7 @@ module Arel
5
7
  [
6
8
  o.cores.map { |x| visit_Arel_Nodes_SelectCore x }.join,
7
9
  ("ORDER BY #{o.orders.map { |x| visit x }.join(', ')}" unless o.orders.empty?),
8
- ("FETCH FIRST #{o.limit} ROWS ONLY" if o.limit),
10
+ ("FETCH FIRST #{limit_for(o.limit)} ROWS ONLY" if o.limit),
9
11
  (visit(o.offset) if o.offset),
10
12
  (visit(o.lock) if o.lock),
11
13
  ].compact.join ' '
@@ -1,3 +1,5 @@
1
+ require 'arel/visitors/compat'
2
+
1
3
  module Arel
2
4
  module Visitors
3
5
  class HSQLDB < Arel::Visitors::ToSql
@@ -12,7 +14,7 @@ module Arel
12
14
  offset = o.offset || 0
13
15
  bef = sql[7..-1]
14
16
  if limit = o.limit
15
- "SELECT LIMIT #{offset} #{limit} #{bef}"
17
+ "SELECT LIMIT #{offset} #{limit_for(limit)} #{bef}"
16
18
  elsif offset > 0
17
19
  "SELECT LIMIT #{offset} 0 #{bef}"
18
20
  else
@@ -1,3 +1,5 @@
1
+ require 'arel/visitors/compat'
2
+
1
3
  module Arel
2
4
  module Visitors
3
5
  class SQLServer < Arel::Visitors::ToSql
@@ -26,7 +28,7 @@ module Arel
26
28
  end
27
29
 
28
30
  order ||= "ORDER BY #{@connection.determine_order_clause(sql)}"
29
- replace_limit_offset!(sql, o.limit.to_i, o.offset && o.offset.value.to_i, order)
31
+ replace_limit_offset!(sql, limit_for(o.limit).to_i, o.offset && o.offset.value.to_i, order)
30
32
  sql = "SELECT COUNT(*) AS count_id FROM (#{sql}) AS subquery" if subquery
31
33
  elsif order
32
34
  sql << " #{order}"
@@ -99,7 +99,7 @@ module ActiveRecord
99
99
  visitor = nil
100
100
  arel2_visitors.each do |k,v|
101
101
  visitor = v
102
- visitors[k] = v unless visitors.has_key?(k)
102
+ visitors[k] = v
103
103
  end
104
104
  if visitor && config[:adapter] =~ /^(jdbc|jndi)$/
105
105
  visitors[config[:adapter]] = visitor
Binary file
@@ -35,9 +35,9 @@ module ::ArJdbc
35
35
  end
36
36
 
37
37
  def arel2_visitors
38
- require 'arel/visitors/mssql'
38
+ require 'arel/visitors/sql_server'
39
39
  visitor_class = sqlserver_version == "2000" ? ::Arel::Visitors::SQLServer2000 : ::Arel::Visitors::SQLServer
40
- { 'mssql' => visitor_class, 'jdbcmssql' => visitor_class}
40
+ { 'mssql' => visitor_class, 'sqlserver' => visitor_class, 'jdbcmssql' => visitor_class}
41
41
  end
42
42
 
43
43
  def sqlserver_version
@@ -554,6 +554,17 @@ module ::ArJdbc
554
554
  end
555
555
 
556
556
  private
557
+ def translate_exception(exception, message)
558
+ case exception.message
559
+ when /duplicate key value violates unique constraint/
560
+ RecordNotUnique.new(message, exception)
561
+ when /violates foreign key constraint/
562
+ InvalidForeignKey.new(message, exception)
563
+ else
564
+ super
565
+ end
566
+ end
567
+
557
568
  def extract_pg_identifier_from_name(name)
558
569
  match_data = name[0,1] == '"' ? name.match(/\"([^\"]+)\"/) : name.match(/([^\.]+)/)
559
570
 
@@ -1,6 +1,6 @@
1
1
  module ArJdbc
2
2
  module Version
3
- VERSION = "1.1.0"
3
+ VERSION = "1.1.1"
4
4
  end
5
5
  end
6
6
  # Compatibility with older versions of ar-jdbc for other extensions out there
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-jdbc-adapter
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 1
7
- - 1
8
- - 0
9
- version: 1.1.0
4
+ prerelease:
5
+ version: 1.1.1
10
6
  platform: ruby
11
7
  authors:
12
8
  - Nick Sieger, Ola Bini and JRuby contributors
@@ -14,7 +10,7 @@ autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
12
 
17
- date: 2010-12-09 00:00:00 -06:00
13
+ date: 2011-01-14 00:00:00 -06:00
18
14
  default_executable:
19
15
  dependencies:
20
16
  - !ruby/object:Gem::Dependency
@@ -25,10 +21,6 @@ dependencies:
25
21
  requirements:
26
22
  - - ">="
27
23
  - !ruby/object:Gem::Version
28
- segments:
29
- - 2
30
- - 0
31
- - 4
32
24
  version: 2.0.4
33
25
  type: :development
34
26
  version_requirements: *id001
@@ -40,10 +32,6 @@ dependencies:
40
32
  requirements:
41
33
  - - ">="
42
34
  - !ruby/object:Gem::Version
43
- segments:
44
- - 2
45
- - 6
46
- - 2
47
35
  version: 2.6.2
48
36
  type: :development
49
37
  version_requirements: *id002
@@ -89,10 +77,11 @@ files:
89
77
  - lib/arel/engines/sql/compilers/hsqldb_compiler.rb
90
78
  - lib/arel/engines/sql/compilers/jdbc_compiler.rb
91
79
  - lib/arel/engines/sql/compilers/mssql_compiler.rb
80
+ - lib/arel/visitors/compat.rb
92
81
  - lib/arel/visitors/db2.rb
93
82
  - lib/arel/visitors/derby.rb
94
83
  - lib/arel/visitors/hsqldb.rb
95
- - lib/arel/visitors/mssql.rb
84
+ - lib/arel/visitors/sql_server.rb
96
85
  - lib/arjdbc/db2.rb
97
86
  - lib/arjdbc/derby.rb
98
87
  - lib/arjdbc/discover.rb
@@ -257,21 +246,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
257
246
  requirements:
258
247
  - - ">="
259
248
  - !ruby/object:Gem::Version
260
- segments:
261
- - 0
262
249
  version: "0"
263
250
  required_rubygems_version: !ruby/object:Gem::Requirement
264
251
  none: false
265
252
  requirements:
266
253
  - - ">="
267
254
  - !ruby/object:Gem::Version
268
- segments:
269
- - 0
270
255
  version: "0"
271
256
  requirements: []
272
257
 
273
258
  rubyforge_project: jruby-extras
274
- rubygems_version: 1.3.7
259
+ rubygems_version: 1.4.2
275
260
  signing_key:
276
261
  specification_version: 3
277
262
  summary: JDBC adapter for ActiveRecord, for use within JRuby on Rails.