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 +4 -4
- data/lib/brick/version_number.rb +1 -1
- data/lib/brick.rb +26 -28
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c257a0a65807fa87a13d722f3cc30c38d51bde571a070df53f4277fc6db8b7ba
|
4
|
+
data.tar.gz: 74d7690a968fab671d9e9e8ac92e41885ceb44a700fd1cb293f3b79af819e463
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4337faa80a6f0d9c1dadcb3271aea14ec54bb91e72cd7eead7e59c860557f828ac073cab3768feaa2db2f664d63b1604bd8f8e0d53c64621b1fcf5cc041057d9
|
7
|
+
data.tar.gz: 541cade2070bd0a79b21dd7155df700b2739084ae81eaa02709f9e00164f956e62e8342330a78496c4b5fbf351cac9ea40483d3cdc32c1fb1dbe8d7e34499d2d
|
data/lib/brick/version_number.rb
CHANGED
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
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
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
|
-
|
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
|