Skip to content
This repository was archived by the owner on Jul 15, 2021. It is now read-only.
This repository was archived by the owner on Jul 15, 2021. It is now read-only.

Confusion about parsing of "not" operator #51

@eatonphil

Description

@eatonphil

Hi! In the following example I'd expect "not" to be a first-class member of the AST. But it appears to just be concatenated with the operator after it. This would imply I've got to then do string parsing of the operation field if I'm trying to discover "not" use:

> const { statement: [{ where: [where5] }] }  = parser('select 1 where processName =  \'/bin/sh\' and id not like \'foo\'');
undefined
> where5
{ type: 'expression',
  format: 'binary',
  variant: 'operation',
  operation: 'and',
  left:
   { type: 'expression',
     format: 'binary',
     variant: 'operation',
     operation: '=',
     left: { type: 'identifier', variant: 'column', name: 'processname' },
     right: { type: 'literal', variant: 'text', value: '/bin/sh' } },
  right:
   { type: 'expression',
     format: 'binary',
     variant: 'operation',
     operation: 'not like',
     right: { type: 'literal', variant: 'text', value: 'foo' },
     left: { type: 'identifier', variant: 'column', name: 'id' } } }

Is this intentional? I'd expect the AST to look more like:

  ...
  right:
   { type: 'expression',
     format: 'unary',
     variant: 'operation',
     operation: 'not',
     expression:
     {  type: 'expression',
        format: 'binary',
        variant: 'operation',
        operation: 'like',
        right: { type: 'literal', variant: 'text', value: 'foo' },
        left: { type: 'identifier', variant: 'column', name: 'id' } } } }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions