rest_framework 2.0.0.beta3 → 2.0.0.beta4

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: 7cedfa02dac90388b712f4e15e29d07a40e45df23847bebf5da02eea03862e75
4
- data.tar.gz: 2de9c962810e9473dd5eb68c2ee42da764ed793e341049a49d9f4ca8d34fa48e
3
+ metadata.gz: 4b09674d62848416f77b39e23bc7b586e105786c7605320ad61761fe76ebc033
4
+ data.tar.gz: d8242a8db125185c3b1d778f4b4f2697a174d0bf17f796329cc4a0dfa11be99e
5
5
  SHA512:
6
- metadata.gz: f52b1b1075fef181d9e771df56f1c088c73601d600606411974febb1bb544facacc7d16d83c2b34929acc0d0f44a0e518098a3a121fcdf27f7e5f12be3a5d8ca
7
- data.tar.gz: c08ffc3af87bb7d7337dd1a908c7c6199fa3e70328b06dbebd1a691a0c3f235224b0119026eda4274f555385254383d2a7a29719b339f5c487f0ee82a7b2bcd2
6
+ metadata.gz: 8399d7751f5116a6196853e64c704f153c33e0a79923fa6fa0c12a3867f0669f3f7651f6ea4528b5bd976a76ea7e2e2604a87fcb1c39116d0148c79e34d36d30
7
+ data.tar.gz: f32a2db5595e8aee9dc069aa4fcaf6f96fffc35cb69b4ebc2d76589951a5dc1fdcdeae46631ad5af1506dbb365d07749461e12702ca8b36d7f1afa12e3922e83
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.0.beta3
1
+ 2.0.0.beta4
@@ -651,6 +651,15 @@ module RESTFramework::Controller
651
651
  self.get_fields.reject { |f| cfg[f]&.[](:write_only) }
652
652
  end
653
653
 
654
+ # The fields a client may write (create/update): `get_fields` minus read_only fields. Excluding
655
+ # them here — before strong parameters expand associations into `_id`/`_ids`/`_attributes` keys —
656
+ # keeps a read_only association from ever producing a permitted (and otherwise unstrippable, since
657
+ # those keys don't match a field name) assignment key.
658
+ def writable_fields
659
+ cfg = self.class.field_configuration
660
+ self.get_fields.reject { |f| cfg[f]&.[](:read_only) }
661
+ end
662
+
654
663
  # `readable_fields` restricted to real columns, for query surfaces that build SQL directly
655
664
  # (find_by, search) and would raise on a virtual/method field.
656
665
  def readable_columns
@@ -673,12 +682,14 @@ module RESTFramework::Controller
673
682
  @_get_allowed_parameters = self.class.allowed_parameters
674
683
  return @_get_allowed_parameters if @_get_allowed_parameters
675
684
 
676
- # Assemble strong parameters. Read-only fields are permitted here and stripped later per-action
677
- # by `_rrf_strip_read_only_fields` (which keeps the primary key on bulk update to find records).
685
+ # Assemble strong parameters from writable fields only, so read-only fields never produce a
686
+ # permitted key including the `_id`/`_ids`/`_attributes` variations an association expands
687
+ # into, which a later key-name-based filter couldn't catch. Bulk update re-permits the primary
688
+ # key (see `get_body_params`) since it needs it to locate each record.
678
689
  variations = []
679
690
  hash_variations = {}
680
691
  reflections = self.class.model.reflections
681
- @_get_allowed_parameters = self.get_fields.map { |f|
692
+ @_get_allowed_parameters = self.writable_fields.map { |f|
682
693
  f = f.to_s
683
694
  config = self.class.field_configuration[f]
684
695
 
@@ -823,37 +834,12 @@ module RESTFramework::Controller
823
834
  body_params[k].unshift(*v)
824
835
  end
825
836
 
826
- # Filter read-only fields. For bulk actions the permitted structure is `{ _json: [...] }`, so we
827
- # strip read-only keys from each element rather than the top-level hash (whose only key is
828
- # `_json`). Bulk update keeps the primary key, which it needs to locate each record.
829
- if bulk_action
830
- keep = bulk_action == :update ? [ pk.to_s ] : []
831
- body_params[:_json]&.each do |element|
832
- next unless element.is_a?(ActionController::Parameters)
833
-
834
- self._rrf_strip_read_only_fields(element, keep: keep)
835
- end
836
- else
837
- self._rrf_strip_read_only_fields(body_params)
838
- end
839
-
840
837
  body_params
841
838
  end
842
839
  alias_method :get_create_params, :get_body_params
843
840
  alias_method :get_update_params, :get_body_params
844
841
  alias_method :get_destroy_params, :get_body_params
845
842
 
846
- # Remove read-only fields from a permitted params hash in place. `keep` lists field names to
847
- # preserve even when read-only (e.g. the primary key on bulk update, used to locate records).
848
- def _rrf_strip_read_only_fields(params, keep: [])
849
- params.delete_if do |f, _|
850
- next false if f.in?(keep)
851
-
852
- cfg = self.class.field_configuration[f]
853
- cfg && cfg[:read_only]
854
- end
855
- end
856
-
857
843
  # Get the set of records this controller has access to.
858
844
  def get_recordset
859
845
  return self.class.recordset if self.class.recordset
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: 2.0.0.beta3
4
+ version: 2.0.0.beta4
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: 2026-08-01 00:00:00.000000000 Z
11
+ date: 2026-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails