brick 1.0.198 → 1.0.199

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9de3c9df6786000fb662d7aa133a5c53b2ed5d06a114edd3165dfd0acd3ebe7c
4
- data.tar.gz: 7750790ca7698e8291ebd2843692009ef29795aab60c5691911698a835808bda
3
+ metadata.gz: 45f0082e1fac37af74b7ee802123ba84b8f670596fbd6f47c704ce6e660a6a2e
4
+ data.tar.gz: aad9255dbb59fda237d733508268f817666158984633b5e2965ed2fcfa909d9b
5
5
  SHA512:
6
- metadata.gz: dcb14263731745917eba2172d838b7eeb11910a1bab8c93dbe5d27b8923f98e16b24c08b74c52c550f75bc900cb61af1d1783d010ae9ed3000e03043749f47d8
7
- data.tar.gz: ec2111be292b26489b972782478151f1468c2d02c6c84dc144c09bd4a8c0e34104fcb392c0ebdc9758eda6061ed62db982e4751e2e885edd282c4ba42c144bed
6
+ metadata.gz: f1ec256df47b3091bf23ad128ae74e3e3baef71052fc6353fa24fefe2744bf8d28bf8ba1aea595c583049745c7addf26a5cbd992b91406a5b457a4e6e6a4e2e7
7
+ data.tar.gz: e6c9cc621f4cd184be0da3c924b3e529f2964b1125c518aeb93f9c1fd1a7e55c94ab278d1573522a01f5b9f5969c044685659f2ffb4656dce0fd001df759990d
@@ -3470,11 +3470,11 @@ module Brick
3470
3470
  res_name << '.' if res_name
3471
3471
  (res_name ||= +'') << (relation ||= ::Brick.relations.fetch(tbl_name, nil))&.fetch(:resource, nil) || tbl_name_parts.last
3472
3472
 
3473
- res_parts = ((mode == :singular) ? tbl_name.singularize : res_name).split('.')
3473
+ res_parts = ((mode == :singular) ? res_name.singularize : res_name).split('.')
3474
3474
  res_parts.shift if ::Brick.apartment_multitenant && res_parts.length > 1 && res_parts.first == ::Brick.apartment_default_tenant
3475
- if (aps = relation&.fetch(:auto_prefixed_schema, nil)) && res_parts.last.start_with?(aps)
3476
- last_part = res_parts.last[aps.length..-1]
3475
+ if (aps = relation&.fetch(:auto_prefixed_schema, nil)) # && res_parts.last.start_with?(aps)
3477
3476
  aps = aps[0..-2] if aps[-1] == '_'
3477
+ last_part = res_parts.last # [aps.length..-1]
3478
3478
  res_parts[-1] = aps
3479
3479
  res_parts << last_part
3480
3480
  end
