Skip to content

Commit 13c875f

Browse files
Merge pull request #2021 from taozhi8833998/refactor-default-expr
refactor: default expr in all dialects
2 parents 645713b + 6605670 commit 13c875f

15 files changed

+26
-23
lines changed

pegjs/athena.pegjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ storage
477477
}
478478
}
479479
default_expr
480-
= KW_DEFAULT __ ce: (literal / expr) {
480+
= KW_DEFAULT __ ce:expr {
481481
return {
482482
type: 'default',
483483
value: ce

pegjs/bigquery.pegjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1141,7 +1141,7 @@ create_fulltext_spatial_index_definition
11411141
}
11421142

11431143
default_expr
1144-
= KW_DEFAULT __ ce: (literal / expr) {
1144+
= KW_DEFAULT __ ce:expr {
11451145
return {
11461146
type: 'default',
11471147
value: ce

pegjs/db2.pegjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ storage
474474
}
475475
}
476476
default_expr
477-
= KW_DEFAULT __ ce: (literal / expr) {
477+
= KW_DEFAULT __ ce:expr {
478478
return {
479479
type: 'default',
480480
value: ce

pegjs/flinksql.pegjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,7 @@ storage
930930
}
931931
}
932932
default_expr
933-
= KW_DEFAULT __ ce: (literal / expr) {
933+
= KW_DEFAULT __ ce:expr {
934934
// => { type: 'default'; value: literal | expr; }
935935
return {
936936
type: 'default',

pegjs/hive.pegjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ storage
475475
}
476476
}
477477
default_expr
478-
= KW_DEFAULT __ ce: (literal / expr) {
478+
= KW_DEFAULT __ ce:expr {
479479
return {
480480
type: 'default',
481481
value: ce

pegjs/mariadb.pegjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ storage
849849
}
850850
}
851851
default_expr
852-
= KW_DEFAULT __ ce: (literal / expr) {
852+
= KW_DEFAULT __ ce:expr {
853853
return {
854854
type: 'default',
855855
value: ce

pegjs/mysql.pegjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,7 @@ storage
10481048
}
10491049
}
10501050
default_expr
1051-
= KW_DEFAULT __ ce: (literal / expr) {
1051+
= KW_DEFAULT __ ce:expr {
10521052
return {
10531053
type: 'default',
10541054
value: ce

pegjs/noql.pegjs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,17 +1258,15 @@ storage
12581258
}
12591259
}
12601260
default_arg_expr
1261-
= kw:(KW_DEFAULT / KW_ASSIGIN_EQUAL)? __ ce:(literal / expr) {
1262-
// => { type: 'default'; keyword: string, value: literal | expr; }
1261+
= kw:(KW_DEFAULT / KW_ASSIGIN_EQUAL)? __ ce:expr {
12631262
return {
12641263
type: 'default',
12651264
keyword: kw && kw[0],
12661265
value: ce
12671266
}
12681267
}
12691268
default_expr
1270-
= KW_DEFAULT __ ce: (literal / expr) {
1271-
// => { type: 'default'; value: literal | expr; }
1269+
= KW_DEFAULT __ ce:expr {
12721270
return {
12731271
type: 'default',
12741272
value: ce

pegjs/postgresql.pegjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,17 +1400,17 @@ storage
14001400
}
14011401
}
14021402
default_arg_expr
1403-
= kw:(KW_DEFAULT / KW_ASSIGIN_EQUAL)? __ ce:(literal / expr) {
1404-
// => { type: 'default'; keyword: string, value: literal | expr; }
1403+
= kw:(KW_DEFAULT / KW_ASSIGIN_EQUAL)? __ ce:expr {
1404+
// => { type: 'default'; keyword: string, value: expr; }
14051405
return {
14061406
type: 'default',
14071407
keyword: kw && kw[0],
14081408
value: ce
14091409
}
14101410
}
14111411
default_expr
1412-
= KW_DEFAULT __ ce: (literal / expr) {
1413-
// => { type: 'default'; value: literal | expr; }
1412+
= KW_DEFAULT __ ce:expr {
1413+
// => { type: 'default'; value: expr; }
14141414
return {
14151415
type: 'default',
14161416
value: ce

pegjs/redshift.pegjs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,17 +1270,15 @@ storage
12701270
}
12711271
}
12721272
default_arg_expr
1273-
= kw:(KW_DEFAULT / KW_ASSIGIN_EQUAL)? __ ce:(literal / expr) {
1274-
// => { type: 'default'; keyword: string, value: literal | expr; }
1273+
= kw:(KW_DEFAULT / KW_ASSIGIN_EQUAL)? __ ce:expr {
12751274
return {
12761275
type: 'default',
12771276
keyword: kw && kw[0],
12781277
value: ce
12791278
}
12801279
}
12811280
default_expr
1282-
= KW_DEFAULT __ ce: (literal / expr) {
1283-
// => { type: 'default'; value: literal | expr; }
1281+
= KW_DEFAULT __ ce:expr {
12841282
return {
12851283
type: 'default',
12861284
value: ce

pegjs/snowflake.pegjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,7 @@ storage
10091009
}
10101010
}
10111011
default_expr
1012-
= KW_DEFAULT __ ce: (literal / expr) {
1012+
= KW_DEFAULT __ ce:expr {
10131013
// => { type: 'default'; value: literal | expr; }
10141014
return {
10151015
type: 'default',

pegjs/sqlite.pegjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ storage
597597
}
598598
}
599599
default_expr
600-
= KW_DEFAULT __ ce: (literal / expr) {
600+
= KW_DEFAULT __ ce:expr {
601601
return {
602602
type: 'default',
603603
value: ce

pegjs/transactsql.pegjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ storage
593593
}
594594
}
595595
default_expr
596-
= KW_DEFAULT __ ce: (literal / expr) {
596+
= KW_DEFAULT __ ce:expr {
597597
return {
598598
type: 'default',
599599
value: ce

pegjs/trino.pegjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,7 @@ storage
10191019
}
10201020
}
10211021
default_expr
1022-
= KW_DEFAULT __ ce: (literal / expr) {
1022+
= KW_DEFAULT __ ce:expr {
10231023
// => { type: 'default'; value: literal | expr; }
10241024
return {
10251025
type: 'default',

test/postgres.spec.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,6 +1588,13 @@ describe('Postgres', () => {
15881588
'CREATE TYPE "float8_range" AS RANGE (subtype = float8, subtype_diff = float8mi)'
15891589
]
15901590
},
1591+
{
1592+
title: '',
1593+
sql: [
1594+
"CREATE TABLE public.tnotok (description text DEFAULT ''::text NOT NULL);",
1595+
`CREATE TABLE "public"."tnotok" (description TEXT NOT NULL DEFAULT ''::TEXT)`,
1596+
]
1597+
},
15911598
]
15921599
function neatlyNestTestedSQL(sqlList){
15931600
sqlList.forEach(sqlInfo => {

0 commit comments

Comments
 (0)