brick 1.0.96 → 1.0.97

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: 0061ad25b22deee43d1939b6541257924a61a67b3b8b004fb6a0072302746ca2
4
- data.tar.gz: 99968b9de834f73c60842bf5da03b5bddd750f1ff8c3ac1dac294078f0eb2358
3
+ metadata.gz: c257a0a65807fa87a13d722f3cc30c38d51bde571a070df53f4277fc6db8b7ba
4
+ data.tar.gz: 74d7690a968fab671d9e9e8ac92e41885ceb44a700fd1cb293f3b79af819e463
5
5
  SHA512:
6
- metadata.gz: 4958e2b0c18522be75134ab29df481213594189b4addd6ef9368ae8677aba603cbb278176c57c51217a49c0042e98927cb33465995bc4aae01f3af59b2d64f15
7
- data.tar.gz: 1d486886f30ce384edc7d84a441617906b26b001c7c3562558289eedfd4b0c12e2a860c587f71acb6e6727649a3756223f1240c07f4e1013029cfe5b67a9c117
6
+ metadata.gz: 4337faa80a6f0d9c1dadcb3271aea14ec54bb91e72cd7eead7e59c860557f828ac073cab3768feaa2db2f664d63b1604bd8f8e0d53c64621b1fcf5cc041057d9
7
+ data.tar.gz: 541cade2070bd0a79b21dd7155df700b2739084ae81eaa02709f9e00164f956e62e8342330a78496c4b5fbf351cac9ea40483d3cdc32c1fb1dbe8d7e34499d2d
@@ -5,7 +5,7 @@ module Brick
5
5
  module VERSION
6
6
  MAJOR = 1
7
7
  MINOR = 0
8
- TINY = 96
8
+ TINY = 97
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
@@ -1257,35 +1257,33 @@ module ActiveRecord
1257
1257
  # For AR >= 4.2
1258
1258
  if self.const_defined?('JoinDependency')
1259
1259
  class JoinDependency
1260
- if ActiveRecord.version >= ::Gem::Version.new('6.0')
1261
- # An intelligent .eager_load() and .includes() that creates t0_r0 style aliases only for the columns
1262
- # used in .select(). To enable this behaviour, include the flag :_brick_eager_load as the first
1263
- # entry in your .select().
1264
- # More information: https://discuss.rubyonrails.org/t/includes-and-select-for-joined-data/81640
1265
- def apply_column_aliases(relation)
1266
- used_cols = {}
1267
- if (sel_vals = relation.select_values.map(&:to_s)).first == '_brick_eager_load'
1268
- # Find and expand out all column names being used in select(...)
1269
- new_select_values = sel_vals.each_with_object([]) do |col, s|
1270
- next if col == '_brick_eager_load'
1271
-
1272
- if col.include?(' ') # Some expression? (No chance for a simple column reference)
1273
- s << col # Just pass it through
1274
- else
1275
- col = if (col_parts = col.split('.')).length == 1
1276
- [col]
1277
- else
1278
- [col_parts[0..-2].join('.'), col_parts.last]
1279
- end
1280
- used_cols[col] = nil
1281
- end
1282
- end
1283
- if new_select_values.present?
1284
- relation.select_values = new_select_values
1260
+ # An intelligent .eager_load() and .includes() that creates t0_r0 style aliases only for the columns
1261
+ # used in .select(). To enable this behaviour, include the flag :_brick_eager_load as the first
1262
+ # entry in your .select().
1263
+ # More information: https://discuss.rubyonrails.org/t/includes-and-select-for-joined-data/81640
1264
+ def apply_column_aliases(relation)
1265
+ used_cols = {}
1266
+ if (sel_vals = relation.select_values.map(&:to_s)).first == '_brick_eager_load'
1267
+ # Find and expand out all column names being used in select(...)
1268
+ new_select_values = sel_vals.each_with_object([]) do |col, s|
1269
+ next if col == '_brick_eager_load'
1270
+
1271
+ if col.include?(' ') # Some expression? (No chance for a simple column reference)
1272
+ s << col # Just pass it through
1285
1273
  else
1286
- relation.select_values.clear
1274
+ col = if (col_parts = col.split('.')).length == 1
1275
+ [col]
1276
+ else
1277
+ [col_parts[0..-2].join('.'), col_parts.last]
1278
+ end
1279
+ used_cols[col] = nil
1287
1280
  end
1288
1281
  end
1282
+ if new_select_values.present?
1283
+ relation.select_values = new_select_values
1284
+ else
1285
+ relation.select_values.clear
1286
+ end
1289
1287
 
1290
1288
  @aliases ||= Aliases.new(join_root.each_with_index.map do |join_part, i|
1291
1289
  join_alias = join_part.table&.table_alias || join_part.table_name
@@ -1315,9 +1313,9 @@ module ActiveRecord
1315
1313
  end
1316
1314
  Aliases::Table.new(join_part, columns)
1317
1315
  end)
1318
-
1319
- relation._select!(-> { @aliases.columns })
1320
1316
  end
1317
+
1318
+ relation._select!(-> { aliases.columns })
1321
1319
  end
1322
1320
 
1323
1321
  private
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brick
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.96
4
+ version: 1.0.97
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lorin Thwaits