@embed: @never is ignored inside an @reverse frame

Đang mở Phù hợp với người mới
#378 0 bình luận 1 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

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

Đánh giá

Độ khó
1/5
Thời gian dự kiến
Dưới một giờ
Mức phù hợp với người mới
90/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
data

Hướng nghiên cứu

Bắt đầu tại lib/pyld/jsonld.py#L4663 trong nhánh reverse-framing, nơi khóa trạng thái được viết là embeded; so sánh nó với kiểm tra @never quanh L4484-L4485 và các điểm gọi forward tại L4597 và L4611. Chạy reproducer của issue để xác nhận nút employee được nhúng, sau đó áp dụng bản sửa một ký tự. Hoàn tất nghĩa là reverse frame trả về "employees": {"@id": "ex:p1"} trong khi các kiểm thử frame hiện có vẫn không đổi.

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

Mô tả

Framing a reverse property with {"@embed": "@never"} embeds the matched node in full. The same flag on a forward property is honoured.

from pyld import jsonld

ctx = {"schema": "http://schema.org/", "name": "schema:name",
       "works_for": {"@id": "schema:worksFor", "@type": "@id"},
       "employees": {"@reverse": "schema:worksFor"}}
doc = {"@context": ctx, "@graph": [
    {"@id": "ex:org1", "@type": "schema:Organization", "name": "Acme"},
    {"@id": "ex:p1", "@type": "schema:Person", "name": "Ada", "works_for": "ex:org1"}]}
back = jsonld.from_rdf(jsonld.to_rdf(doc, {"format": "application/n-quads"}),
                       {"format": "application/n-quads"})

print(jsonld.frame(back, {"@context": ctx, "@embed": "@once", "@type": "schema:Organization",
                          "@reverse": {"schema:worksFor": {"@embed": "@never"}}}))

3.3.0 returns the employee embedded:

"employees": {"@id": "ex:p1", "@type": "schema:Person", "name": "Ada", "works_for": "ex:org1"}

The reverse branch recurses with a misspelled state key, jsonld.py#L4663:

{**state, 'embeded': True},

while the @never test reads state['embedded'] (L4484-L4485). The key written is never read, so a reverse-framed node is treated as if it were at the top level, where @never does not apply. The two forward call sites, L4597 and L4611, spell it 'embedded'.

Changing that one character in an installed 3.3.0 gives "employees": {"@id": "ex:p1"}, with the other frames unchanged.

jsonld.js is correct at frame.js#L309, so this is specific to the Python port.

Ngôn ngữ chính
Python
Star
689
Fork
140
Merge trung bình
2 ngày 16 giờ
Pull request đã merge (30 ngày)
11

Chuẩn bị môi trường

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 digitalbazaar/pyld

Tất cả issue của digitalbazaar/pyld

Issue tương tự

Thêm issue về Python

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.