Skip to content

Commit

Permalink
Codegen supports VarBinary column type (#746)
Browse files Browse the repository at this point in the history
* [cli]: codegen supports `VarBinary` column type

* Fixup
  • Loading branch information
billy1624 authored Jul 17, 2022
1 parent 58d0b66 commit 13d2abf
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions sea-orm-codegen/src/entity/column.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl Column {
},
ColumnType::Decimal(_) | ColumnType::Money(_) => "Decimal".to_owned(),
ColumnType::Uuid => "Uuid".to_owned(),
ColumnType::Binary(_) => "Vec<u8>".to_owned(),
ColumnType::Binary(_) | ColumnType::VarBinary(_) => "Vec<u8>".to_owned(),
ColumnType::Boolean => "bool".to_owned(),
ColumnType::Enum(name, _) => name.to_camel_case(),
_ => unimplemented!(),
Expand Down Expand Up @@ -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() },
Expand Down Expand Up @@ -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)),
Expand All @@ -292,6 +293,7 @@ mod tests {
"cake_filling_id",
"cake_filling_id",
"cake_filling_id",
"cake_filling_id",
"cake",
"date",
"time",
Expand Down Expand Up @@ -321,6 +323,7 @@ mod tests {
"CakeFillingId",
"CakeFillingId",
"CakeFillingId",
"CakeFillingId",
"Cake",
"Date",
"Time",
Expand Down Expand Up @@ -351,6 +354,7 @@ mod tests {
"f32",
"f64",
"Vec<u8>",
"Vec<u8>",
"bool",
"Date",
"Time",
Expand Down Expand Up @@ -393,6 +397,7 @@ mod tests {
"f32",
"f64",
"Vec<u8>",
"Vec<u8>",
"bool",
"TimeDate",
"TimeTime",
Expand Down Expand Up @@ -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()",
Expand Down

0 comments on commit 13d2abf

Please sign in to comment.