filtering flattened projection does not seem to follow projection rules

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

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

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
javascript
Lĩnh vực
tooling

Hướng nghiên cứu

Issue không nêu tên tệp hoặc test nào trong repository; hãy bắt đầu bằng cách tái hiện hai truy vấn filter-and-flatten và so sánh chúng với tài liệu projection của JMESPath được liên kết. Theo dõi cách các biểu thức filter và flatten được đánh giá, sau đó xác định xem hành vi có phù hợp với các quy tắc của ngôn ngữ hay không và ghi lại các truy vấn được minh họa trong một regression case hoặc tài liệu được làm rõ.

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

Mô tả

Scenario

If we have an object like so:

{
    "persons": [
        {
            "name": "bob",
            "addresses": [
                {
                    "current": true,
                    "address": "132 Main Ave"
                },
                {
                    "current": false,
                    "address": "99 1st St"
                }
            ]
        },
        {
            "name": "linda",
            "addresses": [
                {
                    "current": true,
                    "address": "132 Main Ave"
                },
                {
                    "current": false,
                    "address": "99 1st St"
                }
            ]
        }
    ]
}

and the query:

persons[?name=='bob'].addresses[]

I get the result

[
  {
    "current": true,
    "address": "132 Main Ave"
  },
  {
    "current": false,
    "address": "99 1st St"
  }
]

This seems to line up just fine with the documentation of what a "projection" is in JMES.
It is my understanding that Filter and Flatten are both types of projections. So if I then filter the flattened projection like so

persons[?name=='bob'].addresses[][?current]

I would expect this

[
  {
    "current": true,
    "address": "132 Main Ave"
  }
]

but instead I have to pipe the result to a filter projection in order to get this to work:

persons[?name=='bob'].addresses[] | [?current]

Question / Issue

I would not expect that I have to first use the pipe operator in order to achieve that.
Why is it that the filter is not applied as a projection of each result of the flatten operation? Am I misunderstanding something about what is/is not a projection and how the projection algorithm is supposed to work?

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

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

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

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 jmespath/jmespath.js

Tất cả issue của jmespath/jmespath.js

Issue tương tự

Thêm issue về JavaScript

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.