activerecord-jdbc-adapter 1.3.4 → 1.3.5

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: 928b3af97782b45db074f63a7c5a3242e7223ea9
4
- data.tar.gz: ad5a1f8133f58957d7ab2f9678367523b85c29a9
3
+ metadata.gz: a2ea14fa2985e6b568284ddd24df9db9511f6437
4
+ data.tar.gz: 72570ca5a15d8f3bd04b3efc5c9b3c7b86911215
5
5
  SHA512:
6
- metadata.gz: be7f8bbb664f74030fc79097e8f6b673b5ed93acfc348271ccfe6fa9b1e3c3098f34afbb071d597bdb8dad561828c0912a443516848a43dfd56f19653fbe7c4a
7
- data.tar.gz: 60516ac2d7c14bb124b8215400368152014ff00e32a8a9b4c7790cdbcb4eaf8fe9c3ffc3510d23e20277850469e9d41a2ab23d8e2640a0ba0206ea41e1bd81c4
6
+ metadata.gz: 72bbce793d260cfdd46f81007543bd0e6aff6a81149b45e0d21de5cef98e0c96b6cdb1127b1dc7ab03a372510a664c70996dd879ca7d7a53f5a3b32f89466a0e
7
+ data.tar.gz: 07087ad9b681f0c0d6cb4008fc5f432991baf24fd62615e9864d8c420938c8585767c324493c239888ff50550bd76aa1b5a3e943eb0716d4a14615dbd36ad39d
@@ -2,6 +2,9 @@ language: ruby
2
2
  bundler_args: --without development
3
3
  script: bundle exec rake test_$DB
4
4
  before_script: export JRUBY_OPTS="--server -Xcext.enabled=false -Xcompile.invokedynamic=false"
5
+ before_install:
6
+ #- gem update --system 2.1.11
7
+ #- 'ruby -e "puts RUBY_VERSION" | grep ^1\.8 && gem update --system -v 2.1.11 || true'
5
8
  rvm:
6
9
  - jruby
7
10
  gemfile:
@@ -37,8 +40,8 @@ branches:
37
40
  - master
38
41
  - 1-2-stable
39
42
  matrix:
40
- allow_failures:
41
- - gemfile: gemfiles/rails41.gemfile
43
+ #allow_failures:
44
+ #- gemfile: gemfiles/rails41.gemfile
42
45
  exclude:
43
46
  # Rails 4 prefers Ruby 2.0 (or at least >= 1.9.3) :
44
47
  - rvm: jruby
data/Gemfile CHANGED
@@ -26,6 +26,7 @@ gem 'mocha', '~> 0.13.1', :require => nil, :group => :test
26
26
 
27
27
  gem 'simplecov', :require => nil, :group => :test
28
28
  gem 'bcrypt-ruby', '~> 3.0.0', :require => nil, :group => :test
29
+ #gem 'trinidad_dbpool', :require => nil, :group => :test
29
30
 
30
31
  group :rails do
31
32
  gem 'erubis', :require => nil
