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 +4 -4
- data/VERSION +1 -1
- data/lib/rest_framework/controller_mixins/base.rb +1 -1
- data/lib/rest_framework/controller_mixins/models.rb +2 -2
- data/lib/rest_framework/filters.rb +11 -5
- data/lib/rest_framework.rb +4 -4
- 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: 8bbc760b6f4694137002e90cf81453f1e07cd86ffd69a8318646db54b31144b6
|
4
|
+
data.tar.gz: 41ce57cbee20b11453d332e03fbdf54118ba7b7f1ceeaa5b3b02d118675c6a3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59fdf66ab6dd1c457a9551ed1a9ab0724fc2079be1c28ec2ebc08eada94390fe66e3722ab278a6d5fba7c55aed9a4a75dca0e3ea498cd183832d70553f6db9d7
|
7
|
+
data.tar.gz: e3e2f6b3c3ff29e03d8c9c3a058996bea5de44acfae449a065278a000b98b22b536892dd2d4e3e46b65d9c94cee85aedd1f9928e697e39afd4c491b33ae33504
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.8.
|
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
|
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.
|
288
|
+
# Get a hash of metadata to be rendered in the `OPTIONS` response.
|
289
289
|
def get_options_metadata
|
290
|
-
return super
|
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
|
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 @
|
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
|
150
|
+
"CAST(#{f} AS #{data_type}) #{@controller.class.search_ilike ? "ILIKE" : "LIKE"} ?"
|
145
151
|
}.join(" OR "),
|
146
152
|
*(["%#{search}%"] * fields.length),
|
147
153
|
)
|
data/lib/rest_framework.rb
CHANGED
@@ -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
|
-
#
|
52
|
+
# Disable `rescue_from` on the controller mixins.
|
53
53
|
attr_accessor :disable_rescue_from
|
54
54
|
|
55
|
-
#
|
55
|
+
# Exclude certain classes from being added by default as association fields.
|
56
56
|
attr_accessor :exclude_association_classes
|
57
57
|
|
58
|
-
#
|
58
|
+
# The default label fields to use when generating labels for `has_many` associations.
|
59
59
|
attr_accessor :label_fields
|
60
60
|
|
61
|
-
#
|
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
|
+
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-
|
11
|
+
date: 2023-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|