Skip to content

Commit f54152f

Browse files
committed
some more deprecation - config[:options] should no longer be used
1 parent c3528f5 commit f54152f

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

lib/arjdbc/jdbc/connection.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ def native_database_types
3434
end
3535

3636
# @deprecated no longer used - only kept for compatibility
37-
def set_native_database_types; end
37+
def set_native_database_types
38+
ArJdbc.deprecate "set_native_database_types is no longer used and does nothing override native_database_types instead"
39+
end
3840

3941
def self.jndi_config?(config)
4042
config[:jndi] || config[:data_source]
@@ -74,7 +76,8 @@ def setup_jndi_factory
7476

7577
def setup_jdbc_factory
7678
if ! config[:url] || ( ! config[:driver] && ! config[:driver_instance] )
77-
raise ::ActiveRecord::ConnectionNotEstablished, "jdbc adapter requires :driver class and :url"
79+
msg = config[:url] ? ":url = #{config[:url]}" : ":driver = #{config[:driver]}"
80+
raise ::ActiveRecord::ConnectionNotEstablished, "jdbc adapter requires :driver and :url (got #{msg})"
7881
end
7982

8083
url = jdbc_url
@@ -93,8 +96,9 @@ def setup_jdbc_factory
9396

9497
def jdbc_url
9598
url = config[:url].to_s
96-
if Hash === config[:options]
97-
options = config[:options].map { |key, val| "#{key}=#{val}" }.join('&')
99+
if options = config[:options]
100+
ArJdbc.deprecate "use config[:properties] to specify connection URL properties instead of config[:options]"
101+
options = options.map { |key, val| "#{key}=#{val}" }.join('&') if Hash === options
98102
url = url['?'] ? "#{url}&#{options}" : "#{url}?#{options}" unless options.empty?
99103
config[:url] = url; config[:options] = nil
100104
end

lib/arjdbc/jdbc/connection_methods.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module ArJdbc
2-
if defined? ActiveRecord::ConnectionHandling # 4.0
2+
if ActiveRecord.const_defined? :ConnectionHandling # 4.0
33
ConnectionMethods = ActiveRecord::ConnectionHandling
44
else # 3.x
55
ConnectionMethods = (class << ActiveRecord::Base; self; end)
@@ -27,4 +27,4 @@ def jndi_config?(config)
2727
end
2828

2929
end
30-
end
30+
end

0 commit comments

Comments
 (0)