Skip to content

Commit 88e6827

Browse files
committed
Allow any expression in type modifiers list
Fixes #121
1 parent 5b732af commit 88e6827

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

src/cst/DataType.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { BaseNode, Empty, Keyword } from "./Base";
22
import { ColumnConstraint } from "./Constraint";
33
import { ColumnDefinition } from "./CreateTable";
4-
import { EntityName, Identifier, ListExpr, ParenExpr } from "./Expr";
5-
import { Literal, NumberLiteral } from "./Literal";
4+
import { EntityName, Expr, Identifier, ListExpr, ParenExpr } from "./Expr";
5+
import { NumberLiteral } from "./Literal";
66

77
export type AllDataTypeNodes =
88
| DataType
@@ -23,7 +23,7 @@ export interface NamedDataType extends BaseNode {
2323
type: "named_data_type";
2424
// in PostgreSQL all data types will be parsed as DataTypeIdentifier
2525
name: Keyword | Keyword[] | DataTypeIdentifier;
26-
params?: ParenExpr<ListExpr<Literal>> | GenericTypeParams;
26+
params?: ParenExpr<ListExpr<Expr>> | GenericTypeParams;
2727
}
2828

2929
// PostgreSQL

src/parser.pegjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7030,7 +7030,7 @@ with_time_zone_data_type
70307030
/ named_data_type
70317031

70327032
named_data_type
7033-
= kw:(type_name __) params:paren$list$literal {
7033+
= kw:(type_name __) params:paren$list$expr {
70347034
return loc({ type: "named_data_type", name: read(kw), params });
70357035
}
70367036
/ &bigquery type:(bigquery_array_type / bigquery_struct_type / bigquery_table_type) {

test/ddl/data_types.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,13 @@ describe("data types", () => {
393393
testType("public.my_type");
394394
});
395395

396+
it("supports geometry types", () => {
397+
testType("GEOMETRY");
398+
testType("GEOMETRY(POLYGON, 3395)");
399+
testType("GEOMETRY(POINT, 4326)");
400+
testType("GEOMETRY(LINESTRINGZM, 4269)");
401+
});
402+
396403
it("parses data types as identifiers", () => {
397404
expect(parseExpr(`foo :: Character Varying`)).toMatchInlineSnapshot(`
398405
{

0 commit comments

Comments
 (0)