brick 1.0.208 → 1.0.209
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 +15 -13
- data/lib/brick/frameworks/rails/form_builder.rb +1 -1
- data/lib/brick/frameworks/rails/form_tags.rb +9 -9
- data/lib/brick/version_number.rb +1 -1
- data/lib/brick.rb +7 -7
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9727d5ff3dbf5edcb8ce91b03d0570eec5eb2e0f9ae2c4f456d9d50779321fc9
|
4
|
+
data.tar.gz: 32b32f909110d6eca464c775d9725ad049fabf8591daab1088da007ae9a95c5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1931290e472f472d93e1536e6517a3865bcc1acd23d15156d48e52c7f35987183b274c8a7c2ac00f09f2f6ac9a4d5663071c84ae4c896de6b4c0069d4a06b1da
|
7
|
+
data.tar.gz: 5064ef883fb66feb187fe80a92b3ec700da04feef0f390d720b51497f086bbc1062e505cd467d3624fadb6102bc8dec49b0b6b16a1c04a1a1ceb34e50f4f9ff5
|
data/lib/brick/extensions.rb
CHANGED
@@ -542,25 +542,27 @@ module ActiveRecord
|
|
542
542
|
|
543
543
|
# Links from ActiveRecord association pathing names over to the real table
|
544
544
|
# correlation names that get chosen when the AREL AST tree is walked.
|
545
|
-
def brick_links
|
545
|
+
def brick_links(do_dup = true)
|
546
546
|
# Touching AREL AST walks the JoinDependency tree, and in that process uses our
|
547
547
|
# "brick_links" patch to find how every AR chain of association names relates to exact
|
548
|
-
# table correlation names chosen by AREL.
|
549
|
-
#
|
550
|
-
#
|
551
|
-
#
|
552
|
-
#
|
553
|
-
#
|
554
|
-
#
|
555
|
-
# table
|
556
|
-
#
|
548
|
+
# table correlation names chosen by AREL. Unless a relation has already had its AST
|
549
|
+
# tree built out, we will use a duplicate relation object for this, because an important
|
550
|
+
# side-effect of referencing the AST is that the @arel instance variable gets set. This
|
551
|
+
# is a signal to ActiveRecord that a relation has now become immutable. (When Brick is
|
552
|
+
# still in the middle of calculating its query, we aren't quite ready for the relation
|
553
|
+
# object to be set in stone ... still need to add .select(), and possibly .where() and
|
554
|
+
# .order() things ... also if there are any HM counts then an OUTER JOIN for each of
|
555
|
+
# them out to a derived table to do that counting. All of these things need to know
|
556
|
+
# proper table correlation names, which will now become available from brick_links on
|
557
|
+
# the rel_dupe object.)
|
557
558
|
@_brick_links ||= begin
|
558
559
|
# If it's a CollectionProxy (which inherits from Relation) then need to dig
|
559
560
|
# out the core Relation object which is found in the association scope.
|
560
|
-
|
561
|
+
brick_rel = is_a?(ActiveRecord::Associations::CollectionProxy) ? scope : self
|
562
|
+
brick_rel = brick_rel.dup if do_dup
|
561
563
|
# Start out with a hash that has only the root table name
|
562
|
-
|
563
|
-
|
564
|
+
brick_rel.instance_variable_set(:@_brick_links, bl = { '' => table_name })
|
565
|
+
brick_rel.arel.ast if do_dup # Walk the AST tree in order to capture all the other correlation names
|
564
566
|
bl
|
565
567
|
end
|
566
568
|
end
|
@@ -57,7 +57,7 @@ module Brick::Rails::FormBuilder
|
|
57
57
|
out << ::Brick::Rails.hide_bcrypt(val, nil, 1000)
|
58
58
|
elsif col_type == :string
|
59
59
|
if model.respond_to?(:uploaders) && model.uploaders.key?(col.name&.to_sym) &&
|
60
|
-
|
60
|
+
(url = self.object.send(col.name)&.url) # Carrierwave image?
|
61
61
|
out << "<img src=\"#{url}\" title=\"#{val}\">"
|
62
62
|
elsif model.respond_to?(:enumerized_attributes) && (opts = (attr = model.enumerized_attributes[method])&.options).present?
|
63
63
|
enum_html_options = attr.kind_of?(Enumerize::Multiple) ? html_options.merge({ multiple: true, size: opts.length + 1 }) : html_options
|
@@ -232,15 +232,15 @@ module Brick::Rails::FormTags
|
|
232
232
|
out << if klass._brick_monetized_attributes&.include?(col_name)
|
233
233
|
val ? Money.new(val.to_i).format : ''
|
234
234
|
elsif klass.respond_to?(:uploaders) && klass.uploaders.key?(col_name.to_sym) &&
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
235
|
+
(url = obj.send(col.name)&.url) && # Has a Carrierwave URL? ...
|
236
|
+
# ... and either not restricting Carrierwave, or under the defined Carrierwave attachment limit?
|
237
|
+
(!(limit_carrierwave = ::Brick.config.limit_carrierwave) ||
|
238
|
+
(limit_carrierwave.is_a?(Numeric) &&
|
239
|
+
(carrierwave_count = instance_variable_get(:@_carrierwave_count) || 0) &&
|
240
|
+
((carrierwave_count += 1) < limit_carrierwave) &&
|
241
|
+
instance_variable_set(:@_carrierwave_count, carrierwave_count)
|
242
|
+
)
|
243
|
+
)
|
244
244
|
"<img class=\"thumbImg\" src=\"#{url}\" title=\"#{val}\">"
|
245
245
|
else
|
246
246
|
lat_lng = if [:float, :decimal].include?(col.type) &&
|
data/lib/brick/version_number.rb
CHANGED
data/lib/brick.rb
CHANGED
@@ -1512,7 +1512,7 @@ module ActiveRecord
|
|
1512
1512
|
module QueryMethods
|
1513
1513
|
private
|
1514
1514
|
|
1515
|
-
if private_instance_methods.include?(:build_join_query)
|
1515
|
+
if private_instance_methods.include?(:build_join_query) # AR 5.0 - 6.0
|
1516
1516
|
alias _brick_build_join_query build_join_query
|
1517
1517
|
def build_join_query(manager, buckets, *args) # , **kwargs)
|
1518
1518
|
# %%% Better way to bring relation into the mix
|
@@ -1523,7 +1523,7 @@ module ActiveRecord
|
|
1523
1523
|
_brick_build_join_query(manager, buckets, *args) # , **kwargs)
|
1524
1524
|
end
|
1525
1525
|
|
1526
|
-
elsif private_instance_methods.include?(:select_association_list)
|
1526
|
+
elsif private_instance_methods.include?(:select_association_list) # AR >= 6.1
|
1527
1527
|
alias _brick_select_association_list select_association_list
|
1528
1528
|
def select_association_list(associations, stashed_joins = nil)
|
1529
1529
|
result = _brick_select_association_list(associations, stashed_joins)
|
@@ -1531,7 +1531,7 @@ module ActiveRecord
|
|
1531
1531
|
result
|
1532
1532
|
end
|
1533
1533
|
|
1534
|
-
# else #
|
1534
|
+
# else # AR 4.2 and older
|
1535
1535
|
# alias _brick_build_joins build_joins
|
1536
1536
|
# def build_joins(manager, joins)
|
1537
1537
|
# result = _brick_build_joins(manager, joins)
|
@@ -1551,12 +1551,12 @@ module ActiveRecord
|
|
1551
1551
|
# Capture the table alias name that was chosen
|
1552
1552
|
# if (relation = node.instance_variable_get(:@assocs)&.instance_variable_get(:@relation))
|
1553
1553
|
# link_path = node.instance_variable_get(:@link_path)
|
1554
|
-
# relation.brick_links[link_path] = result.first.table_alias || result.first.table_name
|
1554
|
+
# relation.brick_links(false)[link_path] = result.first.table_alias || result.first.table_name
|
1555
1555
|
# end
|
1556
1556
|
result
|
1557
1557
|
end
|
1558
1558
|
end
|
1559
|
-
else # For AR >= 4.
|
1559
|
+
else # For AR >= 4.1
|
1560
1560
|
class JoinDependency
|
1561
1561
|
# An intelligent .eager_load() and .includes() that creates t0_r0 style aliases only for the columns
|
1562
1562
|
# used in .select(). To enable this behaviour, include the flag :_brick_eager_load as the first
|
@@ -1652,7 +1652,7 @@ module ActiveRecord
|
|
1652
1652
|
# Capture the table alias name that was chosen
|
1653
1653
|
if (relation = node.instance_variable_get(:@assocs)&.instance_variable_get(:@relation))
|
1654
1654
|
link_path = node.instance_variable_get(:@link_path)
|
1655
|
-
relation.brick_links[link_path] = result.first.table_alias || result.first.table_name
|
1655
|
+
relation.brick_links(false)[link_path] = result.first.table_alias || result.first.table_name
|
1656
1656
|
end
|
1657
1657
|
result
|
1658
1658
|
end
|
@@ -1663,7 +1663,7 @@ module ActiveRecord
|
|
1663
1663
|
# Capture the table alias name that was chosen
|
1664
1664
|
if (relation = child.instance_variable_get(:@assocs)&.instance_variable_get(:@relation))
|
1665
1665
|
link_path = child.instance_variable_get(:@link_path)
|
1666
|
-
relation.brick_links[link_path] = if child.table.is_a?(Arel::Nodes::TableAlias)
|
1666
|
+
relation.brick_links(false)[link_path] = if child.table.is_a?(Arel::Nodes::TableAlias)
|
1667
1667
|
child.table.right
|
1668
1668
|
else
|
1669
1669
|
# Was: result.first&.left&.table_alias || child.table_name
|
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.209
|
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-03-
|
11
|
+
date: 2024-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -285,7 +285,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
285
285
|
- !ruby/object:Gem::Version
|
286
286
|
version: 1.3.6
|
287
287
|
requirements: []
|
288
|
-
rubygems_version: 3.
|
288
|
+
rubygems_version: 3.2.33
|
289
289
|
signing_key:
|
290
290
|
specification_version: 4
|
291
291
|
summary: Create a Rails app from data alone
|