Skip to content
This repository was archived by the owner on Jul 15, 2021. It is now read-only.

Commit 2338427

Browse files
committed
Add missing fields to FOREIGN KEY constraint node.
1 parent e2d11ff commit 2338427

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

src/grammar.pegjs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2169,25 +2169,24 @@ foreign_clause
21692169
= r:( foreign_references ) a:( foreign_actions )? d:( foreign_deferrable )?
21702170
{
21712171
return Object.assign({
2172-
'type': 'constraint',
2173-
'action': a,
2174-
'defer': d
2175-
}, r);
2172+
'type': 'constraint'
2173+
}, r, a, d);
21762174
}
21772175

21782176
foreign_references "REFERENCES Clause"
2179-
= s:( REFERENCES ) o t:( id_cte )
2177+
= s:( REFERENCES ) o t:( id_cte ) o
21802178
{
21812179
return {
21822180
'references': t
21832181
};
21842182
}
21852183

2186-
2187-
21882184
foreign_actions
2189-
= f:( foreign_action ) o b:( foreign_actions_tail )*
2190-
{ return collect([f, b], []); }
2185+
= f:( foreign_action ) o b:( foreign_actions_tail )* {
2186+
return {
2187+
'action': flattenAll([ f, b ])
2188+
};
2189+
}
21912190

21922191
foreign_actions_tail
21932192
= a:( foreign_action ) o
@@ -2213,22 +2212,22 @@ action_on_action "FOREIGN KEY Action"
22132212
/ on_action_none
22142213

22152214
on_action_set
2216-
= s:( SET ) o v:( NULL / DEFAULT )
2215+
= s:( SET ) o v:( NULL / DEFAULT ) o
22172216
{ return foldString([ s, v ]); }
22182217

22192218
on_action_cascade
2220-
= c:( CASCADE / RESTRICT )
2219+
= c:( CASCADE / RESTRICT ) o
22212220
{ return textNode(c); }
22222221

22232222
on_action_none
2224-
= n:( NO ) o a:( ACTION )
2223+
= n:( NO ) o a:( ACTION ) o
22252224
{ return foldString([ n, a ]); }
22262225

22272226
/**
22282227
* @note Not sure what kind of name this should be.
22292228
*/
22302229
foreign_action_match
2231-
= m:( MATCH ) o n:( name )
2230+
= m:( MATCH ) o n:( name ) o
22322231
{
22332232
return {
22342233
'type': 'action',
@@ -2238,8 +2237,11 @@ foreign_action_match
22382237
}
22392238

22402239
foreign_deferrable "DEFERRABLE Clause"
2241-
= n:( expression_is_not )? d:( DEFERRABLE ) o i:( deferrable_initially )?
2242-
{ return foldStringKey([ n, d, i ]); }
2240+
= n:( expression_is_not )? d:( DEFERRABLE ) o i:( deferrable_initially )? {
2241+
return {
2242+
'defer': foldStringKey([ n, d, i ])
2243+
};
2244+
}
22432245

22442246
deferrable_initially
22452247
= i:( INITIALLY ) o d:( DEFERRED / IMMEDIATE ) o
@@ -2282,7 +2284,7 @@ index_unique
22822284
}
22832285

22842286
index_on "ON Clause"
2285-
= o:( ON ) o t:( id_table ) o c:( primary_columns )
2287+
= o:( ON ) o t:( id_table ) o c:( primary_columns_index )
22862288
{
22872289
return {
22882290
'type': 'identifier',

0 commit comments

Comments
 (0)