Skip to content

Commit

Permalink
Generate select_as and save_as attributes for custom column types.
Browse files Browse the repository at this point in the history
Fixes #1643
  • Loading branch information
lucasmerlin committed Jan 26, 2024
1 parent 387b07e commit 28fdb30
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions sea-orm-codegen/src/entity/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use heck::ToUpperCamelCase;
use proc_macro2::TokenStream;
use quote::{format_ident, quote};
use std::{collections::BTreeMap, str::FromStr};
use sea_query::ColumnType;
use syn::{punctuated::Punctuated, token::Comma};
use tracing::info;

Expand Down Expand Up @@ -754,6 +755,11 @@ impl EntityWriter {
attrs.push(quote! { nullable });
}
};
if let ColumnType::Custom(typ) = &col.col_type {
let type_string = typ.to_string();
attrs.push(quote! { select_as = "text" });
attrs.push(quote! { save_as = #type_string });
}
if col.unique {
attrs.push(quote! { unique });
}
Expand Down

0 comments on commit 28fdb30

Please sign in to comment.