rest_framework 0.8.4 → 0.8.5

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: 333e3109a118ca9b6069e4856d77ec85baf217b8f0e835f6f1426c93674822bd
4
- data.tar.gz: e187f2d6f01b5eb69d358fb0f5da134120c4a04c76eb06e8c181deb16a6d317a
3
+ metadata.gz: 8bbc760b6f4694137002e90cf81453f1e07cd86ffd69a8318646db54b31144b6
4
+ data.tar.gz: 41ce57cbee20b11453d332e03fbdf54118ba7b7f1ceeaa5b3b02d118675c6a3d
5
5
  SHA512:
6
- metadata.gz: 875514cb611fe74eaddeda88c2e48dcb7e28246274b8e191c7e13410998ce462c0a6dff1cbdc0cc9140a3e6e56026aecbcfbc4c002d230e36f7c315bebd5c84a
7
- data.tar.gz: b82c26a854b08314c4e56d2a29532570289fad186d2f0019421f6214f1ad35fa60e4730a5b2d8c06b0bd776f28c291cb1d33740131f2f030912c527eca3dcc87
6
+ metadata.gz: 59fdf66ab6dd1c457a9551ed1a9ab0724fc2079be1c28ec2ebc08eada94390fe66e3722ab278a6d5fba7c55aed9a4a75dca0e3ea498cd183832d70553f6db9d7
7
+ data.tar.gz: e3e2f6b3c3ff29e03d8c9c3a058996bea5de44acfae449a065278a000b98b22b536892dd2d4e3e46b65d9c94cee85aedd1f9928e697e39afd4c491b33ae33504
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.4
1
+ 0.8.5
@@ -112,7 +112,7 @@ module RESTFramework::BaseControllerMixin
112
112
 
113
113
  # Get a hash of metadata to be rendered in the `OPTIONS` response. Cache the result.
114
114
  def get_options_metadata
115
- return @_base_options_metadata ||= {
115
+ return {
116
116
  title: self.get_title,
117
117
  description: self.description,
118
118
  renders: [
@@ -285,9 +285,9 @@ module RESTFramework::BaseModelControllerMixin
285
285
  }.to_h
286
286
  end
287
287
 
288
- # Get a hash of metadata to be rendered in the `OPTIONS` response. Cache the result.
288
+ # Get a hash of metadata to be rendered in the `OPTIONS` response.
289
289
  def get_options_metadata
290
- return super().merge(
290
+ return super.merge(
291
291
  {
292
292
  fields: self.get_fields_metadata,
293
293
  callbacks: self._process_action_callbacks.as_json,
@@ -14,7 +14,7 @@ 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 @_get_fields ||= (
17
+ return (
18
18
  @controller.class.filterset_fields || @controller.get_fields(fallback: true)
19
19
  ).map(&:to_s)
20
20
  end
@@ -69,9 +69,7 @@ class RESTFramework::ModelOrderingFilter < RESTFramework::BaseFilter
69
69
  # Get a list of ordering fields for the current action. Do not fallback to columns in case the
70
70
  # user wants to order by a virtual column.
71
71
  def _get_fields
72
- return @_get_fields ||= (
73
- @controller.class.ordering_fields || @controller.get_fields
74
- )&.map(&:to_s)
72
+ return (@controller.class.ordering_fields || @controller.get_fields)&.map(&:to_s)
75
73
  end
76
74
 
77
75
  # Convert ordering string to an ordering configuration.
@@ -138,10 +136,18 @@ class RESTFramework::ModelSearchFilter < RESTFramework::BaseFilter
138
136
 
139
137
  if search.present?
140
138
  if fields = self._get_fields.presence
139
+ # MySQL doesn't support casting to VARCHAR, so we need to use CHAR instead.
140
+ data_type = if data.connection.adapter_name =~ /mysql/i
141
+ "CHAR"
142
+ else
143
+ # Sufficient for both PostgreSQL and SQLite.
144
+ "VARCHAR"
145
+ end
146
+
141
147
  # Ensure we pass user input as arguments to prevent SQL injection.
142
148
  return data.where(
143
149
  fields.map { |f|
144
- "CAST(#{f} AS VARCHAR) #{@controller.class.search_ilike ? "ILIKE" : "LIKE"} ?"
150
+ "CAST(#{f} AS #{data_type}) #{@controller.class.search_ilike ? "ILIKE" : "LIKE"} ?"
145
151
  }.join(" OR "),
146
152
  *(["%#{search}%"] * fields.length),
147
153
  )
@@ -49,16 +49,16 @@ module RESTFramework
49
49
  # Whether the backtrace should be shown in rescued errors.
50
50
  attr_accessor :show_backtrace
51
51
 
52
- # Option to disable `rescue_from` on the controller mixins.
52
+ # Disable `rescue_from` on the controller mixins.
53
53
  attr_accessor :disable_rescue_from
54
54
 
55
- # Option to exclude certain classes from being added by default as association fields.
55
+ # Exclude certain classes from being added by default as association fields.
56
56
  attr_accessor :exclude_association_classes
57
57
 
58
- # Option for the default label fields to use when generating labels for `has_many` associations.
58
+ # The default label fields to use when generating labels for `has_many` associations.
59
59
  attr_accessor :label_fields
60
60
 
61
- # Option for the default search columns to use when generating search filters.
61
+ # The default search columns to use when generating search filters.
62
62
  attr_accessor :search_columns
63
63
 
64
64
  def initialize
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
4
+ version: 0.8.5
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-01-30 00:00:00.000000000 Z
11
+ date: 2023-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails