rest_framework 0.8.10 → 0.8.12
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39af19a8d4f904490f8080fad81cb42705b3ba324e41727b271b8287fe79fcf8
|
4
|
+
data.tar.gz: 59c16881e824d3ea3c9290c8fc180236b53fe78b899c20642c930d39f27214f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2829f419f59f8b0f9e04509403962890e36abba2cf75807f0e0fe04670904fd0741c4895d31e77377bd3a115a77cf12c85f827aa301c4a42ce88b8daee7259c5
|
7
|
+
data.tar.gz: d8ae7cf13d751e437b6e9de839ba64b8c874f3399d3dfa331fe00168945c97c7ea106371e17bae69d4834425cc8ea59b64a7cef407e4c6396cc4530e989947b8
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.8.
|
1
|
+
0.8.12
|
@@ -156,8 +156,8 @@ module RESTFramework::BaseControllerMixin
|
|
156
156
|
|
157
157
|
# Alias `extra_actions` to `extra_collection_actions`.
|
158
158
|
unless base.respond_to?(:extra_collection_actions)
|
159
|
-
base.alias_method(:extra_collection_actions, :extra_actions)
|
160
|
-
base.alias_method(:extra_collection_actions=, :extra_actions=)
|
159
|
+
base.singleton_class.alias_method(:extra_collection_actions, :extra_actions)
|
160
|
+
base.singleton_class.alias_method(:extra_collection_actions=, :extra_actions=)
|
161
161
|
end
|
162
162
|
|
163
163
|
# Skip CSRF since this is an API.
|
@@ -91,9 +91,10 @@ module RESTFramework::BaseModelControllerMixin
|
|
91
91
|
|
92
92
|
# Get the available fields. Returning `nil` indicates that anything should be accepted. If
|
93
93
|
# `fallback` is true, then we should fallback to this controller's model columns, or an empty
|
94
|
-
# array.
|
94
|
+
# array. This should always return an array of strings, no symbols, and possibly `nil` (only if
|
95
|
+
# `fallback` is false).
|
95
96
|
def get_fields(input_fields: nil, fallback: true)
|
96
|
-
input_fields ||= self.fields if fallback
|
97
|
+
input_fields ||= self.fields&.map(&:to_s) if fallback
|
97
98
|
|
98
99
|
# If fields is a hash, then parse it.
|
99
100
|
if input_fields.is_a?(Hash)
|
@@ -14,14 +14,12 @@ class RESTFramework::ModelFilter < RESTFramework::BaseFilter
|
|
14
14
|
# Get a list of filterset fields for the current action. Fallback to columns because we don't want
|
15
15
|
# to try filtering by any query parameter because that could clash with other query parameters.
|
16
16
|
def _get_fields
|
17
|
-
return
|
18
|
-
|
19
|
-
).map(&:to_s)
|
17
|
+
# Always return a list of strings; `@controller.get_fields` already does this.
|
18
|
+
return @controller.class.filterset_fields&.map(&:to_s) || @controller.get_fields(fallback: true)
|
20
19
|
end
|
21
20
|
|
22
21
|
# Filter params for keys allowed by the current action's filterset_fields/fields config.
|
23
22
|
def _get_filter_params
|
24
|
-
# Map filterset fields to strings because query parameter keys are strings.
|
25
23
|
fields = self._get_fields
|
26
24
|
|
27
25
|
return @controller.request.query_parameters.select { |p, _|
|
@@ -69,7 +67,7 @@ class RESTFramework::ModelOrderingFilter < RESTFramework::BaseFilter
|
|
69
67
|
# Get a list of ordering fields for the current action. Do not fallback to columns in case the
|
70
68
|
# user wants to order by a virtual column.
|
71
69
|
def _get_fields
|
72
|
-
return
|
70
|
+
return @controller.class.ordering_fields&.map(&:to_s) || @controller.get_fields
|
73
71
|
end
|
74
72
|
|
75
73
|
# Convert ordering string to an ordering configuration.
|
@@ -119,10 +117,10 @@ class RESTFramework::ModelSearchFilter < RESTFramework::BaseFilter
|
|
119
117
|
# common string-like columns by default.
|
120
118
|
def _get_fields
|
121
119
|
if search_fields = @controller.class.search_fields
|
122
|
-
return search_fields
|
120
|
+
return search_fields&.map(&:to_s)
|
123
121
|
end
|
124
122
|
|
125
|
-
columns = @controller.class.get_model.
|
123
|
+
columns = @controller.class.get_model.column_names
|
126
124
|
return @controller.get_fields(fallback: true).select { |f|
|
127
125
|
f.in?(RESTFramework.config.search_columns) && f.in?(columns)
|
128
126
|
}
|
data/lib/rest_framework/utils.rb
CHANGED
@@ -150,11 +150,13 @@ module RESTFramework::Utils
|
|
150
150
|
Rails.logger.warn("RRF: Unknown key in fields hash: #{k}")
|
151
151
|
end
|
152
152
|
|
153
|
-
return
|
153
|
+
# We should always return strings, not symbols.
|
154
|
+
return parsed_fields.map(&:to_s)
|
154
155
|
end
|
155
156
|
|
156
157
|
# Get the fields for a given model, including not just columns (which includes
|
157
|
-
# foreign keys), but also associations.
|
158
|
+
# foreign keys), but also associations. Note that we always return an array of
|
159
|
+
# strings, not symbols.
|
158
160
|
def self.fields_for(model, exclude_associations: nil)
|
159
161
|
foreign_keys = model.reflect_on_all_associations(:belongs_to).map(&:foreign_key)
|
160
162
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rest_framework
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gregory N. Schmit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|