brick 1.0.95 → 1.0.96
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/brick/config.rb +4 -4
- data/lib/brick/frameworks/rails/engine.rb +2 -2
- data/lib/brick/version_number.rb +1 -1
- data/lib/brick.rb +54 -52
- 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: 0061ad25b22deee43d1939b6541257924a61a67b3b8b004fb6a0072302746ca2
|
4
|
+
data.tar.gz: 99968b9de834f73c60842bf5da03b5bddd750f1ff8c3ac1dac294078f0eb2358
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4958e2b0c18522be75134ab29df481213594189b4addd6ef9368ae8677aba603cbb278176c57c51217a49c0042e98927cb33465995bc4aae01f3af59b2d64f15
|
7
|
+
data.tar.gz: 1d486886f30ce384edc7d84a441617906b26b001c7c3562558289eedfd4b0c12e2a860c587f71acb6e6727649a3756223f1240c07f4e1013029cfe5b67a9c117
|
data/lib/brick/config.rb
CHANGED
@@ -304,12 +304,12 @@ module Brick
|
|
304
304
|
true
|
305
305
|
end
|
306
306
|
|
307
|
-
def
|
308
|
-
@mutex.synchronize { @
|
307
|
+
def license
|
308
|
+
@mutex.synchronize { @license }
|
309
309
|
end
|
310
310
|
|
311
|
-
def
|
312
|
-
@mutex.synchronize { @
|
311
|
+
def license=(key)
|
312
|
+
@mutex.synchronize { @license = key }
|
313
313
|
end
|
314
314
|
end
|
315
315
|
end
|
@@ -1097,10 +1097,10 @@ erDiagram
|
|
1097
1097
|
end
|
1098
1098
|
|
1099
1099
|
when 'crosstab'
|
1100
|
-
if is_crosstab && ::Brick.config.
|
1100
|
+
if is_crosstab && ::Brick.config.license
|
1101
1101
|
decipher = OpenSSL::Cipher::AES256.new(:CBC).decrypt
|
1102
1102
|
decipher.iv = "\xB4,\r2\x19\xF5\xFE/\aR\x1A\x8A\xCFV\v\x8C"
|
1103
|
-
decipher.key = Digest::SHA256.hexdigest(::Brick.config.
|
1103
|
+
decipher.key = Digest::SHA256.hexdigest(::Brick.config.license).scan(/../).map { |x| x.hex }.pack('c*')
|
1104
1104
|
decipher.update(File.binread("/Users/aga/brick/lib/brick/frameworks/rails/crosstab.brk"))[16..-1]
|
1105
1105
|
else
|
1106
1106
|
'Crosstab Charting not yet activated -- enter a valid license key in brick.rb'
|
data/lib/brick/version_number.rb
CHANGED
data/lib/brick.rb
CHANGED
@@ -466,8 +466,8 @@ module Brick
|
|
466
466
|
Brick.config.default_route_fallback = resource_name
|
467
467
|
end
|
468
468
|
|
469
|
-
def
|
470
|
-
Brick.config.
|
469
|
+
def license=(key)
|
470
|
+
Brick.config.license = key
|
471
471
|
end
|
472
472
|
|
473
473
|
# Load additional references (virtual foreign keys)
|
@@ -1257,65 +1257,67 @@ 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
|
-
|
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
|
1273
1285
|
else
|
1274
|
-
|
1275
|
-
[col]
|
1276
|
-
else
|
1277
|
-
[col_parts[0..-2].join('.'), col_parts.last]
|
1278
|
-
end
|
1279
|
-
used_cols[col] = nil
|
1286
|
+
relation.select_values.clear
|
1280
1287
|
end
|
1281
1288
|
end
|
1282
|
-
if new_select_values.present?
|
1283
|
-
relation.select_values = new_select_values
|
1284
|
-
else
|
1285
|
-
relation.select_values.clear
|
1286
|
-
end
|
1287
|
-
end
|
1288
1289
|
|
1289
|
-
|
1290
|
-
|
1291
|
-
|
1290
|
+
@aliases ||= Aliases.new(join_root.each_with_index.map do |join_part, i|
|
1291
|
+
join_alias = join_part.table&.table_alias || join_part.table_name
|
1292
|
+
keys = [join_part.base_klass.primary_key] # Always include the primary key
|
1292
1293
|
|
1293
|
-
|
1294
|
-
|
1294
|
+
# # %%% Optional to include all foreign keys:
|
1295
|
+
# keys.concat(join_part.base_klass.reflect_on_all_associations.select { |a| a.belongs_to? }.map(&:foreign_key))
|
1295
1296
|
|
1296
|
-
|
1297
|
-
|
1297
|
+
# Add foreign keys out to referenced tables that we belongs_to
|
1298
|
+
join_part.children.each { |child| keys << child.reflection.foreign_key if child.reflection.belongs_to? }
|
1298
1299
|
|
1299
|
-
|
1300
|
-
|
1301
|
-
|
1302
|
-
|
1303
|
-
|
1304
|
-
end
|
1305
|
-
keys = keys.compact # In case we're using composite_primary_keys
|
1306
|
-
j = 0
|
1307
|
-
columns = join_part.column_names.each_with_object([]) do |column_name, s|
|
1308
|
-
# Include columns chosen in select(...) as well as the PK and any relevant FKs
|
1309
|
-
if used_cols.keys.find { |c| (c.length == 1 || c.first == join_alias) && c.last == column_name } ||
|
1310
|
-
keys.find { |c| c == column_name }
|
1311
|
-
s << Aliases::Column.new(column_name, "t#{i}_r#{j}")
|
1300
|
+
# Add the foreign key that got us here -- "the train we rode in on" -- if we arrived from
|
1301
|
+
# a has_many or has_one:
|
1302
|
+
if join_part.is_a?(ActiveRecord::Associations::JoinDependency::JoinAssociation) &&
|
1303
|
+
!join_part.reflection.belongs_to?
|
1304
|
+
keys << join_part.reflection.foreign_key
|
1312
1305
|
end
|
1313
|
-
|
1314
|
-
|
1315
|
-
|
1316
|
-
|
1306
|
+
keys = keys.compact # In case we're using composite_primary_keys
|
1307
|
+
j = 0
|
1308
|
+
columns = join_part.column_names.each_with_object([]) do |column_name, s|
|
1309
|
+
# Include columns chosen in select(...) as well as the PK and any relevant FKs
|
1310
|
+
if used_cols.keys.find { |c| (c.length == 1 || c.first == join_alias) && c.last == column_name } ||
|
1311
|
+
keys.find { |c| c == column_name }
|
1312
|
+
s << Aliases::Column.new(column_name, "t#{i}_r#{j}")
|
1313
|
+
end
|
1314
|
+
j += 1
|
1315
|
+
end
|
1316
|
+
Aliases::Table.new(join_part, columns)
|
1317
|
+
end)
|
1317
1318
|
|
1318
|
-
|
1319
|
+
relation._select!(-> { @aliases.columns })
|
1320
|
+
end
|
1319
1321
|
end
|
1320
1322
|
|
1321
1323
|
private
|
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.96
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lorin Thwaits
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-11-
|
11
|
+
date: 2022-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|