taozhi8833998 / node-sql-parser

Parse simple SQL statements into an abstract syntax tree (AST) with the visited tableList and convert it back to SQL
https://taozhi8833998.github.io/node-sql-parser/
Apache License 2.0
798 stars 180 forks source link

Interface for WITH statement does not match actual implementation wrt the stmt property #1925

Open pkthomsen opened 4 months ago

pkthomsen commented 4 months ago

Hi,

I noticed that the interface (in the types.ts.d file) for a WITH statement, it is defined like this:

export interface With {
  name: { value: string };
  stmt: {
    _parentheses?: boolean;
    tableList: string[];
    columnList: string[];
    ast: Select;
  };
  columns?: any[];
}

Here the stmt object contains a property 'ast' that is defined as a AST (or specifically a Select)

However, when I look at the actual object generated from the astify() function, I see that the stmt object itself is the AST object, i.e. as if the interface should have been like this:

export interface With {
  name: { value: string };
  stmt: Select;
  columns?: any[];
}

I much prefer the original definition of the interface, as it is very practical to always have a property named "ast" whenever there is an AST object. This makes it very easy to quickly parse through the output from astify() and find all ast named properties and parse these AST objects.