Skip to content

Queries consecutive left parens not accurately parsed #69

@paustint

Description

@paustint
  • Feature
  • Bug Request

Description

SELECT Id, Name
FROM Account
WHERE (((Name = '1'
OR Name = '2')
AND Name = '3'))
AND (((Description = '123')
OR (Id = '1'
AND Id = '2')))
AND Id = '1'

Parsed To:

{
    "fields": [
        {
            "type": "Field",
            "field": "Id"
        },
        {
            "type": "Field",
            "field": "Name"
        }
    ],
    "sObject": "Account",
    "where": {
        "left": {
            "openParen": 1,
            "field": "Name",
            "operator": "=",
            "value": "'1'",
            "literalType": "STRING"
        },
        "operator": "OR",
        "right": {
            "left": {
                "field": "Name",
                "operator": "=",
                "value": "'2'",
                "literalType": "STRING",
                "closeParen": 1
            },
            "operator": "AND",
            "right": {
                "left": {
                    "field": "Name",
                    "operator": "=",
                    "value": "'3'",
                    "literalType": "STRING",
                    "closeParen": 2
                },
                "operator": "AND",
                "right": {
                    "left": {
                        "openParen": 1,
                        "field": "Description",
                        "operator": "=",
                        "value": "'123'",
                        "literalType": "STRING",
                        "closeParen": 1
                    },
                    "operator": "OR",
                    "right": {
                        "left": {
                            "openParen": 1,
                            "field": "Id",
                            "operator": "=",
                            "value": "'1'",
                            "literalType": "STRING"
                        },
                        "operator": "AND",
                        "right": {
                            "left": {
                                "field": "Id",
                                "operator": "=",
                                "value": "'2'",
                                "literalType": "STRING",
                                "closeParen": 3
                            },
                            "operator": "AND",
                            "right": {
                                "left": {
                                    "field": "Id",
                                    "operator": "=",
                                    "value": "'1'",
                                    "literalType": "STRING"
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

Composed To:

SELECT Id, Name
FROM Account
WHERE (Name = '1'
OR Name = '2')
AND Name = '3'))
AND (Description = '123')
OR (Id = '1'
AND Id = '2')))
AND Id = '1'

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions