diff --git a/src/backend/table_builder.rs b/src/backend/table_builder.rs index b5b2049d3..aafe8b1ff 100644 --- a/src/backend/table_builder.rs +++ b/src/backend/table_builder.rs @@ -101,6 +101,7 @@ pub trait TableBuilder: IndexBuilder + ForeignKeyBuilder + QuotedBuilder + Table TableOpt::Engine(s) => format!("ENGINE={}", s), TableOpt::Collate(s) => format!("COLLATE={}", s), TableOpt::CharacterSet(s) => format!("DEFAULT CHARSET={}", s), + TableOpt::Strict => "STRICT".to_string(), } ) .unwrap() diff --git a/src/table/create.rs b/src/table/create.rs index 2d6ddcd85..a3d5897c9 100644 --- a/src/table/create.rs +++ b/src/table/create.rs @@ -92,6 +92,7 @@ pub enum TableOpt { Engine(String), Collate(String), CharacterSet(String), + Strict, } /// All available table partition options @@ -246,6 +247,12 @@ impl TableCreateStatement { self } + /// Mark table as strict. SQLite only. + pub fn strict(&mut self) -> &mut Self { + self.opt(TableOpt::Strict); + self + } + fn opt(&mut self, option: TableOpt) -> &mut Self { self.options.push(option); self diff --git a/tests/sqlite/table.rs b/tests/sqlite/table.rs index 1fad76b67..6873abbda 100644 --- a/tests/sqlite/table.rs +++ b/tests/sqlite/table.rs @@ -316,6 +316,25 @@ fn create_with_unique_index_constraint() { ); } +#[test] +fn create_strict() { + assert_eq!( + Table::create() + .table(Task::Table) + .col(ColumnDef::new(Task::Id).integer()) + .col(ColumnDef::new(Task::IsDone).boolean()) + .strict() + .to_string(SqliteQueryBuilder), + [ + r#"CREATE TABLE "task" ("#, + r#""id" integer,"#, + r#""is_done" boolean"#, + r#") STRICT"#, + ] + .join(" ") + ); +} + #[test] fn drop_1() { assert_eq!(