sinatra-activerecord 2.0.22 → 2.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/sinatra/activerecord.rb +12 -2
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dd8c9b0af0329e3c58559409592d58ff44a7110407969effa9902c34c316eb07
4
- data.tar.gz: fb39eecde9d4947aac413beda568cb3b60ad408d8505fddf45907cbed18193f2
3
+ metadata.gz: c1985ef88a83eccdcf4ad4db78ced061a9398fd54cd01a0444816f4b83c661da
4
+ data.tar.gz: e449fdc9807e75b4d9994545d08107473b618712b870b37edfb5d84de317aef3
5
5
  SHA512:
6
- metadata.gz: 8655fe10cab66ccb6d3c4ab505d81e7ae2d091057dcda13b2f8e0504f738274274a4ae4d53c5d6c91bf64f0c5b2be2603467bc62272d2cf7125e124c825b7c37
7
- data.tar.gz: b04451e063eb7729b3e33937697c13f0d1dd329bfcd7970a8e2d0eda4f7c64fda3d72dc4aa896e16569db2d95a4f0ee158b7068147dac8d8ec53c545296c50d3
6
+ metadata.gz: b6e0d9905eb59b73e06cb57d9e69f1351c34ffa17a386bac9bc4a520fd9950d28cb5c58d68e09dcb261a9550ed8a58194f72257f466e793c540f664fc0edc945
7
+ data.tar.gz: 60ff2c30ffb5b65b6cb6f9d4a9b9d0aaf39af210ff7c3fcea6a04365b9573b67864d3d4b9331e6193986b499ba6c06ea4d512173114a183442f8a6d30d0e9bea
@@ -31,8 +31,18 @@ module Sinatra
31
31
  url_spec = ActiveRecord::ConnectionAdapters::ConnectionSpecification::ConnectionUrlResolver.new(url).to_hash
32
32
  end
33
33
 
34
- # url_spec will override the same key, if exist
35
- final_spec = file_spec.keys.map{ |env| [env, file_spec[env].merge(url_spec)] }.to_h
34
+ # if the configuration concerns only one database, and url_spec exist, url_spec will override the same key
35
+ # if the configuration has multiple databases (Rails 6.0+ feature), url_spec is discarded
36
+ # Following Active Record config convention
37
+ # https://github.com/rails/rails/blob/main/activerecord/lib/active_record/database_configurations.rb#L169
38
+ final_spec = file_spec.keys.map do |env|
39
+ config = file_spec[env]
40
+ if config.is_a?(Hash) && config.all? { |_k, v| v.is_a?(Hash) }
41
+ [env, config]
42
+ else
43
+ [env, config.merge(url_spec)]
44
+ end
45
+ end.to_h
36
46
 
37
47
  app.set :database, final_spec
38
48
  elsif ENV['DATABASE_URL']
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-activerecord
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.22
4
+ version: 2.0.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Blake Mizerany
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-01-18 00:00:00.000000000 Z
13
+ date: 2021-05-12 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: sinatra