motor-admin 0.2.21 → 0.2.25

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a6fc72d7b1968213aa4845a2df527a839baeff558af4676719eaf8ea3f8ddc93
4
- data.tar.gz: fdc2e35bbdead105ff8e92f90f7b172320941f7ca92af085918517ea27c6eb52
3
+ metadata.gz: 2a53555a0c69ed075e09c63deb22a53381efb7d1935542d8ac760f6bbd168044
4
+ data.tar.gz: 99437be8cbf015ad29890152e45163fc0efbe5f3e747c6d74014640f548f1b28
5
5
  SHA512:
6
- metadata.gz: fe3ff74c52022c83a4e51c1bdb67b0fe7239f644c1b2d70ad689bb70850a9d1955f5abfe2e92e237b936d01177847e7ac2197e492b024cfc52fbc5b15a07e793
7
- data.tar.gz: 00c722957541fcb93b3f22d3c3ed59da71b39517cb9f0f0631990c80f5ae50963a57a26b656d95460175936a6f1214e9bf5185c0f5dfc44aab6252731eccda9d
6
+ metadata.gz: 532dfb71de17b84ca9f70c546290ca35261cf8d886a64cb8764bb1c72c512b3d5170ef9572075db026be9c28a64ddd5a4ce455d28c1d0595fbce0eb0e17a8389
7
+ data.tar.gz: 05c1f902bedf840dca52bf6b3a0229606e43ffcbe156b48431bd72988c81310d5731fe56b55130ddb8260a866d2e789702632502b758bcb9df77d57839d38725
@@ -4,7 +4,7 @@ module Motor
4
4
  module CurrentAbility
5
5
  def current_ability
6
6
  @current_ability ||=
7
- if defined?(Motor::Ability) && current_user
7
+ if defined?(Motor::Ability)
8
8
  klass = Motor::Ability.dup.tap do |k|
9
9
  k.prepend(Motor::CancanUtils::AbilityPatch)
10
10
  end
@@ -142,7 +142,10 @@ module Motor
142
142
 
143
143
  return { select_options: enum.keys } if enum
144
144
 
145
- return { number_format: true } if !column.name.ends_with?('_id') && %i[integer float].include?(column.type)
145
+ return {} if column.name == 'year'
146
+
147
+ return { number_format: true } if !column.name.match?(/_(?:id|year)\z/) &&
148
+ %i[integer float].include?(column.type)
146
149
 
147
150
  {}
148
151
  end
@@ -83,9 +83,7 @@ module Motor
83
83
  end
84
84
 
85
85
  def load_cache_keys
86
- result = ActiveRecord::Base.connection.execute(cache_keys_sql).to_a
87
-
88
- result = result.map(&:values) if result.first.is_a?(Hash)
86
+ result = ActiveRecord::Base.connection.exec_query(cache_keys_sql).rows
89
87
 
90
88
  result.to_h.with_indifferent_access
91
89
  end
@@ -61,7 +61,7 @@ module Motor
61
61
  # @return [ActiveRecord::Result]
62
62
  def execute_query(query, limit, variables_hash, filters)
63
63
  result = nil
64
- statement = prepare_sql_statement(query, limit, variables_hash, filters)
64
+ statement = prepare_sql_statement(connection_class.connection, query, limit, variables_hash, filters)
65
65
 
66
66
  connection_class.transaction do
67
67
  result =
@@ -129,17 +129,18 @@ module Motor
129
129
  end
130
130
  end
131
131
 
132
+ # @param connection [Object]
132
133
  # @param query [Motor::Query]
133
134
  # @param limit [Integer]
134
135
  # @param variables_hash [Hash]
135
136
  # @param filters [Hash]
136
137
  # @return [Array]
137
- def prepare_sql_statement(query, limit, variables_hash, filters)
138
+ def prepare_sql_statement(connection, query, limit, variables_hash, filters)
138
139
  variables = merge_variable_default_values(query.preferences.fetch(:variables, []), variables_hash)
139
140
 
140
141
  sql, query_variables = RenderSqlTemplate.call(query.sql_body, variables)
141
142
  cte_sql = format(WITH_STATEMENT_TEMPLATE, sql_body: sql.strip.delete_suffix(';'))
142
- cte_select_sql = build_cte_select_sql(limit, filters)
143
+ cte_select_sql = build_cte_select_sql(connection, limit, filters)
143
144
 
144
145
  attributes = build_statement_attributes(query_variables)
145
146
 
@@ -149,7 +150,7 @@ module Motor
149
150
  # @param limit [Number]
150
151
  # @param filters [Hash]
151
152
  # @return [String]
152
- def build_cte_select_sql(limit, filters)
153
+ def build_cte_select_sql(connection, limit, filters)
153
154
  table = Arel::Table.new(CTE_NAME)
154
155
 
155
156
  arel_filters = build_filters_arel(filters)
@@ -157,7 +158,9 @@ module Motor
157
158
  expresion = table.project(table[Arel.star])
158
159
  expresion = expresion.where(arel_filters) if arel_filters.present?
159
160
 
160
- expresion.take(limit.to_i).to_sql
161
+ expresion.take(limit.to_i) unless connection.class.name.include?('SQLServerAdapter')
162
+
163
+ expresion.to_sql.delete('"')
161
164
  end
162
165
 
163
166
  # @param filters [Hash]
@@ -9,7 +9,7 @@ module Motor
9
9
 
10
10
  def call(sql)
11
11
  CACHE_STORE.fetch(sql.hash) do
12
- Queries::RunQuery.call(Query.new(sql_body: sql), limit: 0).columns
12
+ Queries::RunQuery.call(Query.new(sql_body: sql), limit: 0).columns || []
13
13
  end
14
14
  end
15
15
  end
data/lib/motor/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Motor
4
- VERSION = '0.2.21'
4
+ VERSION = '0.2.25'
5
5
  end
@@ -2601,9 +2601,9 @@
2601
2601
  "icons/zoom-out.svg.gz": "icons/zoom-out.svg.gz",
2602
2602
  "icons/zoom-question.svg": "icons/zoom-question.svg",
2603
2603
  "icons/zoom-question.svg.gz": "icons/zoom-question.svg.gz",
2604
- "main-fa2bc70ab29bad641f1a.css.gz": "main-fa2bc70ab29bad641f1a.css.gz",
2605
- "main-fa2bc70ab29bad641f1a.js.LICENSE.txt": "main-fa2bc70ab29bad641f1a.js.LICENSE.txt",
2606
- "main-fa2bc70ab29bad641f1a.js.gz": "main-fa2bc70ab29bad641f1a.js.gz",
2607
- "main.css": "main-fa2bc70ab29bad641f1a.css",
2608
- "main.js": "main-fa2bc70ab29bad641f1a.js"
2604
+ "main-0bcdc9f1a27b26d23abd.css.gz": "main-0bcdc9f1a27b26d23abd.css.gz",
2605
+ "main-0bcdc9f1a27b26d23abd.js.LICENSE.txt": "main-0bcdc9f1a27b26d23abd.js.LICENSE.txt",
2606
+ "main-0bcdc9f1a27b26d23abd.js.gz": "main-0bcdc9f1a27b26d23abd.js.gz",
2607
+ "main.css": "main-0bcdc9f1a27b26d23abd.css",
2608
+ "main.js": "main-0bcdc9f1a27b26d23abd.js"
2609
2609
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motor-admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.21
4
+ version: 0.2.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pete Matsyburka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-08 00:00:00.000000000 Z
11
+ date: 2021-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord-filter
@@ -1525,8 +1525,8 @@ files:
1525
1525
  - ui/dist/icons/zoom-money.svg.gz
1526
1526
  - ui/dist/icons/zoom-out.svg.gz
1527
1527
  - ui/dist/icons/zoom-question.svg.gz
1528
- - ui/dist/main-fa2bc70ab29bad641f1a.css.gz
1529
- - ui/dist/main-fa2bc70ab29bad641f1a.js.gz
1528
+ - ui/dist/main-0bcdc9f1a27b26d23abd.css.gz
1529
+ - ui/dist/main-0bcdc9f1a27b26d23abd.js.gz
1530
1530
  - ui/dist/manifest.json
1531
1531
  homepage:
1532
1532
  licenses: