brick 1.0.86 → 1.0.87

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
  SHA256:
3
- metadata.gz: 67cdd41b9c4a3a235e4d88a151149a7c2c9345a4280efe31c3fbd983b65fbdd4
4
- data.tar.gz: 12f80d33a0360cfa67fb703ed59b65b9216cafa07a18d9283baf9df584067896
3
+ metadata.gz: b178117c13e6d4feb053c27334b558285765a68a8bdc00c0a1d7a0a708ab3e70
4
+ data.tar.gz: b4b90b2cef91df1797d3a6534d6658914000b01542fe244d7560d31922c2125e
5
5
  SHA512:
6
- metadata.gz: e95aefd208502dfa2ae724d178a29d15ccad4d00522ecbb865019823ba331c0d9f6e4026aea1b634f57f1d7945d8f522e35361d42d9de972698de91c0b9bd129
7
- data.tar.gz: 99d0df87ae591bf836f6040aa237863fb1535774cb6fae515bb1c25edd284b4f37d5a1c01584138df81cfbb66a535ef8bec9aaf2550c96a42c02dee7e48aada1
6
+ metadata.gz: a7866357360543e3af339aced9e7ff8c1dff803f3f92eebb12926b5cefb4da18415003b729ad5aca3b7771a145035963bd1e49d8a46096bb943a161e4b33ca79
7
+ data.tar.gz: b2978cf99f81c2ad59b04f656c189763d230542e9eb9d9eb7d3a922c609e79354926357320967f7de53a1a6cc4ec55b61811395138e632cb0f1a96993a31e926
@@ -211,7 +211,14 @@ module ActiveRecord
211
211
  this_obj = obj
212
212
  bracket_name.split('.').each do |part|
213
213
  obj_name += ".#{part}"
214
- this_obj = caches.fetch(obj_name) { caches[obj_name] = this_obj&.send(part.to_sym) }
214
+ this_obj = begin
215
+ caches.fetch(obj_name) { caches[obj_name] = this_obj&.send(part.to_sym) }
216
+ rescue
217
+ clsnm = part.camelize
218
+ if (possible = this_obj.class.reflect_on_all_associations.select { |a| a.class_name == clsnm || a.klass.base_class.name == clsnm }.first)
219
+ caches[obj_name] = this_obj&.send(possible.name)
220
+ end
221
+ end
215
222
  break if this_obj.nil?
216
223
  end
217
224
  if this_obj.is_a?(ActiveRecord::Base) && (obj_descrip = this_obj.class.brick_descrip(this_obj))
@@ -1797,6 +1804,8 @@ end.class_exec do
1797
1804
  # This is done separately so that during testing it can be called right after a migration
1798
1805
  # in order to make sure everything is good.
1799
1806
  def _brick_reflect_tables
1807
+ return unless ::Brick.config.mode == :on
1808
+
1800
1809
  # return if ActiveRecord::Base.connection.current_database == 'postgres'
1801
1810
 
1802
1811
  initializer_loaded = false
@@ -1870,8 +1879,9 @@ end.class_exec do
1870
1879
  ::Brick.db_schemas ||= {}
1871
1880
 
1872
1881
  if ActiveRecord::Base.connection.adapter_name == 'PostgreSQL'
1873
- if (possible_schema = ::Brick.config.schema_behavior&.[](:multitenant)&.[](:schema_to_analyse))
1874
- if ::Brick.db_schemas.key?(possible_schema)
1882
+ if (possible_schemas = ::Brick.config.schema_behavior&.[](:multitenant)&.[](:schema_to_analyse))
1883
+ possible_schemas = [possible_schemas] unless possible_schemas.is_a?(Array)
1884
+ if (possible_schema = possible_schemas.find { |ps| ::Brick.db_schemas.key?(ps) })
1875
1885
  ::Brick.default_schema = schema = possible_schema
1876
1886
  orig_schema = ActiveRecord::Base.execute_sql('SELECT current_schemas(true)').first['current_schemas'][1..-2].split(',')
1877
1887
  ActiveRecord::Base.execute_sql("SET SEARCH_PATH = ?", schema)
@@ -1881,7 +1891,7 @@ end.class_exec do
1881
1891
  orig_schema = ActiveRecord::Base.execute_sql('SELECT current_schemas(true)').first['current_schemas'][1..-2].split(',')
1882
1892
  ActiveRecord::Base.execute_sql("SET SEARCH_PATH = ?", schema)
1883
1893
  else
1884
- puts "*** In the brick.rb initializer the line \"::Brick.schema_behavior = ...\" refers to a schema called \"#{possible_schema}\". This schema does not exist. ***"
1894
+ puts "*** In the brick.rb initializer the line \"::Brick.schema_behavior = ...\" refers to schema(s) called #{possible_schemas.map { |s| "\"#{s}\"" }.join(', ')}. No mentioned schema exists. ***"
1885
1895
  end
1886
1896
  end
1887
1897
  end
@@ -5,7 +5,7 @@ module Brick
5
5
  module VERSION
6
6
  MAJOR = 1
7
7
  MINOR = 0
8
- TINY = 86
8
+ TINY = 87
9
9
 
10
10
  # PRE is nil unless it's a pre-release (beta, RC, etc.)
11
11
  PRE = nil
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brick
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.86
4
+ version: 1.0.87
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lorin Thwaits
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-27 00:00:00.000000000 Z
11
+ date: 2022-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord