rest_framework 0.8.4 → 0.8.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 333e3109a118ca9b6069e4856d77ec85baf217b8f0e835f6f1426c93674822bd
4
- data.tar.gz: e187f2d6f01b5eb69d358fb0f5da134120c4a04c76eb06e8c181deb16a6d317a
3
+ metadata.gz: a4fe6c7cddb11163195ca847ef985d87274b20b33a16bba96ed1979dd9ef3f91
4
+ data.tar.gz: e9db88d728e115a1e20d9584087fb21f48cff195476019efefa7f19c142eeb9e
5
5
  SHA512:
6
- metadata.gz: 875514cb611fe74eaddeda88c2e48dcb7e28246274b8e191c7e13410998ce462c0a6dff1cbdc0cc9140a3e6e56026aecbcfbc4c002d230e36f7c315bebd5c84a
7
- data.tar.gz: b82c26a854b08314c4e56d2a29532570289fad186d2f0019421f6214f1ad35fa60e4730a5b2d8c06b0bd776f28c291cb1d33740131f2f030912c527eca3dcc87
6
+ metadata.gz: 3c6a447cedc65be69c0ab0ae9430ecd219e6780b1373ba3cecfecc57d7335cf9af388a996e8d57f9b16cce60fc941f02d940b88f29e78841fb9eb78f4746b1d2
7
+ data.tar.gz: 2c187d7b063b084970b3d8e8d13699e0c6e321cf4d4c38d23357923b9a0c10ea5fa9bd54763959913d772745d6aa5abfbaa7f8ad6fd79162c1724a5d696cfa19
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.4
1
+ 0.8.6
@@ -11,7 +11,9 @@
11
11
  <nav class="navbar navbar-dark bg-dark">
12
12
  <div class="container">
13
13
  <span class="navbar-brand p-0">
14
- <h1 class="text-light font-weight-light m-0 p-0" style="font-size: 1em"><%= @template_logo_text || 'Rails REST Framework' %></h1>
14
+ <h1 title="RRF v<%= RESTFramework::VERSION %>" class="text-light font-weight-light m-0 p-0" style="font-size: 1em">
15
+ <%= @template_logo_text || 'Rails REST Framework' %>
16
+ </h1>
15
17
  </span>
16
18
  </div>
17
19
  </nav>
@@ -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.6
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