brick 1.0.134 → 1.0.135

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: 613c6296c56af562bc77d55d734b0a6e5bdad7e3942891db4dc939fe087fca7f
4
- data.tar.gz: acc5873eeae8a0d9e9d4a86cc8b71ee12dc0699821dee132c40c569147156075
3
+ metadata.gz: 28451931f3f43343f010a14d83dd3ed2d4c2fc80e61234d5a96775dd16ff4f11
4
+ data.tar.gz: aeb7327ab42e4252d60ec92bc25d93c778fe15d83744b830aad7673d833c3e75
5
5
  SHA512:
6
- metadata.gz: 046bec9f177ec74aaa3bbba3ef1dd2afe54f43376068ed657ed0fec6d18ac353e8addfabad514fdf33cc6199d053ca1e23c0f46aa1a53cac96fe6e21f7a50796
7
- data.tar.gz: 7d21817ea8774f65852be247ae72c341559c84b0a58228d019d5630036827a99988699752392bbc43330400761ea9e59292231bae5993fa0620240126fe7490e
6
+ metadata.gz: bd85040932260d4a6d68eb46a0406cdbce355a3beb793fa8b56fca51228f4227c430b44fdb7852a8280894720220af4e6564775dfd474bbecf722749909779c3
7
+ data.tar.gz: f4f34d81eab0bf2922c888d618dd1e115f605132578627f7a16c39420d78a574bf63b2fd3e4d3a9278ceab52c4abba6bbc16bf1884dfd4183c0473c8943e42ca
@@ -388,18 +388,42 @@ module ActiveRecord
388
388
  order_by_txt&.<<("Arel.sql(#{ord_expr})")
389
389
  s << Arel.sql(ord_expr)
390
390
  else # Expecting only Symbol
391
- if _br_hm_counts.key?(ord_part)
392
- ord_part = "\"b_r_#{ord_part}_ct\""
393
- elsif !_br_bt_descrip.key?(ord_part) && !_br_cust_cols.key?(ord_part) && !column_names.include?(ord_part.to_s)
391
+ ord_part = ord_part.to_s
392
+ if ord_part[0] == '-' # First char '-' means descending order
393
+ ord_part.slice!(0)
394
+ is_desc = true
395
+ end
396
+ if ord_part[0] == '~' # Char '~' means order NULLs as highest values instead of lowest
397
+ ord_part.slice!(0)
398
+ # (Unfortunately SQLServer does not support NULLS FIRST / NULLS LAST, so leave them out.)
399
+ is_nulls_switch = case ActiveRecord::Base.connection.adapter_name
400
+ when 'PostgreSQL', 'OracleEnhanced', 'SQLite'
401
+ :pg
402
+ when 'Mysql2', 'Trilogy'
403
+ :mysql
404
+ end
405
+ end
406
+ if _br_hm_counts.key?(ord_part_sym = ord_part.to_sym)
407
+ ord_part = +"\"b_r_#{ord_part}_ct\""
408
+ elsif _br_bt_descrip.key?(ord_part_sym)
409
+ ord_part = _br_bt_descrip.fetch(ord_part_sym, nil)&.first&.last&.first&.last&.dup
410
+ elsif !_br_cust_cols.key?(ord_part_sym) && !column_names.include?(ord_part)
394
411
  # Disallow ordering by a bogus column
395
412
  # %%% Note this bogus entry so that Javascript can remove any bogus _brick_order
396
413
  # parameter from the querystring, pushing it into the browser history.
397
414
  ord_part = nil
398
415
  end
416
+
399
417
  if ord_part
400
- # Retain any reference to a bt_descrip as being a symbol
401
- # Was: "#{quoted_table_name}.\"#{ord_part}\""
402
- order_by_txt&.<<(_br_bt_descrip.key?(ord_part) ? ord_part : ord_part.inspect)
418
+ ord_part << ' DESC' if is_desc
419
+ ord_part << (is_desc ? ' NULLS LAST' : ' NULLS FIRST') if is_nulls_switch == :pg
420
+ ord_part.insert(0, '-') if is_nulls_switch == :mysql
421
+
422
+ order_by_txt&.<<("Arel.sql(#{ord_part.inspect})")
423
+
424
+ # # Retain any reference to a bt_descrip as being a symbol
425
+ # # Was: "#{quoted_table_name}.\"#{ord_part}\""
426
+ # order_by_txt&.<<(_br_bt_descrip.key?(ord_part) ? ord_part : ord_part.inspect)
403
427
  s << ord_part
