rest_framework 0.8.11 → 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: 076db67d932800e57d2c166d757b60ea6e0d77df03da2385eddff8fd25886f76
4
- data.tar.gz: d8b0fd131b50978e65b767d95a076f9592c8948a2708adff97e7971f84b0fbca
3
+ metadata.gz: 39af19a8d4f904490f8080fad81cb42705b3ba324e41727b271b8287fe79fcf8
4
+ data.tar.gz: 59c16881e824d3ea3c9290c8fc180236b53fe78b899c20642c930d39f27214f5
5
5
  SHA512:
6
- metadata.gz: f23d1835c49628c2b2f02521df2373438aabdb8ccb4fb12c3bd008cc757e3b660521c1eecf6d54fc92ad4f9b7c04881122acc9931c4d8847253cc78408e1e70d
7
- data.tar.gz: 23dbfba94daee299e86a1e542d17b8b25bccd04989e569fee71731fac79c3996ac987a8ee28a58d4f489ddf1cf3a02d4774f45b022cbfaaeb9d796ddc6e71cb3
6
+ metadata.gz: 2829f419f59f8b0f9e04509403962890e36abba2cf75807f0e0fe04670904fd0741c4895d31e77377bd3a115a77cf12c85f827aa301c4a42ce88b8daee7259c5
7
+ data.tar.gz: d8ae7cf13d751e437b6e9de839ba64b8c874f3399d3dfa331fe00168945c97c7ea106371e17bae69d4834425cc8ea59b64a7cef407e4c6396cc4530e989947b8
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.11
1
+ 0.8.12
@@ -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
- @controller.class.filterset_fields || @controller.get_fields(fallback: true)
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 (@controller.class.ordering_fields || @controller.get_fields)&.map(&:to_s)
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.columns_hash.keys
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
  }
@@ -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 parsed_fields
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.11
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-02-28 00:00:00.000000000 Z
11
+ date: 2023-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails