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

Commit e2d11ff

Browse files
committed
Allow trailing CONSTRAINT names.
From SQLite official tests: Undocumented behavior: The CONSTRAINT name clause can follow a constraint. Such a clause is ignored. But the parser must accept it for backwards compatibility.
1 parent 87df549 commit e2d11ff

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

src/grammar.pegjs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1890,12 +1890,14 @@ column_constraint_tail
18901890
= o c:( column_constraint )
18911891
{ return c; }
18921892

1893-
/** {@link https://www.sqlite.org/syntax/column-constraint.html} */
1894-
/* Note from SQLite official tests:
1895-
* Undocumented behavior: The CONSTRAINT name clause can follow a constraint.
1896-
* Such a clause is ignored. But the parser must accept it for backwards
1897-
* compatibility.
1893+
/**
1894+
* @note
1895+
* From SQLite official tests:
1896+
* Undocumented behavior: The CONSTRAINT name clause can follow a constraint.
1897+
* Such a clause is ignored. But the parser must accept it for backwards
1898+
* compatibility.
18981899
*/
1900+
/** {@link https://www.sqlite.org/syntax/column-constraint.html} */
18991901
column_constraint "Column Constraint"
19001902
= n:( constraint_name )? c:( column_constraint_types ) ln:( constraint_name )?
19011903
{
@@ -2007,23 +2009,20 @@ column_constraint_collate "COLLATE Column Constraint"
20072009
}
20082010

20092011
/** {@link https://www.sqlite.org/syntax/table-constraint.html} */
2012+
/* Note from SQLite official tests:
2013+
* Undocumented behavior: The CONSTRAINT name clause can follow a constraint.
2014+
* Such a clause is ignored. But the parser must accept it for backwards
2015+
* compatibility.
2016+
*/
20102017
table_constraint "Table Constraint"
2011-
= n:( table_constraint_name )? o c:( table_constraint_types ) o
2018+
= n:( constraint_name )? c:( table_constraint_types ) o nl:( constraint_name )?
20122019
{
20132020
return Object.assign({
20142021
'type': 'definition',
20152022
'variant': 'constraint'
20162023
}, c, n);
20172024
}
20182025

2019-
table_constraint_name "Table Constraint Name"
2020-
= CONSTRAINT o n:( name )
2021-
{
2022-
return {
2023-
'name': n
2024-
};
2025-
}
2026-
20272026
table_constraint_types
20282027
= table_constraint_foreign
20292028
/ table_constraint_primary

0 commit comments

Comments
 (0)