jetstreamapp / soql-parser-js

Javascript SOQL parser
https://jetstreamapp.github.io/soql-parser-js/
MIT License
77 stars 20 forks source link

keep literalType in the result JSON #207

Closed ghingis closed 1 year ago

ghingis commented 1 year ago

Description

Is it possible to keep the literal type for the subqueries in the condition clause?

Currently a query like this: SELECT Id FROM Account WHERE Id IN (SELECT AccountId FROM Opportunity) returns with the following result:

{
  "fields": [
    {
      "type": "Field",
      "field": "Id"
    }
  ],
  "sObject": "Account",
  "where": {
    "left": {
      "field": "Id",
      "operator": "IN",
      "valueQuery": {
        "fields": [
          {
            "type": "Field",
            "field": "AccountId"
          }
        ],
        "sObject": "Opportunity"
      }
    }
  }
}

I think it should also return the literal type like this.

{
  ...
  "where": {
    "left": {
      ...
      "operator": "IN",
      "literalType": "SUBQUERY"
      "valueQuery": {
        ...
      }
    }
  }
}

This would help to handle the results afterward. I'm not sure if there are any other literalType that is ommited from the final result, but if there are, please keep them as well

paustint commented 1 year ago

This does appear to be a bug, I will take a look into it.

I am on holiday now, so it may be a few days before I am able to investigate.