Fields filtering with include

オープン
#1,475 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
rails, ruby
領域
api, backend

調査の方向性

lib/jsonapi/resource_serializer.rb の JSONAPI::ResourceSerializer#supplying_relationship_fields から始め、issue で説明されている fields[events]=name と include=establishment のケースを再現します。response hash が relationships キーを保持しながらフィールドフィルタリングも適用し続けることを確認してください。集合の共通部分を変更する前に、意図された動作を確認する必要があります。

索引モデルが issue の本文から書いたものです。

説明

Version 0.9.12

When using fields[events]=name + include=establishment the key relationships disappear from the response hash.

Basic association is events belongs_to establishment

Issue is coming from here:


# JSONAPI::ResourceSerializer#supplying_relationship_fields

def supplying_relationship_fields(resource_klass)
        @_supplying_relationship_fields.fetch resource_klass do
          relationships = Set.new(resource_klass._relationships.keys.map(&:to_sym))
          cur = resource_klass
          while cur != JSONAPI::Resource
            if @fields.has_key?(cur._type)
              # here... 
              # It always empty the Set
              #relationships &= @fields[cur._type]
              break
            end
            cur = cur.superclass
          end
          @_supplying_relationship_fields[resource_klass] = relationships
        end
      end

Commenting relationships &= @fields[cur._type] solves this issue. @DavidMikeSimon could you describe your mind here? I know it was a loooong time ago but your help might help to correctly fix this issue.

主要言語
Ruby
スター
2.3k
フォーク
546
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

JSONAPI-Resources/jsonapi-resources のほかの issue

JSONAPI-Resources/jsonapi-resources の issue をすべて見る

似ている issue

Ruby の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。