brick 1.0.133 → 1.0.134

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: 6804b443d939d24da85968d5b75c4c0603c8880dcc5ab4d07b20be0a52e5a349
4
- data.tar.gz: 17ed154ec5f8ec1f351a83120673e9354f892217da76957fdc49a31e663e9eba
3
+ metadata.gz: 613c6296c56af562bc77d55d734b0a6e5bdad7e3942891db4dc939fe087fca7f
4
+ data.tar.gz: acc5873eeae8a0d9e9d4a86cc8b71ee12dc0699821dee132c40c569147156075
5
5
  SHA512:
6
- metadata.gz: 1b4e53fe24d3de942a7388453d6ee732b0263097b08cbed104d7499842ffaa4eb7239b1bdb81b7300d08df9a628b2a99aad74f47de1fd3579b1eefbf0382b18a
7
- data.tar.gz: 3eb38e2a8f1e5c12493ff6e3a524d42157dcae2781d6d39f339d098b04b12d936989f3974977df589419ca04663a4c27f6b7425e09b9695817d9103fb7fd543f
6
+ metadata.gz: 046bec9f177ec74aaa3bbba3ef1dd2afe54f43376068ed657ed0fec6d18ac353e8addfabad514fdf33cc6199d053ca1e23c0f46aa1a53cac96fe6e21f7a50796
7
+ data.tar.gz: 7d21817ea8774f65852be247ae72c341559c84b0a58228d019d5630036827a99988699752392bbc43330400761ea9e59292231bae5993fa0620240126fe7490e
@@ -670,7 +670,6 @@ module ActiveRecord
670
670
  # Add derived table JOIN for the has_many counts
671
671
  nix = []
672
672
  klass._br_hm_counts.each do |k, hm|
673
- num_bt_things = 0
674
673
  count_column = if hm.options[:through]
675
674
  # Build the chain of JOINs going to the final destination HMT table
676
675
  # (Usually just one JOIN, but could be many.)
@@ -691,7 +690,11 @@ module ActiveRecord
691
690
  # Turn the last member of link_back into a foreign key
692
691
  link_back << hmt_assoc.source_reflection.foreign_key
693
692
  # If it's a HMT based on a HM -> HM, must JOIN the last table into the mix at the end
694
- through_sources.push(hm.source_reflection) unless hm.source_reflection.belongs_to?
693
+ this_hm = hm
694
+ while !(src_ref = this_hm.source_reflection).belongs_to? && (thr = src_ref.options[:through])
695
+ through_sources.push(this_hm = src_ref.active_record.reflect_on_association(thr))
696
+ end
697
+ through_sources.push(src_ref) unless src_ref.belongs_to?
695
698
  from_clause = +"#{through_sources.first.table_name} br_t0"
696
699
  fk_col = through_sources.shift.foreign_key
697
700
 
@@ -700,9 +703,7 @@ module ActiveRecord
700
703
  through_sources.map do |a|
701
704
  from_clause << "\n LEFT OUTER JOIN #{a.table_name} br_t#{idx += 1} "
702
705
  from_clause << if (src_ref = a.source_reflection).macro == :belongs_to
703
- nm = hmt_assoc.source_reflection.inverse_of&.name
704
- link_back << nm
705
- num_bt_things += 1
706
+ link_back << (nm = hmt_assoc.source_reflection.inverse_of&.name)
706
707
  # puts "BT #{a.table_name}"
707
708
  "ON br_t#{idx}.#{a.active_record.primary_key} = br_t#{idx - 1}.#{a.foreign_key}"
708
709
  elsif src_ref.options[:as]
@@ -723,9 +724,8 @@ module ActiveRecord
723
724
  end
724
725
  else # Standard has_many or has_one
725
726
  # puts "HM #{a.table_name}"
726
- # binding.pry unless (
727
727
  nm = hmt_assoc.source_reflection.inverse_of&.name
728
- # )
728
+ # binding.pry unless nm
729
729
  link_back << nm # if nm
730
730
  "ON br_t#{idx}.#{a.foreign_key} = br_t#{idx - 1}.#{a.active_record.primary_key}"
731
731
  end
@@ -742,16 +742,8 @@ module ActiveRecord
742
742
  nix << k
743
743
  next
744
744
  elsif src_ref.macro == :belongs_to # Traditional HMT using an associative table
745
- # binding.pry if link_back.length > 2
746
745
  "br_t#{idx}.#{hm.foreign_key}"
747
746
  else # A HMT that goes HM -> HM, something like Categories -> Products -> LineItems
748
- # %%% Currently flaky, so will revisit this soon, probably while implementing the whole link_back architecture
749
- if num_bt_things > 1
750
- # binding.pry
751
- nix << k
752
- next
753
- end
754
-
755
747
  "br_t#{idx}.#{src_ref.active_record.primary_key}"
756
748
  end
757
749
  else
@@ -5,7 +5,7 @@ module Brick
5
5
  module VERSION
6
6
  MAJOR = 1
7
7
  MINOR = 0
8
- TINY = 133
8
+ TINY = 134
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.133
4
+ version: 1.0.134
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lorin Thwaits
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-24 00:00:00.000000000 Z
11
+ date: 2023-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord