Nested querying issue

Aperta
#100 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
javascript, python
Ambito
tooling

Direzione di ricerca

Riproduci le query con filtri annidati dell’issue nell’implementazione JavaScript di JMESPath e confronta i relativi risultati con il comportamento Python segnalato. Inizia con il valutatore delle query e con i test di filtraggio esistenti, se disponibili; il lavoro è completato quando sono stati stabiliti il risultato atteso e se la discrepanza è un bug dell’implementazione o un problema di semantica della query.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
JavaScript
Stelle
847
Fork
105
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di jmespath/jmespath.js

Tutte le issue di jmespath/jmespath.js

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.