@@ -788,13 +788,6 @@ window.addEventListener(\"popstate\", linkSchemas);
788
788
  next if rel.first.blank? || rel.last[:cols].empty? ||
789
789
  ::Brick.config.exclude_tables.include?(rel.first)
790
790
 
791
- tbl_parts = rel.first.split('.')
792
- if (aps = rel.last.fetch(:auto_prefixed_schema, nil))
793
- tbl_parts << tbl_parts.last[aps.length..-1]
794
- aps = aps[0..-2] if aps[-1] == '_'
795
- tbl_parts[-2] = aps
796
- end
797
- tbl_parts.shift if tbl_parts.first == apartment_default_schema
798
791
  # %%% When table_name_prefixes are use then during rendering empty non-TNP
799
792
  # entries get added at some point when an attempt is made to find the table.
800
793
  # Will have to hunt that down at some point.
@@ -1623,7 +1616,7 @@ end %>#{"
1623
1616
  <td><%= link_to_brick(
1624
1617
  ::Brick::Rails::AA_PNG.html_safe,
1625
1618
  { show_proc: Proc.new do |aa_model, relation|
1626
- path_helper = \"#\{ns}_#\{relation.fetch(:auto_prefixed_schema, nil)}#\{rk = aa_model.model_name.singular_route_key}_path\".to_sym
1619
+ path_helper = \"#\{ns}_#\{relation.fetch(:auto_prefixed_schema, nil)}#\{aa_model.model_name.singular_route_key}_path\".to_sym
1627
1620
  send(path_helper, obj) if respond_to?(path_helper)
1628
1621
  end,
1629
1622
  title: \"#\{page_title} in ActiveAdmin\" }
@@ -73,7 +73,7 @@ module Brick::Rails::FormTags
73
73
  <td>#{link_to_brick(
74
74
  ::Brick::Rails::AA_PNG.html_safe,
75
75
  { index_proc: Proc.new do |aa_model, relation|
76
- path_helper = "#{ns}_#{relation.fetch(:auto_prefixed_schema, nil)}#{rk = aa_model.model_name.route_key}_path".to_sym
76
+ path_helper = "#{ns}_#{relation.fetch(:auto_prefixed_schema, nil)}#{aa_model.model_name.route_key}_path".to_sym
77
77
  send(path_helper) if respond_to?(path_helper)
78
78
  end,
79
79
  title: "#{klass.name} in ActiveAdmin" }
@@ -137,7 +137,7 @@ module Brick::Rails::FormTags
137
137
  options[col[1].inheritance_column] = col[1].name unless col[1] == col[1].base_class
138
138
  x_order = " x-order=\"#{col_name}\"" if true
139
139
  s << "#{x_order}>#{col[2]} "
140
- s << (col.first ? "#{col[3]}" : "#{link_to(col[3], send("#{col[1]._brick_index}_path", options))}")
140
+ s << (col.first ? col[3].to_s : "#{link_to(col[3], send("#{col[1]._brick_index}_path", options))}")
141
141
  elsif cust_cols.key?(col_name) # Custom column
142
142
  x_order = " x-order=\"#{col_name}\"" if true
143
143
  s << "#{x_order}>#{col_name}"
@@ -5,7 +5,7 @@ module Brick
5
5
  module VERSION
6
6
  MAJOR = 1
7
7
  MINOR = 0
8
- TINY = 198
8
+ TINY = 199
9
9
 
10
10
  # PRE is nil unless it's a pre-release (beta, RC, etc.)
11
11
  PRE = nil
data/lib/brick.rb CHANGED
@@ -224,7 +224,7 @@ module Brick
224
224
  if !a.polymorphic? && (a.belongs_to? || (through && (thr = a.through_reflection))) &&
225
225
  !((kls = thr&.klass || a.klass) && ::Brick.config.exclude_tables.exclude?(kls.table_name) &&
226
226
  (!a.belongs_to? ||
227
- ((fk_type = a.foreign_key.is_a?(Array) ? a.foreign_key.map { |fk_part| model_cols[fk_part.to_s].type } : model_cols[a.foreign_key.to_s].type) &&
227
+ ((fk_type = a.foreign_key.is_a?(Array) ? a.foreign_key.map { |fk_part| model_cols[fk_part.to_s].type } : model_cols[a.foreign_key.to_s]&.type) &&
228
228
  (primary_cols = primary_klass.columns_hash) &&
229
229
  (pk_type = a_pk.is_a?(Array) ? a_pk.map { |pk_part| primary_cols[pk_part.to_s].type } : primary_cols[a_pk].type) &&
230
230
  (same_type = (pk_type == fk_type))
@@ -141,7 +141,7 @@ module Brick
141
141
  end
142
142
  end).present?
143
143
  fringe.each do |tbl|
144
- mig = gen_migration_columns(relations, tbl, (tbl_parts = tbl.split('.')), (add_fks = []),
144
+ mig = gen_migration_columns(relations, tbl, (tbl_parts = tbl.split('.')), (add_fks = []), built_schemas, mig_path, current_mig_time,
145
145
  key_type, is_4x_rails, ar_version, do_fks_last)
146
146
  after_fks.concat(add_fks) if do_fks_last
147
147
  versions_to_create << migration_file_write(mig_path, "create_#{::Brick._brick_index(tbl, nil, 'x')}", current_mig_time += 1.minute, ar_version, mig)
@@ -153,7 +153,7 @@ module Brick
153
153
  if do_fks_last
154
154
  # Write out any more tables that haven't been done yet
155
155
  chosen.each do |tbl|
156
- mig = gen_migration_columns(relations, tbl, (tbl_parts = tbl.split('.')), (add_fks = []),
156
+ mig = gen_migration_columns(relations, tbl, (tbl_parts = tbl.split('.')), (add_fks = []), built_schemas, mig_path, current_mig_time,
157
157
  key_type, is_4x_rails, ar_version, do_fks_last)
158
158
  after_fks.concat(add_fks)
159
159
  migration_file_write(mig_path, "create_#{::Brick._brick_index(tbl, nil, 'x')}", current_mig_time += 1.minute, ar_version, mig)
@@ -204,8 +204,11 @@ module Brick
204
204
  # No official PK, but if coincidentally there's a column of the same name, take a chance on it
205
205
  pk = (add_fk[2][:cols].key?(add_fk[1]) && add_fk[1]) || '???'
206
206
  end
207
- # from_table column to_table
208
- puts " [#{add_fk[3].to_s.inspect}, #{add_fk[1].inspect}, #{add_fk[0].to_s.inspect}]"
207
+ from_table = add_fk[3]
208
+ from_table = "'#{from_table[1..-1]}'" if from_table[0] == ':'
209
+ to_table = add_fk[0]
210
+ to_table = "'#{to_table[1..-1]}'" if to_table[0] == ':'
211
+ puts " [#{from_table}, #{add_fk[1].inspect}, #{to_table}],"
209
212
  end
210
213
  puts ' ]'
211
214
  end
@@ -251,7 +254,7 @@ module Brick
251
254
 
252
255
  private
253
256
 
254
- def gen_migration_columns(relations, tbl, tbl_parts, add_fks,
257
+ def gen_migration_columns(relations, tbl, tbl_parts, add_fks, built_schemas, mig_path, current_mig_time,
255
258
  key_type, is_4x_rails, ar_version, do_fks_last)
256
259
  return unless (relation = relations.fetch(tbl, nil))&.fetch(:cols, nil)&.present?
257
260
 
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.198
4
+ version: 1.0.199
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lorin Thwaits
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-03 00:00:00.000000000 Z
11
+ date: 2024-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord