Nested querying issue

Đang mở
#100 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
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
javascript, python
Lĩnh vực
tooling

Hướng nghiên cứu

Tái hiện các truy vấn bộ lọc lồng nhau từ issue trong triển khai JavaScript của JMESPath và so sánh kết quả của chúng với hành vi Python được báo cáo. Bắt đầu với trình đánh giá truy vấn và các bài kiểm thử lọc hiện có, nếu có; công việc được xem là hoàn tất khi đã xác định được kết quả mong đợi và liệu sự khác biệt là lỗi trong triển khai hay vấn đề về ngữ nghĩa truy vấn.

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

Mô tả

I tested on both Python version and Javascript version on JMSPath webpage, same results:

Testing query: users[?id == `1`].contacts[?type == `email`].value | [0]
JSON Data: {
  "users": [
    {
      "id": 1,
      "name": "Alice",
      "contacts": [
        {
          "type": "email",
          "value": "[email protected]"
        },
        {
          "type": "phone",
          "value": "+1234567890"
        }
      ]
    },
    {
      "id": 2,
      "name": "Bob",
      "contacts": [
        {
          "type": "email",
          "value": "[email protected]"
        }
      ]
    }
  ]
}
Debug: JMESPath version: 1.0.1
Debug: Python version: 3.10.16 | packaged by conda-forge | (main, Dec  5 2024, 14:16:10) [GCC 13.3.0]
Debug: Users with id == 1: [{'id': 1, 'name': 'Alice', 'contacts': [{'type': 'email', 'value': '[email protected]'}, {'type': 'phone', 'value': '+1234567890'}]}]
Debug: Raw contact objects: [[{'type': 'email', 'value': '[email protected]'}, {'type': 'phone', 'value': '+1234567890'}]]
Debug: Flattened contacts: [{'type': 'email', 'value': '[email protected]'}, {'type': 'phone', 'value': '+1234567890'}]
Debug: All contact types: ['email', 'phone']
Debug: Raw type values: ['email', 'phone']
Debug: Contacts with type == email: []
Debug: Minimal test: None
Test failed!
Query: users[?id == `1`].contacts[?type == `email`].value | [0]
Expected: [email protected]
Got: None

Testing query: users[?id == `1`].contacts[][?type == `email`].value | [0]
JSON Data: {
  "users": [
    {
      "id": 1,
      "name": "Alice",
      "contacts": [
        {
          "type": "email",
          "value": "[email protected]"
        },
        {
          "type": "phone",
          "value": "+1234567890"
        }
      ]
    },
    {
      "id": 2,
      "name": "Bob",
      "contacts": [
        {
          "type": "email",
          "value": "[email protected]"
        }
      ]
    }
  ]
}
Debug: JMESPath version: 1.0.1
Debug: Python version: 3.10.16 | packaged by conda-forge | (main, Dec  5 2024, 14:16:10) [GCC 13.3.0]
Debug: Users with id == 1: [{'id': 1, 'name': 'Alice', 'contacts': [{'type': 'email', 'value': '[email protected]'}, {'type': 'phone', 'value': '+1234567890'}]}]
Debug: Raw contact objects: [[{'type': 'email', 'value': '[email protected]'}, {'type': 'phone', 'value': '+1234567890'}]]
Debug: Flattened contacts: [{'type': 'email', 'value': '[email protected]'}, {'type': 'phone', 'value': '+1234567890'}]
Debug: All contact types: ['email', 'phone']
Debug: Raw type values: ['email', 'phone']
Debug: Contacts with type == email: []
Debug: Minimal test: None
Test failed!
Query: users[?id == `1`].contacts[][?type == `email`].value | [0]
Expected: [email protected]
Got: None

Testing query: users[?id == `1`].contacts[*][?type == `email`].value | [0]
JSON Data: {
  "users": [
    {
      "id": 1,
      "name": "Alice",
      "contacts": [
        {
          "type": "email",
          "value": "[email protected]"
        },
        {
          "type": "phone",
          "value": "+1234567890"
        }
      ]
    },
    {
      "id": 2,
      "name": "Bob",
      "contacts": [
        {
          "type": "email",
          "value": "[email protected]"
        }
      ]
    }
  ]
}
Debug: JMESPath version: 1.0.1
Debug: Python version: 3.10.16 | packaged by conda-forge | (main, Dec  5 2024, 14:16:10) [GCC 13.3.0]
Debug: Users with id == 1: [{'id': 1, 'name': 'Alice', 'contacts': [{'type': 'email', 'value': '[email protected]'}, {'type': 'phone', 'value': '+1234567890'}]}]
Debug: Raw contact objects: [[{'type': 'email', 'value': '[email protected]'}, {'type': 'phone', 'value': '+1234567890'}]]
Debug: Flattened contacts: [{'type': 'email', 'value': '[email protected]'}, {'type': 'phone', 'value': '+1234567890'}]
Debug: All contact types: ['email', 'phone']
Debug: Raw type values: ['email', 'phone']
Debug: Contacts with type == email: []
Debug: Minimal test: None
Test failed!
Query: users[?id == `1`].contacts[*][?type == `email`].value | [0]
Expected: [email protected]
Got: []

Manual filtering workaround:
Manual result: [email protected]

From JSON above what query should be used to extract [email protected] without providing array index in query but rely only on filtering

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.