taozhi8833998 / taozhi8833998/node-sql-parser

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

Open
#1,925 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PEG.js
Stars
1k
Forks
244
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with types.ts.d and inspect the With interface alongside the object returned by astify(). Confirm whether With.stmt is the Select AST itself or wraps it in an ast property, then make the declaration and implementation agree and verify the resulting type shape against an astify() output.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.