Merge 'core/translate: throw parse error on unsupported GENERATED column constraints' from Preston Thorpe

similar to #3755, we do this for #3749

Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #3758
This commit is contained in:
Preston Thorpe
2025-10-16 15:41:39 -04:00
committed by GitHub
2 changed files with 11 additions and 3 deletions

View File

@@ -1635,6 +1635,9 @@ pub fn create_table(tbl_name: &str, body: &CreateTableBody, root_page: i64) -> R
ast::ColumnConstraint::Check { .. } => {
crate::bail_parse_error!("CHECK constraints are not yet supported");
}
ast::ColumnConstraint::Generated { .. } => {
crate::bail_parse_error!("GENERATED columns are not yet supported");
}
ast::ColumnConstraint::PrimaryKey {
order: o,
auto_increment,
@@ -1727,7 +1730,6 @@ pub fn create_table(tbl_name: &str, body: &CreateTableBody, root_page: i64) -> R
};
foreign_keys.push(Arc::new(fk));
}
_ => {}
}
}

View File

@@ -41,8 +41,14 @@ fn validate(body: &ast::CreateTableBody, connection: &Connection) -> Result<()>
let col_i = &columns[i];
for constraint in &col_i.constraints {
// don't silently ignore CHECK constraints, throw parse error for now
if let ast::ColumnConstraint::Check { .. } = constraint.constraint {
bail_parse_error!("CHECK constraints are not supported yet");
match constraint.constraint {
ast::ColumnConstraint::Check { .. } => {
bail_parse_error!("CHECK constraints are not supported yet");
}
ast::ColumnConstraint::Generated { .. } => {
bail_parse_error!("GENERATED columns are not supported yet");
}
_ => {}
}
}
for j in &columns[(i + 1)..] {