brick 1.0.98 → 1.0.100
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/extensions.rb +19 -10
- data/lib/brick/frameworks/rails/engine.rb +1 -1
- data/lib/brick/frameworks/rails/form_tags.rb +5 -4
- 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: ba0de7f332d1d98502a4e66bc4fda9b44d4f97fe6d6a259ac7527a856c726000
|
4
|
+
data.tar.gz: 45898a638f4c944cf33e98ff73a41da97686819bbdfcc8534257c013a6b28582
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28079c58b020d395845c681710c88db3e7a32ae312fbdf607ab496854aab37d29f3a9dfed78a2495a011b3817aed8259260a1d0d5ecd409803d89b4eda70b87f
|
7
|
+
data.tar.gz: 834499603e05412ee19c2f5db90f55df1f927eff85a41488e4f57381065580aeb4477700596988e4cc630282268f40045d1831822bde2c80b659a23e257f692a
|
data/lib/brick/extensions.rb
CHANGED
@@ -398,7 +398,7 @@ module ActiveRecord
|
|
398
398
|
# Links from ActiveRecord association pathing names over to real table correlation names
|
399
399
|
# that get chosen when the AREL AST tree is walked.
|
400
400
|
def brick_links
|
401
|
-
@brick_links ||= {}
|
401
|
+
@brick_links ||= { '' => table_name }
|
402
402
|
end
|
403
403
|
|
404
404
|
def brick_select(params, selects = [], order_by = nil, translations = {}, join_array = ::Brick::JoinArray.new)
|
@@ -436,6 +436,7 @@ module ActiveRecord
|
|
436
436
|
|
437
437
|
# %%% Skip the metadata columns
|
438
438
|
if selects.empty? # Default to all columns
|
439
|
+
id_parts = (id_col = klass.primary_key).is_a?(Array) ? id_col : [id_col]
|
439
440
|
tbl_no_schema = table.name.split('.').last
|
440
441
|
# %%% Have once gotten this error with MSSQL referring to http://localhost:3000/warehouse/cold_room_temperatures__archive
|
441
442
|
# ActiveRecord::StatementInvalid (TinyTds::Error: DBPROCESS is dead or not enabled)
|
@@ -496,16 +497,23 @@ module ActiveRecord
|
|
496
497
|
dest_pk = nil
|
497
498
|
key_alias = nil
|
498
499
|
cc.first.each do |cc_part|
|
499
|
-
dest_klass = cc_part[0..-2].inject(klass)
|
500
|
+
dest_klass = cc_part[0..-2].inject(klass) do |kl, cc_part_term|
|
501
|
+
# %%% Clear column info properly so we can do multiple subsequent requests
|
502
|
+
# binding.pry unless kl.reflect_on_association(cc_part_term)
|
503
|
+
kl.reflect_on_association(cc_part_term)&.klass || klass
|
504
|
+
end
|
500
505
|
tbl_name = rel_dupe.brick_links[cc_part[0..-2].map(&:to_s).join('.')]
|
501
506
|
# Deal with the conflict if there are two parts in the custom column named the same,
|
502
507
|
# "category.name" and "product.name" for instance will end up with aliases of "name"
|
503
508
|
# and "product__name".
|
504
|
-
cc_part_idx = cc_part.length - 1
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
+
if (cc_part_idx = cc_part.length - 1).zero?
|
510
|
+
col_alias = "br_cc_#{k}__#{table_name.tr('.', '_')}"
|
511
|
+
else
|
512
|
+
while cc_part_idx > 0 &&
|
513
|
+
(col_alias = "br_cc_#{k}__#{cc_part[cc_part_idx..-1].map(&:to_s).join('__').tr('.', '_')}") &&
|
514
|
+
used_col_aliases.key?(col_alias)
|
515
|
+
cc_part_idx -= 1
|
516
|
+
end
|
509
517
|
end
|
510
518
|
used_col_aliases[col_alias] = nil
|
511
519
|
# Set up custom column links by preparing key_klass and key_alias
|
@@ -963,7 +971,7 @@ Module.class_exec do
|
|
963
971
|
::Brick.is_oracle ? class_name.upcase : class_name,
|
964
972
|
(plural_class_name = class_name.pluralize)].find { |s| Brick.db_schemas&.include?(s) }&.camelize ||
|
965
973
|
(::Brick.config.sti_namespace_prefixes&.key?("::#{class_name}::") && class_name) ||
|
966
|
-
(::Brick.config.table_name_prefixes
|
974
|
+
(::Brick.config.table_name_prefixes.values.include?(class_name) && class_name))
|
967
975
|
return self.const_get(schema_name) if self.const_defined?(schema_name)
|
968
976
|
|
969
977
|
# Build out a module for the schema if it's namespaced
|
@@ -1372,7 +1380,7 @@ class Object
|
|
1372
1380
|
when Symbol
|
1373
1381
|
order_tbl[order_default] || order_default
|
1374
1382
|
else
|
1375
|
-
pk.map(
|
1383
|
+
pk.map { |part| "#{table_name}.#{part}"}.join(', ') # If it's not a custom ORDER BY, just use the key
|
1376
1384
|
end
|
1377
1385
|
end
|
1378
1386
|
|
@@ -1568,7 +1576,8 @@ class Object
|
|
1568
1576
|
order_by, _ = model._brick_calculate_ordering(ordering, true) # Don't do the txt part
|
1569
1577
|
|
1570
1578
|
ar_relation = ActiveRecord.version < Gem::Version.new('4') ? model.preload : model.all
|
1571
|
-
|
1579
|
+
|
1580
|
+
@_brick_params = ar_relation.brick_select(params, (selects ||= []), order_by,
|
1572
1581
|
translations = {},
|
1573
1582
|
join_array = ::Brick::JoinArray.new)
|
1574
1583
|
# %%% Add custom HM count columns
|
@@ -54,7 +54,7 @@ module Brick
|
|
54
54
|
end
|
55
55
|
|
56
56
|
# When table names have specific prefixes, automatically place them in their own module with a table_name_prefix.
|
57
|
-
::Brick.table_name_prefixes = app.config.brick.fetch(:table_name_prefixes,
|
57
|
+
::Brick.table_name_prefixes = app.config.brick.fetch(:table_name_prefixes, {})
|
58
58
|
|
59
59
|
# Columns to treat as being metadata for purposes of identifying associative tables for has_many :through
|
60
60
|
::Brick.metadata_columns = app.config.brick.fetch(:metadata_columns, ['created_at', 'updated_at', 'deleted_at'])
|
@@ -11,7 +11,7 @@ module Brick::Rails::FormTags
|
|
11
11
|
out << "<th x-order=\"#{pk.join(',')}\"></th>"
|
12
12
|
end
|
13
13
|
|
14
|
-
col_keys
|
14
|
+
col_keys ||= relation.columns.each_with_object([]) do |col, s|
|
15
15
|
col_name = col.name
|
16
16
|
next if inclusions&.exclude?(col_name) ||
|
17
17
|
(pk.include?(col_name) && [:integer, :uuid].include?(col.type) && !bts.key?(col_name)) ||
|
@@ -122,7 +122,7 @@ module Brick::Rails::FormTags
|
|
122
122
|
if (link_id = obj.send(cust_col.last[1]) if cust_col.last)
|
123
123
|
out << link_to(cust_txt, send("#{cust_col.last.first._brick_index(:singular)}_path", link_id))
|
124
124
|
else
|
125
|
-
out << cust_txt
|
125
|
+
out << (cust_txt || '')
|
126
126
|
end
|
127
127
|
else # Bad column name!
|
128
128
|
out << '?'
|
@@ -186,13 +186,14 @@ module Brick::Rails::FormTags
|
|
186
186
|
end
|
187
187
|
end
|
188
188
|
filter = "?#{filter_parts.join('&')}" if filter_parts.present?
|
189
|
+
app_routes = Rails.application.routes # In case we're operating in another engine, reference the application since Brick routes are placed there.
|
189
190
|
if (klass_or_obj&.is_a?(Class) && klass_or_obj < ActiveRecord::Base) ||
|
190
191
|
(klass_or_obj&.is_a?(ActiveRecord::Base) && klass_or_obj.new_record? && (klass_or_obj = klass_or_obj.class))
|
191
|
-
path = (proc = kwargs[:index_proc]) ? proc.call(klass_or_obj) : "#{
|
192
|
+
path = (proc = kwargs[:index_proc]) ? proc.call(klass_or_obj) : "#{app_routes.path_for(controller: klass_or_obj.base_class._brick_index, action: :index)}#{filter}"
|
192
193
|
lt_args = [text || "Index for #{klass_or_obj.name.pluralize}", path]
|
193
194
|
else
|
194
195
|
# If there are multiple incoming parameters then last one is probably the actual ID, and first few might be some nested tree of stuff leading up to it
|
195
|
-
path = (proc = kwargs[:show_proc]) ? proc.call(klass_or_obj) : "#{
|
196
|
+
path = (proc = kwargs[:show_proc]) ? proc.call(klass_or_obj) : "#{app_routes.path_for(controller: klass_or_obj.class.base_class._brick_index, action: :show, id: klass_or_obj)}#{filter}"
|
196
197
|
lt_args = [text || "Show this #{klass_or_obj.class.name}", path]
|
197
198
|
end
|
198
199
|
link_to(*lt_args, **kwargs)
|
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.100
|
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-12-
|
11
|
+
date: 2022-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|