From 28fdb308ffb5fd570c06cd0db9562a7fc9751438 Mon Sep 17 00:00:00 2001 From: Lucas Meurer Date: Fri, 26 Jan 2024 13:29:40 +0100 Subject: [PATCH] Generate select_as and save_as attributes for custom column types. Fixes #1643 --- sea-orm-codegen/src/entity/writer.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sea-orm-codegen/src/entity/writer.rs b/sea-orm-codegen/src/entity/writer.rs index 3c4c17eeb..7242bdc22 100644 --- a/sea-orm-codegen/src/entity/writer.rs +++ b/sea-orm-codegen/src/entity/writer.rs @@ -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; @@ -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 }); }