data/History.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## 1.3.5 (01/10/14)
2
+
3
+ We're now green against Rails 4.1 (master), test and report issues if any.
4
+
5
+ - improved support for `config[:jndi]` with all supported custom adapters
6
+ - [mysql] fix incompatible character encodings: ASCII-8BIT and UTF-8
7
+ - rails 4.1 - create_table_definition changed from 3 to 4 parameters (#522)
8
+ - [firebird] Insert quotes for blobs to prevent failed inserts on not-null cols
9
+
10
+ Code Contributors: Ray Zane, Gary S. Weaver
11
+ Code Contributors: @rzane, @garysweaver
12
+
1
13
  ## 1.3.4 (12/12/13)
2
14
 
3
15
  - [postgres] unwrap connection instead of casting when adding custom types (#515)
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012-2013 Karol Bucek <self@kares.org>
1
+ Copyright (c) 2012-2014 Karol Bucek <self@kares.org>
2
2
  Copyright (c) 2006-2012 Nick Sieger <nick@nicksieger.com>
3
3
  Copyright (c) 2006-2008 Ola Bini <ola.bini@gmail.com>
4
4
 
data/README.md CHANGED
@@ -95,15 +95,19 @@ development:
95
95
  url: jdbc:mysql://localhost:3306/blog_development
96
96
  ```
97
97
 
98
- For JNDI data sources, you may simply specify the JNDI location as follows (the
99
- correct database type will be automatically detected):
98
+ For JNDI data sources, you may simply specify the JNDI location as follows, it's
99
+ recommended to use the same adapter: setting as one would configure when using
100
+ "bare" (JDBC) connections e.g. :
100
101
 
101
102
  ```yml
102
103
  production:
103
- adapter: jndi # jdbc
104
+ adapter: postgresql
104
105
  jndi: jdbc/PostgreDS
105
106
  ```
106
107
 
108
+ **NOTE:** any other settings such as *database:*, *username:*, *properties:* make
109
+ no difference since everything is already configured on the JNDI DataSource end.
110
+
107
111
  JDBC driver specific properties might be set if you use an URL to specify the DB
108
112
  or preferably using the *properties:* syntax:
109
113
 
@@ -238,8 +242,10 @@ ask on the #JRuby IRC channel on http://freenode.net/ (try [web-chat][6]).
238
242
 
239
243
  ## Authors
240
244
 
241
- This project was written by Nick Sieger <nick@nicksieger.com> and Ola Bini
242
- <olabini@gmail.com> with lots of help from the JRuby community.
245
+ This project was originally written by [Nick Sieger](http://github.com/nicksieger)
246
+ and [Ola Bini](http://github.com/olabini) with lots of help from the JRuby community.
247
+ Polished 3.x compatibility and 4.x support (for AR-JDBC >= 1.3.0) was managed by
248
+ [Karol Bucek](http://github.com/kares) among others.
243
249
 
244
250
  ## License
245
251
 
@@ -6,8 +6,8 @@ Gem::Specification.new do |gem|
6
6
  gem.name = 'activerecord-jdbc-adapter'
7
7
  gem.version = ArJdbc::VERSION
8
8
  gem.platform = Gem::Platform::RUBY
9
- gem.authors = ['Nick Sieger, Ola Bini and JRuby contributors']
10
- gem.email = ['nick@nicksieger.com', 'ola.bini@gmail.com']
9
+ gem.authors = ['Nick Sieger, Ola Bini, Karol Bucek and JRuby contributors']
10
+ gem.email = ['nick@nicksieger.com', 'ola.bini@gmail.com', 'self@kares.org']
11
11
  gem.homepage = 'https://github.com/jruby/activerecord-jdbc-adapter'
12
12
  gem.license = "BSD"
13
13
  gem.summary = 'JDBC adapter for ActiveRecord, for use within JRuby on Rails.'
@@ -428,6 +428,11 @@ module ArJdbc
428
428
  @connection.execute_update "call sysproc.admin_cmd('RUNSTATS ON TABLE #{tablename} WITH DISTRIBUTION AND DETAILED INDEXES ALL UTIL_IMPACT_PRIORITY #{priority}')"
429
429
  end
430
430
 
431
+ def select(sql, name, binds)
432
+ # DB2 does not like "= NULL", "!= NULL", or "<> NULL".
433
+ exec_query(to_sql(sql.gsub(/(!=|<>)\s*null/i, "IS NOT NULL").gsub(/=\s*null/i, "IS NULL"), binds), name, binds)
434
+ end
435
+
431
436
  def add_index(table_name, column_name, options = {})
432
437
  if ! zos? || ( table_name.to_s == ActiveRecord::Migrator.schema_migrations_table_name.to_s )
433
438
  column_name = column_name.to_s if column_name.is_a?(Symbol)
@@ -1,6 +1,10 @@
1
1
  ArJdbc::ConnectionMethods.module_eval do
2
2
  # @note Assumes DB2 driver (*db2jcc.jar*) is on class-path.
3
3
  def db2_connection(config)
4
+ config[:adapter_spec] ||= ::ArJdbc::DB2
5
+
6
+ return jndi_connection(config) if jndi_config?(config)
7
+
4
8
  config[:url] ||= begin
5
9
  if config[:host] # Type 4 URL: jdbc:db2://server:port/database
6
10
  config[:port] ||= 50000
@@ -10,7 +14,6 @@ ArJdbc::ConnectionMethods.module_eval do
10
14
  end
11
15
  end
12
16
  config[:driver] ||= ::ArJdbc::DB2::DRIVER_NAME
13
- config[:adapter_spec] ||= ::ArJdbc::DB2
14
17
  config[:connection_alive_sql] ||= 'SELECT 1 FROM syscat.tables FETCH FIRST 1 ROWS ONLY'
15
18
  jdbc_connection(config)
16
19
  end
@@ -18,6 +21,10 @@ ArJdbc::ConnectionMethods.module_eval do
18
21
 
19
22
  # @note Assumes AS400 driver (*jt400.jar*) is on class-path.
20
23
  def as400_connection(config)
24
+ config[:adapter_spec] ||= ::ArJdbc::AS400
25
+
26
+ return jndi_connection(config) if config[:jndi]
27
+
21
28
  config[:url] ||= begin
22
29
  # jdbc:as400://[host]
23
30
  url = 'jdbc:as400://'
@@ -30,7 +37,6 @@ ArJdbc::ConnectionMethods.module_eval do
30
37
  end
31
38
  require 'arjdbc/db2/as400'
32
39
  config[:driver] ||= ::ArJdbc::AS400::DRIVER_NAME
33
- config[:adapter_spec] ||= ::ArJdbc::AS400
34
40
  config[:connection_alive_sql] ||= 'SELECT 1 FROM sysibm.tables FETCH FIRST 1 ROWS ONLY'
35
41
  jdbc_connection(config)
36
42
  end
@@ -1,5 +1,9 @@
1
1
  ArJdbc::ConnectionMethods.module_eval do
2
2
  def derby_connection(config)
3
+ config[:adapter_spec] ||= ::ArJdbc::Derby
4
+
5
+ return jndi_connection(config) if jndi_config?(config)
6
+
3
7
  begin
4
8
  require 'jdbc/derby'
5
9
  ::Jdbc::Derby.load_driver(:require) if defined?(::Jdbc::Derby.load_driver)
@@ -9,7 +13,6 @@ ArJdbc::ConnectionMethods.module_eval do
9
13
  config[:url] ||= "jdbc:derby:#{config[:database]};create=true"
10
14
  config[:driver] ||= defined?(::Jdbc::Derby.driver_name) ?
11
15
  ::Jdbc::Derby.driver_name : 'org.apache.derby.jdbc.EmbeddedDriver'
12
- config[:adapter_spec] ||= ::ArJdbc::Derby
13
16
 
14
17
  embedded_driver(config)
15
18
  end
@@ -75,6 +75,24 @@ module ArJdbc
75
75
  # @see #emulate_booleans?
76
76
  def self.emulate_booleans=(emulate); @@emulate_booleans = emulate; end
77
77
 
78
+
79
+ @@update_lob_values = true
80
+
81
+ # Updating records with LOB values (binary/text columns) in a separate
82
+ # statement can be disabled using :
83
+ #
84
+ # ArJdbc::Firebird.update_lob_values = false
85
+ def self.update_lob_values?; @@update_lob_values; end
86
+ # @see #update_lob_values?
87
+ def self.update_lob_values=(update); @@update_lob_values = update; end
88
+
89
+ # @see #update_lob_values?
90
+ def update_lob_values?; Firebird.update_lob_values?; end
91
+
92
+ # @see #quote
93
+ # @private
94
+ BLOB_VALUE_MARKER = "''"
95
+
78
96
  ADAPTER_NAME = 'Firebird'.freeze
79
97
 
80
98
  def adapter_name
@@ -222,8 +240,15 @@ module ArJdbc
222
240
  return value if sql_literal?(value)
223
241
 
224
242
  type = column && column.type
243
+
225
244
  # BLOBs are updated separately by an after_save trigger.
226
- return "NULL" if type == :binary || type == :text
245
+ if type == :binary || type == :text
246
+ if update_lob_values?
247
+ return value.nil? ? "NULL" : BLOB_VALUE_MARKER
248
+ else
249
+ return "'#{quote_string(value)}'"
250
+ end
251
+ end
227
252
 
228
253
  case value
229
254
  when String, ActiveSupport::Multibyte::Chars
@@ -279,6 +304,11 @@ module ArJdbc
279
304
  quote(0)
280
305
  end
281
306
 
307
+ # @override
308
+ def quote_table_name_for_assignment(table, attr)
309
+ quote_column_name(attr)
310
+ end if ::ActiveRecord::VERSION::MAJOR >= 4
311
+
282
312
  # @override
283
313
  def quote_column_name(column_name)
284
314
  column_name = column_name.to_s
@@ -1,5 +1,9 @@
1
1
  ArJdbc::ConnectionMethods.module_eval do
2
2
  def firebird_connection(config)
3
+ config[:adapter_spec] ||= ::ArJdbc::Firebird
4
+
5
+ return jndi_connection(config) if jndi_config?(config)
6
+
3
7
  begin
4
8
  require 'jdbc/firebird'
5
9
  ::Jdbc::Firebird.load_driver(:require)
@@ -12,7 +16,6 @@ ArJdbc::ConnectionMethods.module_eval do
12
16
  "jdbc:firebirdsql://#{config[:host]}:#{config[:port]}/#{config[:database]}"
13
17
  end
14
18
  config[:driver] ||= ::Jdbc::Firebird.driver_name
15
- config[:adapter_spec] ||= ::ArJdbc::Firebird
16
19
 
17
20
  jdbc_connection(config)
18
21
  end
@@ -1,11 +1,16 @@
1
1
  ArJdbc::ConnectionMethods.module_eval do
2
2
  def h2_connection(config)
3
+ config[:adapter_spec] ||= ::ArJdbc::H2
4
+ config[:adapter_class] = ActiveRecord::ConnectionAdapters::H2Adapter unless config.key?(:adapter_class)
5
+
6
+ return jndi_connection(config) if jndi_config?(config)
7
+
3
8
  begin
4
9
  require 'jdbc/h2'
5
10
  ::Jdbc::H2.load_driver(:require) if defined?(::Jdbc::H2.load_driver)
6
11
  rescue LoadError # assuming driver.jar is on the class-path
7
12
  end
8
-
13
+
9
14
  config[:url] ||= begin
10
15
  db = config[:database]
11
16
  if db[0, 4] == 'mem:' || db[0, 5] == 'file:' || db[0, 5] == 'hsql:'
@@ -15,9 +20,7 @@ ArJdbc::ConnectionMethods.module_eval do
15
20
  end
16
21
  end
17
22
  config[:driver] ||= defined?(::Jdbc::H2.driver_name) ? ::Jdbc::H2.driver_name : 'org.h2.Driver'
18
- config[:adapter_spec] ||= ::ArJdbc::H2
19
- config[:adapter_class] = ActiveRecord::ConnectionAdapters::H2Adapter unless config.key?(:adapter_class)
20
-
23
+
21
24
  embedded_driver(config)
22
25
  end
23
26
  alias_method :jdbch2_connection, :h2_connection
@@ -1,11 +1,16 @@
1
1
  ArJdbc::ConnectionMethods.module_eval do
2
2
  def hsqldb_connection(config)
3
+ config[:adapter_spec] ||= ::ArJdbc::HSQLDB
4
+ config[:adapter_class] = ActiveRecord::ConnectionAdapters::HsqldbAdapter unless config.key?(:adapter_class)
5
+
6
+ return jndi_connection(config) if jndi_config?(config)
7
+
3
8
  begin
4
9
  require 'jdbc/hsqldb'
5
10
  ::Jdbc::HSQLDB.load_driver(:require) if defined?(::Jdbc::HSQLDB.load_driver)
6
11
  rescue LoadError # assuming driver.jar is on the class-path
7
12
  end
8
-
13
+
9
14
  config[:url] ||= begin
10
15
  db = config[:database]
11
16
  if db[0, 4] == 'mem:' || db[0, 5] == 'file:' || db[0, 5] == 'hsql:'
@@ -15,10 +20,8 @@ ArJdbc::ConnectionMethods.module_eval do
15
20
  end
16
21
  end
17
22
  config[:driver] ||= defined?(::Jdbc::HSQLDB.driver_name) ? ::Jdbc::HSQLDB.driver_name : 'org.hsqldb.jdbcDriver'
18
- config[:adapter_spec] ||= ::ArJdbc::HSQLDB
19
- config[:adapter_class] = ActiveRecord::ConnectionAdapters::HsqldbAdapter unless config.key?(:adapter_class)
20
23
  config[:connection_alive_sql] ||= 'CALL PI()' # does not like 'SELECT 1'
21
-
24
+
22
25
  embedded_driver(config)
23
26
  end
24
27
  alias_method :jdbchsqldb_connection, :hsqldb_connection
@@ -699,9 +699,12 @@ module ActiveRecord
699
699
  alias table_definition create_table_definition
700
700
 
701
701
  # `TableDefinition.new native_database_types, name, temporary, options`
702
+ # and ActiveRecord 4.1 supports optional `as` argument (which defaults
703
+ # to nil) to provide the SQL to use to generate the table:
704
+ # `TableDefinition.new native_database_types, name, temporary, options, as`
702
705
  # @private
703
- def create_table_definition(name, temporary, options)
704
- table_definition(name, temporary, options)
706
+ def create_table_definition(*args)
707
+ table_definition(*args)
705
708
  end
706
709
 
707
710
  # @note AR-4x arguments expected: `(name, temporary, options)`
@@ -36,6 +36,10 @@ module ActiveRecord
36
36
  # @deprecated no longer used - only kept for compatibility
37
37
  def set_native_database_types; end
38
38
 
39
+ def self.jndi_config?(config)
40
+ config[:jndi] || config[:data_source]
41
+ end
42
+
39
43
  def jndi?; @jndi; end
40
44
  alias_method :jndi_connection?, :jndi?
41
45
 
@@ -46,7 +50,7 @@ module ActiveRecord
46
50
  # @note this has nothing to do with the configure_connection implemented
47
51
  # on some of the concrete adapters (e.g. {#ArJdbc::Postgres})
48
52
  def setup_connection_factory
49
- if config[:jndi] || config[:data_source]
53
+ if self.class.jndi_config?(config)
50
54
  begin
51
55
  setup_jndi_factory
52
56
  rescue => e
@@ -5,19 +5,26 @@ module ArJdbc
5
5
  ConnectionMethods = (class << ActiveRecord::Base; self; end)
6
6
  end
7
7
  ConnectionMethods.module_eval do
8
-
8
+
9
9
  def jdbc_connection(config)
10
10
  adapter_class = config[:adapter_class]
11
11
  adapter_class ||= ::ActiveRecord::ConnectionAdapters::JdbcAdapter
12
12
  adapter_class.new(nil, logger, config)
13
13
  end
14
- alias jndi_connection jdbc_connection
14
+
15
+ def jndi_connection(config); jdbc_connection(config) end
15
16
 
16
17
  def embedded_driver(config)
17
18
  config[:username] ||= "sa"
18
19
  config[:password] ||= ""
19
20
  jdbc_connection(config)
20
21
  end
21
-
22
+
23
+ private
24
+
25
+ def jndi_config?(config)
26
+ ::ActiveRecord::ConnectionAdapters::JdbcConnection.jndi_config?(config)
27
+ end
28
+
22
29
  end
23
30
  end
@@ -11,6 +11,11 @@ ArJdbc::ConnectionMethods.module_eval do
11
11
  return sqlserver_connection(config)
12
12
  end
13
13
 
14
+ config[:adapter_spec] ||= ::ArJdbc::MSSQL
15
+ config[:adapter_class] = ActiveRecord::ConnectionAdapters::MSSQLAdapter unless config.key?(:adapter_class)
16
+
17
+ return jndi_connection(config) if jndi_config?(config)
18
+
14
19
  begin
15
20
  require 'jdbc/jtds'
16
21
  # NOTE: the adapter has only support for working with the
@@ -23,8 +28,6 @@ ArJdbc::ConnectionMethods.module_eval do
23
28
  config[:host] ||= 'localhost'
24
29
  config[:port] ||= 1433
25
30
  config[:driver] ||= defined?(::Jdbc::JTDS.driver_name) ? ::Jdbc::JTDS.driver_name : 'net.sourceforge.jtds.jdbc.Driver'
26
- config[:adapter_spec] ||= ::ArJdbc::MSSQL
27
- config[:adapter_class] = ActiveRecord::ConnectionAdapters::MSSQLAdapter unless config.key?(:adapter_class)
28
31
  config[:connection_alive_sql] ||= 'SELECT 1'
29
32
 
30
33
  config[:url] ||= begin
@@ -49,10 +52,13 @@ ArJdbc::ConnectionMethods.module_eval do
49
52
 
50
53
  # @note Assumes SQLServer SQL-JDBC driver on the class-path.
51
54
  def sqlserver_connection(config)
52
- config[:host] ||= 'localhost'
53
- config[:driver] ||= 'com.microsoft.sqlserver.jdbc.SQLServerDriver'
54
55
  config[:adapter_spec] ||= ::ArJdbc::MSSQL
55
56
  config[:adapter_class] = ActiveRecord::ConnectionAdapters::MSSQLAdapter unless config.key?(:adapter_class)
57
+
58
+ return jndi_connection(config) if jndi_config?(config)
59
+
60
+ config[:host] ||= 'localhost'
61
+ config[:driver] ||= 'com.microsoft.sqlserver.jdbc.SQLServerDriver'
56
62
  config[:connection_alive_sql] ||= 'SELECT 1'
57
63
 
58
64
  config[:url] ||= begin
@@ -152,8 +152,8 @@ module ArJdbc
152
152
  return value if sql_literal?(value)
153
153
  return value.to_s if column && column.type == :primary_key
154
154
 
155
- if value.kind_of?(String) && column && column.type == :binary && column.class.respond_to?(:string_to_binary)
156
- "x'#{column.class.string_to_binary(value).unpack("H*")[0]}'"
155
+ if value.kind_of?(String) && column && column.type == :binary
156
+ "x'#{value.unpack("H*")[0]}'"
157
157
  elsif value.kind_of?(BigDecimal)
158
158
  value.to_s("F")
159
159
  else
@@ -1,5 +1,10 @@
1
1
  ArJdbc::ConnectionMethods.module_eval do
2
2
  def mysql_connection(config)
3
+ config[:adapter_spec] ||= ::ArJdbc::MySQL
4
+ config[:adapter_class] = ActiveRecord::ConnectionAdapters::MysqlAdapter unless config.key?(:adapter_class)
5
+
6
+ return jndi_connection(config) if jndi_config?(config)
7
+
3
8
  begin
4
9
  require 'jdbc/mysql'
5
10
  ::Jdbc::MySQL.load_driver(:require) if defined?(::Jdbc::MySQL.load_driver)
@@ -19,8 +24,6 @@ ArJdbc::ConnectionMethods.module_eval do
19
24
  config[:url] = url
20
25
  end
21
26
  config[:driver] ||= defined?(::Jdbc::MySQL.driver_name) ? ::Jdbc::MySQL.driver_name : 'com.mysql.jdbc.Driver'
22
- config[:adapter_spec] ||= ::ArJdbc::MySQL
23
- config[:adapter_class] = ActiveRecord::ConnectionAdapters::MysqlAdapter unless config.key?(:adapter_class)
24
27
 
25
28
  properties = ( config[:properties] ||= {} )
26
29
  properties['zeroDateTimeBehavior'] ||= 'convertToNull'
@@ -3,11 +3,14 @@ ArJdbc::ConnectionMethods.module_eval do
3
3
  # *thin* method to connect to the Oracle DB.
4
4
  # @note Oracle's JDBC driver should be on the class-path.
5
5
  def oracle_connection(config)
6
+ config[:adapter_spec] ||= ::ArJdbc::Oracle
7
+ config[:adapter_class] = ActiveRecord::ConnectionAdapters::OracleAdapter unless config.key?(:adapter_class)
8
+
9
+ return jndi_connection(config) if jndi_config?(config)
10
+
6
11
  config[:port] ||= 1521
7
12
  config[:url] ||= "jdbc:oracle:thin:@#{config[:host]}:#{config[:port]}:#{config[:database]}"
8
13
  config[:driver] ||= "oracle.jdbc.driver.OracleDriver"
9
- config[:adapter_spec] ||= ::ArJdbc::Oracle
10
- config[:adapter_class] = ActiveRecord::ConnectionAdapters::OracleAdapter unless config.key?(:adapter_class)
11
14
  config[:connection_alive_sql] ||= 'SELECT 1 FROM DUAL'
12
15
  jdbc_connection(config)
13
16
  end
@@ -1,10 +1,16 @@
1
1
  ArJdbc::ConnectionMethods.module_eval do
2
2
  def postgresql_connection(config)
3
+ config[:adapter_spec] ||= ::ArJdbc::PostgreSQL
4
+ config[:adapter_class] = ActiveRecord::ConnectionAdapters::PostgreSQLAdapter unless config.key?(:adapter_class)
5
+
6
+ return jndi_connection(config) if jndi_config?(config)
7
+
3
8
  begin
4
9
  require 'jdbc/postgres'
5
10
  ::Jdbc::Postgres.load_driver(:require) if defined?(::Jdbc::Postgres.load_driver)
6
11
  rescue LoadError # assuming driver.jar is on the class-path
7
12
  end
13
+ config[:driver] ||= defined?(::Jdbc::Postgres.driver_name) ? ::Jdbc::Postgres.driver_name : 'org.postgresql.Driver'
8
14
 
9
15
  host = config[:host] ||= ( config[:hostaddr] || ENV['PGHOST'] || 'localhost' )
10
16
  port = config[:port] ||= ( ENV['PGPORT'] || 5432 )
@@ -36,10 +42,6 @@ ArJdbc::ConnectionMethods.module_eval do
36
42
  properties['tcpKeepAlive'] ||= config[:keepalives] if config.key?(:keepalives)
37
43
  properties['kerberosServerName'] ||= config[:krbsrvname] if config[:krbsrvname]
38
44
 
39
- config[:driver] ||= defined?(::Jdbc::Postgres.driver_name) ? ::Jdbc::Postgres.driver_name : 'org.postgresql.Driver'
40
- config[:adapter_spec] ||= ::ArJdbc::PostgreSQL
41
- config[:adapter_class] = ActiveRecord::ConnectionAdapters::PostgreSQLAdapter unless config.key?(:adapter_class)
42
-
43
45
  jdbc_connection(config)
44
46
  end
45
47
  alias_method :jdbcpostgresql_connection, :postgresql_connection
@@ -1,5 +1,10 @@
1
1
  ArJdbc::ConnectionMethods.module_eval do
2
2
  def sqlite3_connection(config)
3
+ config[:adapter_spec] ||= ::ArJdbc::SQLite3
4
+ config[:adapter_class] = ActiveRecord::ConnectionAdapters::SQLite3Adapter unless config.key?(:adapter_class)
5
+
6
+ return jndi_connection(config) if jndi_config?(config)
7
+
3
8
  begin
4
9
  require 'jdbc/sqlite3'
5
10
  ::Jdbc::SQLite3.load_driver(:require) if defined?(::Jdbc::SQLite3.load_driver)
@@ -10,8 +15,6 @@ ArJdbc::ConnectionMethods.module_eval do
10
15
  database = config[:database] # NOTE: "jdbc:sqlite::memory:" syntax is supported
11
16
  config[:url] ||= "jdbc:sqlite:#{database == ':memory:' ? '' : database}"
12
17
  config[:driver] ||= defined?(::Jdbc::SQLite3.driver_name) ? ::Jdbc::SQLite3.driver_name : 'org.sqlite.JDBC'
13
- config[:adapter_spec] ||= ::ArJdbc::SQLite3
14
- config[:adapter_class] = ActiveRecord::ConnectionAdapters::SQLite3Adapter unless config.key?(:adapter_class)
15
18
  config[:connection_alive_sql] ||= 'SELECT 1'
16
19
 
17
20
  options = ( config[:properties] ||= {} )
@@ -1,5 +1,5 @@
1
1
  module ArJdbc
2
- VERSION = "1.3.4"
2
+ VERSION = "1.3.5"
3
3
  # @deprecated
4
4
  module Version
5
5
  # @private 1.2.x compatibility
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.4
4
+ version: 1.3.5
5
5
  platform: ruby
6
6
  authors:
7
- - Nick Sieger, Ola Bini and JRuby contributors
7
+ - Nick Sieger, Ola Bini, Karol Bucek and JRuby contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-12 00:00:00.000000000 Z
11
+ date: 2014-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -33,6 +33,7 @@ description: 'AR-JDBC is a database adapter for Rails'' ActiveRecord component d
33
33
  email:
34
34
  - nick@nicksieger.com
35
35
  - ola.bini@gmail.com
36
+ - self@kares.org
36
37
  executables: []
37
38
  extensions: []
38
39
  extra_rdoc_files: []