active_scaffold 3.6.15 → 3.6.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.rdoc +11 -0
- data/lib/active_scaffold/actions/list.rb +2 -1
- data/lib/active_scaffold/bridges/paper_trail/actions.rb +1 -1
- data/lib/active_scaffold/tableless.rb +29 -16
- data/lib/active_scaffold/version.rb +1 -1
- data/test/misc/tableless_test.rb +3 -2
- data/test/mock_app/app/models/file_model.rb +12 -0
- 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: 9dfa34216419b18c65d503771afc1f0083561f5419963c858df2948b0c3e9ed2
|
4
|
+
data.tar.gz: c4f0d58b4dc6afee868718214fd725c2004898b903d90fd5b94b09133cea6294
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfc6d60cb5e2df8fbc367ca6854c173ad94b04bd4309e430ff9c61351ebfe17c3162e50f8c9e6409ad722b8e8298cca8f9da28f9ba0dcc2f3b51e64b114a4844
|
7
|
+
data.tar.gz: ae5b110172f4479df2c3456061a17e289ab222b3143135893c4866d4f3f04f74d1c873e07e71262c992c946450bdabe7f7b9457dd1b15bdbfa5ac2db1e9fa92f
|
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
= 3.6.17
|
2
|
+
- Don't add includes or left joins for constrained columns, as they are ignored on sorting clause
|
3
|
+
- Fix deprecation on cache counts with rails 5, and fix the queries for rails >= 5.1
|
4
|
+
- Fix new for tableless models on rails 5.0
|
5
|
+
|
6
|
+
= 3.6.16
|
7
|
+
- Fix query on paper_trail action
|
8
|
+
- Fix one? on tableless relation
|
9
|
+
- Fix exists? on tableless relation
|
10
|
+
- Fix getting conditions from association in the tableless relation
|
11
|
+
|
1
12
|
= 3.6.15
|
2
13
|
- Prevent firing 2 change events on jquery datetime pickers
|
3
14
|
- Fix setting data options on columns for date and datetime pickers
|
@@ -83,6 +83,7 @@ module ActiveScaffold::Actions
|
|
83
83
|
|
84
84
|
def set_includes_for_sorting(columns, sorting)
|
85
85
|
sorting.each_column do |col|
|
86
|
+
next if sorting.constraint_columns.include? col.name
|
86
87
|
next unless col.includes.present? && !columns.include?(col)
|
87
88
|
if active_scaffold_config.model.connection.needs_order_expressions_in_select?
|
88
89
|
active_scaffold_references << col.includes
|
@@ -176,7 +177,7 @@ module ActiveScaffold::Actions
|
|
176
177
|
query = active_scaffold_config.model.where(active_scaffold_config.primary_key => records.map(&:id))
|
177
178
|
.joins(column.name).group(active_scaffold_config.primary_key)
|
178
179
|
.select("#{klass.quoted_table_name}.#{klass.quoted_primary_key}")
|
179
|
-
query = query.
|
180
|
+
query = query.distinct if column.association.scope && klass.instance_exec(&column.association.scope).values[:distinct]
|
180
181
|
query
|
181
182
|
end
|
182
183
|
|
@@ -10,7 +10,7 @@ module ActiveScaffold::Actions
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def deleted
|
13
|
-
query = PaperTrail::Version.destroys.where(:item_type => active_scaffold_config.model)
|
13
|
+
query = PaperTrail::Version.destroys.where(:item_type => active_scaffold_config.model.name)
|
14
14
|
if nested? && nested.child_association&.belongs_to? && PaperTrail::Version.respond_to?(:where_object)
|
15
15
|
query = query.where_object(nested.child_association.foreign_key => nested.parent_id)
|
16
16
|
end
|
@@ -76,6 +76,10 @@ class ActiveScaffold::Tableless < ActiveRecord::Base # rubocop:disable Rails/App
|
|
76
76
|
super.tap do |scope|
|
77
77
|
if klass < ActiveScaffold::Tableless
|
78
78
|
class << scope; include RelationExtension; end
|
79
|
+
assoc_conditions = scope.proxy_association&.send(:association_scope)&.conditions
|
80
|
+
if assoc_conditions&.present?
|
81
|
+
scope.conditions.concat assoc_conditions.map { |c| c.is_a?(Hash) ? c[klass.table_name] || c : c }
|
82
|
+
end
|
79
83
|
end
|
80
84
|
end
|
81
85
|
end
|
@@ -112,8 +116,6 @@ class ActiveScaffold::Tableless < ActiveRecord::Base # rubocop:disable Rails/App
|
|
112
116
|
end
|
113
117
|
|
114
118
|
module RelationExtension
|
115
|
-
attr_reader :conditions
|
116
|
-
|
117
119
|
def initialize(klass, *)
|
118
120
|
super
|
119
121
|
@conditions ||= []
|
@@ -124,6 +126,10 @@ class ActiveScaffold::Tableless < ActiveRecord::Base # rubocop:disable Rails/App
|
|
124
126
|
super
|
125
127
|
end
|
126
128
|
|
129
|
+
def conditions
|
130
|
+
@conditions ||= []
|
131
|
+
end
|
132
|
+
|
127
133
|
def where(opts, *rest)
|
128
134
|
if opts.present?
|
129
135
|
opts = opts.with_indifferent_access if opts.is_a? Hash
|
@@ -131,6 +137,7 @@ class ActiveScaffold::Tableless < ActiveRecord::Base # rubocop:disable Rails/App
|
|
131
137
|
end
|
132
138
|
self
|
133
139
|
end
|
140
|
+
alias where! where
|
134
141
|
|
135
142
|
def merge(rel)
|
136
143
|
super.tap do |merged|
|
@@ -140,14 +147,13 @@ class ActiveScaffold::Tableless < ActiveRecord::Base # rubocop:disable Rails/App
|
|
140
147
|
|
141
148
|
def except(*skips)
|
142
149
|
super.tap do |new_relation|
|
143
|
-
|
150
|
+
unless new_relation.is_a?(RelationExtension)
|
151
|
+
class << new_relation; include RelationExtension; end
|
152
|
+
end
|
153
|
+
new_relation.conditions.concat conditions unless skips.include? :where
|
144
154
|
end
|
145
155
|
end
|
146
156
|
|
147
|
-
def to_a
|
148
|
-
@klass.find_all(self)
|
149
|
-
end
|
150
|
-
|
151
157
|
def find_one(id)
|
152
158
|
@klass.find_one(id, self) || raise(ActiveRecord::RecordNotFound)
|
153
159
|
end
|
@@ -161,7 +167,14 @@ class ActiveScaffold::Tableless < ActiveRecord::Base # rubocop:disable Rails/App
|
|
161
167
|
end
|
162
168
|
|
163
169
|
def exists?
|
164
|
-
|
170
|
+
size > 0
|
171
|
+
end
|
172
|
+
|
173
|
+
private
|
174
|
+
def exec_queries
|
175
|
+
@records = @klass.find_all(self)
|
176
|
+
@loaded = true
|
177
|
+
@records
|
165
178
|
end
|
166
179
|
end
|
167
180
|
|
@@ -203,15 +216,15 @@ class ActiveScaffold::Tableless < ActiveRecord::Base # rubocop:disable Rails/App
|
|
203
216
|
end
|
204
217
|
end
|
205
218
|
end
|
206
|
-
|
207
|
-
def self.columns_hash
|
208
|
-
if self < ActiveScaffold::Tableless
|
209
|
-
@columns_hash ||= Hash[columns.map { |c| [c.name, c] }]
|
210
|
-
else
|
211
|
-
super
|
212
|
-
end
|
213
|
-
end
|
214
219
|
if Rails.version < '5.0' # 4.2.x
|
220
|
+
def self.columns_hash
|
221
|
+
if self < ActiveScaffold::Tableless
|
222
|
+
@columns_hash ||= Hash[columns.map { |c| [c.name, c] }]
|
223
|
+
else
|
224
|
+
super
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
215
228
|
def self.initialize_find_by_cache
|
216
229
|
self.find_by_statement_cache = Hash.new { |h, k| h[k] = StatementCache.new(k) } # rubocop:disable Rails/DynamicFindBy
|
217
230
|
end
|
data/test/misc/tableless_test.rb
CHANGED
@@ -27,8 +27,9 @@ class TablelessTest < MiniTest::Test
|
|
27
27
|
assert Person.new.files.empty?
|
28
28
|
@person = Person.new
|
29
29
|
@person.save(validate: false)
|
30
|
-
assert
|
31
|
-
|
30
|
+
assert !@person.files.empty?
|
31
|
+
assert @person.files.all.exists?
|
32
|
+
assert_equal @person.id, @person.files.first.person_id
|
32
33
|
end
|
33
34
|
|
34
35
|
def test_tableless_assoc_with_dependent
|
@@ -6,6 +6,18 @@ class FileModel < ActiveScaffold::Tableless
|
|
6
6
|
belongs_to :person
|
7
7
|
|
8
8
|
def self.find_all(relation)
|
9
|
+
relation.conditions&.each&.with_index do |condition, i|
|
10
|
+
person_id =
|
11
|
+
case condition
|
12
|
+
when Hash
|
13
|
+
condition[:person_id]
|
14
|
+
when Arel::Nodes::Equality
|
15
|
+
if condition.left.name.to_sym == :person_id
|
16
|
+
relation.bind_values[i].present? ? relation.bind_values[i][1] : condition.right.first
|
17
|
+
end
|
18
|
+
end
|
19
|
+
return [new(person_id: person_id)] if person_id
|
20
|
+
end
|
9
21
|
[]
|
10
22
|
end
|
11
23
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_scaffold
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.6.
|
4
|
+
version: 3.6.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Many, see README
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|