From 13d2abf5a8caa9cc9d61767be849ad05ba1365c3 Mon Sep 17 00:00:00 2001 From: Billy Chan Date: Sun, 17 Jul 2022 18:05:39 +0800 Subject: [PATCH] Codegen supports `VarBinary` column type (#746) * [cli]: codegen supports `VarBinary` column type * Fixup --- sea-orm-codegen/src/entity/column.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sea-orm-codegen/src/entity/column.rs b/sea-orm-codegen/src/entity/column.rs index 18ea94eb0..e6d715b10 100644 --- a/sea-orm-codegen/src/entity/column.rs +++ b/sea-orm-codegen/src/entity/column.rs @@ -68,7 +68,7 @@ impl Column { }, ColumnType::Decimal(_) | ColumnType::Money(_) => "Decimal".to_owned(), ColumnType::Uuid => "Uuid".to_owned(), - ColumnType::Binary(_) => "Vec".to_owned(), + ColumnType::Binary(_) | ColumnType::VarBinary(_) => "Vec".to_owned(), ColumnType::Boolean => "bool".to_owned(), ColumnType::Enum(name, _) => name.to_camel_case(), _ => unimplemented!(), @@ -128,7 +128,7 @@ impl Column { } ColumnType::Time(_) => quote! { ColumnType::Time.def() }, ColumnType::Date => quote! { ColumnType::Date.def() }, - ColumnType::Binary(BlobSize::Blob(_)) => quote! { ColumnType::Binary.def() }, + ColumnType::Binary(BlobSize::Blob(_)) | ColumnType::VarBinary(_) => quote! { ColumnType::Binary.def() }, ColumnType::Binary(BlobSize::Tiny) => quote! { ColumnType::TinyBinary.def() }, ColumnType::Binary(BlobSize::Medium) => quote! { ColumnType::MediumBinary.def() }, ColumnType::Binary(BlobSize::Long) => quote! { ColumnType::LongBinary.def() }, @@ -266,6 +266,7 @@ mod tests { make_col!("cake-filling-id", ColumnType::Float(None)), make_col!("CAKE_FILLING_ID", ColumnType::Double(None)), make_col!("CAKE-FILLING-ID", ColumnType::Binary(BlobSize::Blob(None))), + make_col!("CAKE-FILLING-ID", ColumnType::VarBinary(10)), make_col!("CAKE", ColumnType::Boolean), make_col!("date", ColumnType::Date), make_col!("time", ColumnType::Time(None)), @@ -292,6 +293,7 @@ mod tests { "cake_filling_id", "cake_filling_id", "cake_filling_id", + "cake_filling_id", "cake", "date", "time", @@ -321,6 +323,7 @@ mod tests { "CakeFillingId", "CakeFillingId", "CakeFillingId", + "CakeFillingId", "Cake", "Date", "Time", @@ -351,6 +354,7 @@ mod tests { "f32", "f64", "Vec", + "Vec", "bool", "Date", "Time", @@ -393,6 +397,7 @@ mod tests { "f32", "f64", "Vec", + "Vec", "bool", "TimeDate", "TimeTime", @@ -434,6 +439,7 @@ mod tests { "ColumnType::Float.def()", "ColumnType::Double.def()", "ColumnType::Binary.def()", + "ColumnType::Binary.def()", "ColumnType::Boolean.def()", "ColumnType::Date.def()", "ColumnType::Time.def()",