404
428
  end
405
429
  end
@@ -837,7 +861,8 @@ JOIN (SELECT #{hm_selects.map { |s| "#{'br_t0.' if from_clause}#{s}" }.join(', '
837
861
  # or custom columns as they must be expanded to find the corresponding b_r_model__column
838
862
  # or br_cc_column naming for each.
839
863
  if order_by.present?
840
- final_order_by = *order_by.each_with_object([]) do |v, s|
864
+ order_by, _ = klass._brick_calculate_ordering(order_by, true) # Don't do the txt part
865
+ final_order_by = order_by.each_with_object([]) do |v, s|
841
866
  if v.is_a?(Symbol)
842
867
  # Add the ordered series of columns derived from the BT based on its DSL
843
868
  if (bt_cols = klass._br_bt_descrip[v])
@@ -1132,7 +1157,7 @@ Module.class_exec do
1132
1157
  base_module.const_set(schema_name.to_sym, (built_module = Module.new))
1133
1158
 
1134
1159
  [built_module, "module #{schema_name}; end\n"]
1135
- # # %%% Perhaps an option to use the first module just as schema, and additional modules as namespace with a table name prefix applied
1160
+ # %%% Perhaps an option to use the first module just as schema, and additional modules as namespace with a table name prefix applied
1136
1161
 
1137
1162
  # AVO Resource
1138
1163
  elsif base_module == Object && Object.const_defined?('Avo') && requested.end_with?('Resource') &&
@@ -1778,8 +1803,7 @@ class Object
1778
1803
 
1779
1804
  # %%% Allow params to define which columns to use for order_by
1780
1805
  # Overriding the default by providing a querystring param?
1781
- ordering = params['_brick_order']&.split(',')&.map(&:to_sym) || Object.send(:default_ordering, table_name, pk)
1782
- order_by, _ = real_model._brick_calculate_ordering(ordering, true) # Don't do the txt part
1806
+ order_by = params['_brick_order']&.split(',')&.map(&:to_sym) || Object.send(:default_ordering, table_name, pk)
1783
1807
 
1784
1808
  ar_relation = ActiveRecord.version < Gem::Version.new('4') ? real_model.preload : real_model.all
1785
1809
  params['_brick_is_api'] = true if (is_api = request.format == :js || current_api_root)
@@ -1711,9 +1711,9 @@ end
1711
1711
  <tr><td>(none)</td></tr>
1712
1712
  <% else
1713
1713
  collection2.each do |#{hm_singular_name}| %>
1714
- <tr><td><%= br_descrip ||= #{hm_singular_name}.brick_descrip(
1715
- descrip_cols&.first&.map { |col| #{hm_singular_name}.send(col.last) }
1716
- )
1714
+ <tr><td><%= br_descrip = #{hm_singular_name}.brick_descrip(
1715
+ descrip_cols&.first&.map { |col| #{hm_singular_name}.send(col.last) }
1716
+ )
1717
1717
  link_to(br_descrip, #{hm.first.klass._brick_index(:singular)}_path(slashify(#{obj_pk}))) %></td></tr>
1718
1718
  <% end %>
1719
1719
  <% end %>
@@ -5,7 +5,7 @@ module Brick
5
5
  module VERSION
6
6
  MAJOR = 1
7
7
  MINOR = 0
8
- TINY = 134
8
+ TINY = 135
9
9
 
10
10
  # PRE is nil unless it's a pre-release (beta, RC, etc.)
11
11
  PRE = nil
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.134
4
+ version: 1.0.135
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lorin Thwaits
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-25 00:00:00.000000000 Z
11
+ date: 2023-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord