motor-admin 0.2.23 → 0.2.27

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: bf26c048e51c1aa9f5b43c2356fef76668d00c6f0c5de13a9fe52db8dfc25ee1
4
- data.tar.gz: 3b0ffc4caf26e63b813fa93a777254e0117c2e9484c71cca539f384868eae68a
3
+ metadata.gz: acd8302f343dd0ce3ccad39dd408dc90e7582fb63133cf0abfb3fa1112899cb8
4
+ data.tar.gz: 21dc6ca6b743b0499e8bf3b314465be503cfcc6ce789bd2653f8e278e72b38dc
5
5
  SHA512:
6
- metadata.gz: 01ad26d6c0d7a9c74143051a8d11efbcc35c953d1995998826d68e87ac60a8d4c65ec3a7a6cbb1c68df4e14fb06b3885244a9d7721f7a4adcb01545eca51d707
7
- data.tar.gz: 80ca3dea1aae9d8c477a63a51d8023d0365d2f5a96b15d157f8035af842369667dd2356c2d8759d0be8264694eb3b04e875b6ed001a940b7c5d5b1cdb6ec218c
6
+ metadata.gz: c277ba2eee535baf91c0959d42187e76b0aff57cb24129c1d79917fca6259c2ed2a0b5f59b9fe289dbad1877fc17d7ea3bde2678cf686b5f98ecf558fbe0b0e6
7
+ data.tar.gz: 3ff35c6aa910c27771f108dd9a6fbedb73efd57f5a16890ef8589fcce4d733f41b584a1a4f6e79faa9554e964e17eb2aa1ff1bc38655ed9c5acb2f9a3520e6ef
@@ -278,3 +278,9 @@ en:
278
278
  there_is_nothing_here_yet: There is nothing here yet 🤷‍♂️
279
279
  is_null: Is null
280
280
  is_not_null: Is not null
281
+ split_tags_by: Split tags by
282
+ do_not_split: Do not split
283
+ semicolon: Semicolon
284
+ hyphen: Hyphen
285
+ comma: Comma
286
+ slash: Slash
@@ -278,6 +278,12 @@ es:
278
278
  there_is_nothing_here_yet: Todavía no hay nada aquí 🤷‍♂️
279
279
  is_null: Es nulo
280
280
  is_not_null: No es nulo
281
+ split_tags_by: Dividir las etiquetas por
282
+ do_not_split: No dividir
283
+ semicolon: Punto y coma
284
+ hyphen: Guión
285
+ comma: Coma
286
+ slash: Slash
281
287
  i:
282
288
  locale: es
283
289
  select:
@@ -274,6 +274,12 @@ pt:
274
274
  there_is_nothing_here_yet: Ainda não há nada aqui 🤷‍♂️
275
275
  is_null: É nulo
276
276
  is_not_null: Não é nulo
277
+ split_tags_by: Dividir as etiquetas por
278
+ do_not_split: Não dividir
279
+ semicolon: Ponto-e-vírgula
280
+ hyphen: Hífen
281
+ comma: Vírgula
282
+ slash: Slash
277
283
  i:
278
284
  locale: pt
279
285
  select:
@@ -116,13 +116,20 @@ module Motor
116
116
  end
117
117
 
118
118
  def build_table_column(column, model, default_attrs)
119
+ access_type =
120
+ if model.primary_key == column.name
121
+ ColumnAccessTypes::READ_ONLY
122
+ else
123
+ COLUMN_NAME_ACCESS_TYPES.fetch(column.name, ColumnAccessTypes::READ_WRITE)
124
+ end
125
+
119
126
  {
120
127
  name: column.name,
121
128
  display_name: Utils.humanize_column_name(model.human_attribute_name(column.name)),
122
129
  column_type: fetch_column_type(column, model),
123
130
  column_source: ColumnSources::TABLE,
124
131
  is_array: column.array?,
125
- access_type: COLUMN_NAME_ACCESS_TYPES.fetch(column.name, ColumnAccessTypes::READ_WRITE),
132
+ access_type: access_type,
126
133
  default_value: default_attrs[column.name],
127
134
  validators: fetch_validators(model, column.name),
128
135
  reference: nil,
@@ -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.delete('"')
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
@@ -5,6 +5,8 @@ module Motor
5
5
  module FetchConfiguredModel
6
6
  CACHE_HASH = HashWithIndifferentAccess.new
7
7
 
8
+ HAS_AND_BELONGS_TO_MANY_JOIN_MODEL_PREFIX = 'HABTM_'
9
+
8
10
  module_function
9
11
 
10
12
  def call(model, cache_key:)
@@ -130,13 +132,8 @@ module Motor
130
132
  end
131
133
 
132
134
  def configure_reflection_classes(klass, cache_key)
133
- klass.reflections.each do |key, ref|
134
- begin
135
- next unless ref.klass
136
- next if ref.klass.anonymous?
137
- rescue StandardError
138
- next
139
- end
135
+ klass._reflections.each do |key, ref|
136
+ next unless configure_reflection_class?(ref)
140
137
 
141
138
  ref_dup = ref.dup
142
139
 
@@ -146,11 +143,9 @@ module Motor
146
143
  ref_dup.instance_variable_set(:@klass, call(ref.klass, cache_key: cache_key))
147
144
  end
148
145
 
149
- klass.reflections[key] = ref_dup
146
+ klass._reflections[key] = ref_dup
150
147
  end
151
148
 
152
- klass._reflections = klass.reflections
153
-
154
149
  klass
155
150
  end
156
151
 
@@ -203,6 +198,19 @@ module Motor
203
198
  end
204
199
  end
205
200
 
201
+ def configure_reflection_class?(ref)
202
+ begin
203
+ return false unless ref.klass
204
+ rescue StandardError
205
+ return false
206
+ end
207
+
208
+ return false if ref.klass.anonymous?
209
+ return false if ref.klass.name.demodulize.starts_with?(HAS_AND_BELONGS_TO_MANY_JOIN_MODEL_PREFIX)
210
+
211
+ true
212
+ end
213
+
206
214
  def sti_model?(model)
207
215
  !model.superclass.abstract_class && model.columns_hash[model.inheritance_column.to_s]
208
216
  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.23'
4
+ VERSION = '0.2.27'
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-6570149f716eae327cdc.css.gz": "main-6570149f716eae327cdc.css.gz",
2605
- "main-6570149f716eae327cdc.js.LICENSE.txt": "main-6570149f716eae327cdc.js.LICENSE.txt",
2606
- "main-6570149f716eae327cdc.js.gz": "main-6570149f716eae327cdc.js.gz",
2607
- "main.css": "main-6570149f716eae327cdc.css",
2608
- "main.js": "main-6570149f716eae327cdc.js"
2604
+ "main-9f6b19ff999e209e9d33.css.gz": "main-9f6b19ff999e209e9d33.css.gz",
2605
+ "main-9f6b19ff999e209e9d33.js.LICENSE.txt": "main-9f6b19ff999e209e9d33.js.LICENSE.txt",
2606
+ "main-9f6b19ff999e209e9d33.js.gz": "main-9f6b19ff999e209e9d33.js.gz",
2607
+ "main.css": "main-9f6b19ff999e209e9d33.css",
2608
+ "main.js": "main-9f6b19ff999e209e9d33.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.23
4
+ version: 0.2.27
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-11 00:00:00.000000000 Z
11
+ date: 2021-11-20 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-6570149f716eae327cdc.css.gz
1529
- - ui/dist/main-6570149f716eae327cdc.js.gz
1528
+ - ui/dist/main-9f6b19ff999e209e9d33.css.gz
1529
+ - ui/dist/main-9f6b19ff999e209e9d33.js.gz
1530
1530
  - ui/dist/manifest.json
1531
1531
  homepage:
1532
1532
  licenses: