brick 1.0.133 → 1.0.134
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/brick/extensions.rb +7 -15
- data/lib/brick/version_number.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 613c6296c56af562bc77d55d734b0a6e5bdad7e3942891db4dc939fe087fca7f
|
4
|
+
data.tar.gz: acc5873eeae8a0d9e9d4a86cc8b71ee12dc0699821dee132c40c569147156075
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 046bec9f177ec74aaa3bbba3ef1dd2afe54f43376068ed657ed0fec6d18ac353e8addfabad514fdf33cc6199d053ca1e23c0f46aa1a53cac96fe6e21f7a50796
|
7
|
+
data.tar.gz: 7d21817ea8774f65852be247ae72c341559c84b0a58228d019d5630036827a99988699752392bbc43330400761ea9e59292231bae5993fa0620240126fe7490e
|
data/lib/brick/extensions.rb
CHANGED
@@ -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
|
-
|
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
|
data/lib/brick/version_number.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2023-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|