Hi, thanks for this library! The type definitions are great ✨
There appears to be an issue with parsing zero and negative integers, such as in SELECT 0 and SELECT -42. Parsing these constants produces A_Const nodes with an empty ival:
I wonder if the @pg-nano/pg-parser types for this node are correct, or if you intentionally condensed the A_Const node? Also, why is ival optional for Integer, when the other literal types aren't?
Hi, thanks for this library! The type definitions are great ✨
There appears to be an issue with parsing zero and negative integers, such as in
SELECT 0
andSELECT -42
. Parsing these constants produces A_Const nodes with an empty ival:A successful parse (
SELECT 9000
) looks like this:pgsql-parser successfully parses these, and I also notice that their A_Const nodes look different:
I wonder if the @pg-nano/pg-parser types for this node are correct, or if you intentionally condensed the A_Const node? Also, why is
ival
optional for Integer, when the other literal types aren't?https://github.com/pg-nano/pg-parser/blob/c6136305a43bd67aa053d3dfdac532a97e421b41/src/lib/ast.ts#L6757-L6775
❌ Parse
```js import { parseQuerySync } from '@pg-nano/pg-parser' console.log(JSON.stringify(parseQuerySync('SELECT 0', null, 2)) /* { "version": 160001, "stmts": [ { "stmt": { "SelectStmt": { "targetList": [ { "ResTarget": { "val": { "A_Const": { "ival": {}, "location": 7 } }, "location": 7 } } ], "limitOption": "LIMIT_OPTION_DEFAULT", "op": "SETOP_NONE" } } } ] } */ ```SELECT 0
with @pg-nano/pg-parser❌ Parse
```js import { parseQuerySync } from '@pg-nano/pg-parser' console.log(JSON.stringify(parseQuerySync('SELECT -42', null, 2)) /* { "version": 160001, "stmts": [ { "stmt": { "SelectStmt": { "targetList": [ { "ResTarget": { "val": { "A_Const": { "ival": {}, "location": 7 } }, "location": 7 } } ], "limitOption": "LIMIT_OPTION_DEFAULT", "op": "SETOP_NONE" } } } ] } */ ```SELECT -42
with @pg-nano/pg-parser✅ Parse
```js import { parse } from 'pgsql-parser' console.log(JSON.stringify(parse('SELECT 0', null, 2)) /* [ { "RawStmt": { "stmt": { "SelectStmt": { "targetList": [ { "ResTarget": { "val": { "A_Const": { "val": { "Integer": { "ival": 0 } }, "location": 7 } }, "location": 7 } } ], "limitOption": "LIMIT_OPTION_DEFAULT", "op": "SETOP_NONE" } }, "stmt_location": 0 } } ] */ ```SELECT 0
with pgsql-parser✅ Parse
```js import { parse } from 'pgsql-parser' console.log(JSON.stringify(parse('SELECT -42', null, 2)) /* [ { "RawStmt": { "stmt": { "SelectStmt": { "targetList": [ { "ResTarget": { "val": { "A_Const": { "val": { "Integer": { "ival": -42 } }, "location": 7 } }, "location": 7 } } ], "limitOption": "LIMIT_OPTION_DEFAULT", "op": "SETOP_NONE" } }, "stmt_location": 0 } } ] */ ```SELECT -42
with pgsql-parser