File tree 2 files changed +18
-10
lines changed
2 files changed +18
-10
lines changed Original file line number Diff line number Diff line change @@ -3118,15 +3118,8 @@ comment_on_stmt
3118
3118
expr: is,
3119
3119
}
3120
3120
}
3121
- select_stmt
3122
- = KW_SELECT __ ';' {
3123
- // => { type: 'select'; }
3124
- return {
3125
- type: ' select' ,
3126
- }
3127
- }
3128
- / select_stmt_nake
3129
- / s :('(' __ select_stmt __ ')' ) {
3121
+ select_stmt_parentheses
3122
+ = s :('(' __ select_stmt __ ')' ) {
3130
3123
/*
3131
3124
export interface select_stmt_node extends select_stmt_nake {
3132
3125
parentheses: true;
@@ -3138,6 +3131,14 @@ select_stmt
3138
3131
parentheses_symbol: true ,
3139
3132
}
3140
3133
}
3134
+ select_stmt
3135
+ = KW_SELECT __ ';' {
3136
+ // => { type: 'select'; }
3137
+ return {
3138
+ type: ' select' ,
3139
+ }
3140
+ }
3141
+ / select_stmt_nake / select_stmt_parentheses
3141
3142
3142
3143
with_clause
3143
3144
= KW_WITH __ head :cte_definition tail :(__ COMMA __ cte_definition )* {
@@ -3820,7 +3821,7 @@ number_or_param
3820
3821
/ param
3821
3822
3822
3823
limit_clause
3823
- = l :(KW_LIMIT __ (number_or_param / KW_ALL ))? __ tail :(KW_OFFSET __ number_or_param )? {
3824
+ = l :(KW_LIMIT __ (number_or_param / KW_ALL / select_stmt_parentheses ))? __ tail :(KW_OFFSET __ number_or_param )? {
3824
3825
// => { separator: 'offset' | ''; value: [number_or_param | { type: 'origin', value: 'all' }, number_or_param?] }
3825
3826
const res = []
3826
3827
if (l) res .push (typeof l[2 ] === ' string' ? { type: ' origin' , value: ' all' } : l[2 ])
Original file line number Diff line number Diff line change @@ -1707,6 +1707,13 @@ describe('Postgres', () => {
1707
1707
'CREATE INDEX ON "tableName" (supplier, amount) INCLUDE (id)'
1708
1708
]
1709
1709
} ,
1710
+ {
1711
+ title : 'limit by select stmt' ,
1712
+ sql : [
1713
+ 'SELECT * FROM user LIMIT (SELECT COUNT(*) / 2 FROM user);' ,
1714
+ 'SELECT * FROM "user" LIMIT (SELECT COUNT(*) / 2 FROM "user")'
1715
+ ]
1716
+ } ,
1710
1717
]
1711
1718
function neatlyNestTestedSQL ( sqlList ) {
1712
1719
sqlList . forEach ( sqlInfo => {
You can’t perform that action at this time.
0 commit comments