Skip to content

Commit b3a24e5

Browse files
committed
BREAKING! PostgreSQL array[] type now uses Empty
Instead of using empty ListExpr we now use a more concrete Empty node. Similarly for array[3] we now use just NumberLiteral not ListExpr<NumberLiteral>. This should make more sense as there can never be more than one number inside the bounds specifier, so ListExpr was a bad choice.
1 parent 61167a0 commit b3a24e5

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/cst/DataType.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BaseNode, Keyword } from "./Base";
1+
import { BaseNode, Empty, Keyword } from "./Base";
22
import { ColumnConstraint } from "./Constraint";
33
import { Identifier, ListExpr, ParenExpr } from "./Expr";
44
import { Literal, NumberLiteral } from "./Literal";
@@ -28,9 +28,7 @@ export interface ArrayDataType extends BaseNode {
2828
// PostgreSQL
2929
export interface ArrayBounds extends BaseNode {
3030
type: "array_bounds";
31-
// This can only contain one or zero items.
32-
// We use a list because we want to store whitespace and comments inside empty [] brackets.
33-
bounds: ListExpr<NumberLiteral>; // TODO: use Empty node instead of empty ListExpr
31+
bounds: NumberLiteral | Empty;
3432
}
3533

3634
// PostgreSQL

src/parser.pegjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3585,10 +3585,10 @@ data_type
35853585
/ named_data_type
35863586

35873587
array_bounds
3588-
= "[" bounds:(__ empty_list __) "]" {
3588+
= "[" bounds:(__ empty __) "]" {
35893589
return loc({ type: "array_bounds", bounds: read(bounds) });
35903590
}
3591-
/ "[" bounds:(__ list$number_literal __) "]" {
3591+
/ "[" bounds:(__ number_literal __) "]" {
35923592
return loc({ type: "array_bounds", bounds: read(bounds) });
35933593
}
35943594

0 commit comments

Comments
 (0)