Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Fields filtering with include

Đang mở
#1,475 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
rails, ruby
Lĩnh vực
api, backend

Hướng nghiên cứu

Bắt đầu trong lib/jsonapi/resource_serializer.rb tại JSONAPI::ResourceSerializer#supplying_relationship_fields và tái hiện trường hợp fields[events]=name cộng với include=establishment được mô tả trong issue. Xác minh rằng response hash vẫn giữ khóa relationships trong khi tiếp tục áp dụng việc lọc field; cần xác nhận hành vi dự kiến trước khi thay đổi phép giao của các tập hợp.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Ruby
Star
2.3k
Fork
546
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của JSONAPI-Resources/jsonapi-resources

Tất cả issue của JSONAPI-Resources/jsonapi-resources

Issue tương tự

Thêm issue về Ruby

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.