refactor: remove optional from the protos (#756)

This commit is contained in:
Jiachun Feng
2022-12-16 15:47:51 +08:00
committed by GitHub
parent 7c16a4a17b
commit 66bca11401
16 changed files with 235 additions and 189 deletions

View File

@@ -283,7 +283,7 @@ pub fn sql_column_def_to_grpc_column_def(col: ColumnDef) -> Result<api::v1::Colu
name,
datatype: data_type,
is_nullable,
default_constraint,
default_constraint: default_constraint.unwrap_or_default(),
})
}
@@ -588,7 +588,7 @@ mod tests {
assert_eq!("col", grpc_column_def.name);
assert!(grpc_column_def.is_nullable); // nullable when options are empty
assert_eq!(ColumnDataType::Float64 as i32, grpc_column_def.datatype);
assert_eq!(None, grpc_column_def.default_constraint);
assert!(grpc_column_def.default_constraint.is_empty());
// test not null
let column_def = ColumnDef {

View File

@@ -56,7 +56,7 @@ impl TryFrom<AlterTable> for AlterExpr {
type Error = crate::error::Error;
fn try_from(value: AlterTable) -> Result<Self, Self::Error> {
let (catalog, schema, table) = table_idents_to_full_name(&value.table_name)?;
let (catalog_name, schema_name, table_name) = table_idents_to_full_name(&value.table_name)?;
let kind = match value.alter_operation {
AlterTableOperation::AddConstraint(_) => {
@@ -80,9 +80,9 @@ impl TryFrom<AlterTable> for AlterExpr {
}
};
let expr = AlterExpr {
catalog_name: Some(catalog),
schema_name: Some(schema),
table_name: table,
catalog_name,
schema_name,
table_name,
kind: Some(kind),
};