Nested querying issue

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

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

評価

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

調査の方向性

JMESPath の JavaScript 実装で issue にあるネストしたフィルタークエリを再現し、その結果を報告されている Python の動作と比較します。利用可能であれば、まずクエリ評価器と既存のフィルタリングテストを確認します。期待される結果と、その不一致が実装上のバグなのかクエリセマンティクスの問題なのかが確定すれば完了です。

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

説明

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

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

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

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

jmespath/jmespath.js のほかの issue

jmespath/jmespath.js の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

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

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