Add SQLite "ON CONFLICT" column option in CREATE TABLE statements (#1442)

Co-authored-by: hulk <hulk.website@gmail.com>
Co-authored-by: Ifeanyi Ubah <ify1992@yahoo.com>
This commit is contained in:
nucccc 2024-10-07 22:20:55 +02:00 committed by GitHub
parent 84348d483e
commit 8badcdc200
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 62 additions and 0 deletions

View file

@ -6224,6 +6224,19 @@ impl<'a> Parser<'a> {
None
};
Ok(Some(ColumnOption::Identity(property)))
} else if dialect_of!(self is SQLiteDialect | GenericDialect)
&& self.parse_keywords(&[Keyword::ON, Keyword::CONFLICT])
{
// Support ON CONFLICT for SQLite
Ok(Some(ColumnOption::OnConflict(
self.expect_one_of_keywords(&[
Keyword::ROLLBACK,
Keyword::ABORT,
Keyword::FAIL,
Keyword::IGNORE,
Keyword::REPLACE,
])?,
)))
} else {
Ok(None)
}