Skip to content

Commit ec3593d

Browse files
committed
Minor Fixes
1 parent 8e0c0df commit ec3593d

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

my-postgres-macros/src/postgres_struct_ext.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,8 +449,21 @@ impl<'s> PostgresStructPropertyExt<'s> for StructProperty<'s> {
449449
quote::quote!(my_postgres::table_schema::TableColumnType::BigInt)
450450
}
451451
PropertyType::String => {
452-
self.must_not_have_sql_type_attr()?;
453-
quote::quote!(my_postgres::table_schema::TableColumnType::Text)
452+
if let Some(sql_type) = self.try_get_sql_type_attr_value(&["json", "jsonb"])? {
453+
match sql_type {
454+
"json" => {
455+
quote::quote!(my_postgres::table_schema::TableColumnType::Json)
456+
}
457+
"jsonb" => {
458+
quote::quote!(my_postgres::table_schema::TableColumnType::Jsonb)
459+
}
460+
_ => {
461+
panic!("Unsupported sql_type: {}", sql_type);
462+
}
463+
}
464+
} else {
465+
quote::quote!(my_postgres::table_schema::TableColumnType::Text)
466+
}
454467
}
455468
PropertyType::Bool => {
456469
self.must_not_have_sql_type_attr()?;

0 commit comments

Comments
 (0)