@@ -2622,7 +2622,12 @@ module.exports = grammar({
26222622 ) ,
26232623
26242624 column_definitions : ( $ ) =>
2625- seq ( "(" , comma_list ( $ . column_definition , true ) , ")" ) ,
2625+ seq (
2626+ "(" ,
2627+ comma_list ( $ . column_definition , true ) ,
2628+ optional ( $ . constraints ) ,
2629+ ")"
2630+ ) ,
26262631
26272632 column_definition : ( $ ) =>
26282633 seq (
@@ -2697,6 +2702,16 @@ module.exports = grammar({
26972702 alias ( $ . implicit_cast , $ . cast )
26982703 ) ,
26992704
2705+ constraints : ( $ ) => seq ( "," , $ . constraint , repeat ( seq ( "," , $ . constraint ) ) ) ,
2706+
2707+ constraint : ( $ ) =>
2708+ choice (
2709+ $ . _constraint_literal ,
2710+ $ . _key_constraint ,
2711+ $ . _primary_key_constraint ,
2712+ $ . _check_constraint
2713+ ) ,
2714+
27002715 _constraint_literal : ( $ ) =>
27012716 seq (
27022717 $ . keyword_constraint ,
@@ -2706,6 +2721,57 @@ module.exports = grammar({
27062721
27072722 _primary_key_constraint : ( $ ) => seq ( $ . _primary_key , $ . ordered_columns ) ,
27082723
2724+ _key_constraint : ( $ ) =>
2725+ seq (
2726+ choice (
2727+ seq (
2728+ $ . keyword_unique ,
2729+ optional (
2730+ choice (
2731+ $ . keyword_index ,
2732+ $ . keyword_key ,
2733+ seq (
2734+ $ . keyword_nulls ,
2735+ optional ( $ . keyword_not ) ,
2736+ $ . keyword_distinct
2737+ )
2738+ )
2739+ )
2740+ ) ,
2741+ seq (
2742+ optional ( $ . keyword_foreign ) ,
2743+ $ . keyword_key ,
2744+ optional ( $ . _if_not_exists )
2745+ ) ,
2746+ $ . keyword_index
2747+ ) ,
2748+ optional ( field ( "name" , $ . any_identifier ) ) ,
2749+ $ . ordered_columns ,
2750+ optional (
2751+ seq (
2752+ $ . keyword_references ,
2753+ $ . object_reference ,
2754+ paren_list ( $ . column_identifier , true ) ,
2755+ repeat (
2756+ seq (
2757+ $ . keyword_on ,
2758+ choice ( $ . keyword_delete , $ . keyword_update ) ,
2759+ choice (
2760+ seq ( $ . keyword_no , $ . keyword_action ) ,
2761+ $ . keyword_restrict ,
2762+ $ . keyword_cascade ,
2763+ seq (
2764+ $ . keyword_set ,
2765+ choice ( $ . keyword_null , $ . keyword_default ) ,
2766+ optional ( paren_list ( $ . any_identifier , true ) )
2767+ )
2768+ )
2769+ )
2770+ )
2771+ )
2772+ )
2773+ ) ,
2774+
27092775 ordered_columns : ( $ ) => paren_list ( alias ( $ . ordered_column , $ . column ) , true ) ,
27102776
27112777 ordered_column : ( $ ) => seq ( field ( "name" , $ . _column ) , optional ( $ . direction ) ) ,
0 commit comments