@@ -86,6 +86,7 @@ NOT\s+ILIKE return 'NOT_LIKE'
8686
8787'CALL' return ' CALL'
8888'CASE' return ' CASE'
89+ 'CASCADE' return ' CASCADE'
8990'CAST' return ' CAST'
9091'CHECK' return ' CHECK'
9192'CLASS' return ' CLASS'
@@ -218,6 +219,7 @@ DATABASE(S)? return 'DATABASE'
218219'RENAME' return ' RENAME'
219220'REPEAT' return ' REPEAT'
220221'REPLACE' return ' REPLACE'
222+ 'RESTRICT' return ' RESTRICT'
221223'REQUIRE' return ' REQUIRE'
222224'RESTORE' return ' RESTORE'
223225'RETURN' return ' RETURN'
@@ -2044,29 +2046,48 @@ PrimaryKey
20442046
20452047ForeignKey
20462048 : FOREIGN KEY LPAR ColsList RPAR REFERENCES Table ParColsList?
2047- OnForeignKeyClause
2048- { $$ = {type: ' FOREIGN KEY' , columns: $4 , fktable: $7 , fkcolumns: $8 }; }
2049+ OnReferentialActions
2050+ { $$ = {type: ' FOREIGN KEY' , columns: $4 , fktable: $7 , fkcolumns: $8 }; yy . extend ( $$ , $9 ); }
20492051 ;
20502052
20512053ParColsList
20522054 : LPAR ColsList RPAR
20532055 { $$ = $2 ; }
20542056 ;
20552057
2056- OnForeignKeyClause
2058+ OnReferentialActions
20572059 :
2058- { $$ = undefined ; }
2060+ {$$ = {}; }
2061+ | OnDeleteClause
2062+ {$$ = {ondelete: $1 }; }
2063+ | OnUpdateClause
2064+ {$$ = {onupdate: $1 }; }
20592065 | OnDeleteClause OnUpdateClause
2060- { $$ = undefined ; }
2066+ {$$ = {ondelete: $1 , onupdate: $2 }; }
2067+ | OnUpdateClause OnDeleteClause
2068+ {$$ = {ondelete: $2 , onupdate: $1 }; }
20612069 ;
20622070
20632071OnDeleteClause
2064- : ON DELETE NO ACTION
2065- {$$ = undefined ; }
2072+ : ON DELETE ReferentialAction
2073+ {$$ = $3 ; }
20662074 ;
20672075OnUpdateClause
2068- : ON UPDATE NO ACTION
2069- {$$ = undefined ; }
2076+ : ON UPDATE ReferentialAction
2077+ {$$ = $3 ; }
2078+ ;
2079+
2080+ ReferentialAction
2081+ : CASCADE
2082+ {$$ = ' CASCADE' ; }
2083+ | SET NULL
2084+ {$$ = ' SET NULL' ; }
2085+ | SET DEFAULT
2086+ {$$ = ' SET DEFAULT' ; }
2087+ | RESTRICT
2088+ {$$ = ' RESTRICT' ; }
2089+ | NO ACTION
2090+ {$$ = ' NO ACTION' ; }
20702091 ;
20712092
20722093UniqueKey
@@ -2181,10 +2202,10 @@ ParLiteral
21812202ColumnConstraint
21822203 : PRIMARY KEY
21832204 {$$ = {primarykey: true }; }
2184- | FOREIGN KEY REFERENCES Table ParLiteral?
2185- {$$ = {foreignkey: {table: $4 , columnid: $5 }}; }
2186- | REFERENCES Table ParLiteral?
2187- {$$ = {foreignkey: {table: $2 , columnid: $3 }}; }
2205+ | FOREIGN KEY REFERENCES Table ParLiteral? OnReferentialActions
2206+ {$$ = {foreignkey: {table: $4 , columnid: $5 }}; yy . extend ( $$ . foreignkey , $6 ); }
2207+ | REFERENCES Table ParLiteral? OnReferentialActions
2208+ {$$ = {foreignkey: {table: $2 , columnid: $3 }}; yy . extend ( $$ . foreignkey , $4 ); }
21882209 | IDENTITY LPAR NumValue COMMA NumValue RPAR
21892210 { $$ = {identity: {value: $3 ,step: $5 }} }
21902211 | IDENTITY
0 commit comments