Skip to content

Recognize more paths for String and Vec #299

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions butane/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,3 +466,14 @@ async fn tokio_spawn(conn: ConnectionAsync) {
foo.save(&conn).await.unwrap();
});
}

#[model]
struct TypeVariantsTest {
id: i64,
str1: String,
str2: std::string::String,
str3: ::std::string::String,
blob1: Vec<u8>,
blob2: std::vec::Vec<u8>,
blob3: ::std::vec::Vec<u8>,
}
10 changes: 8 additions & 2 deletions butane_core/src/codegen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,9 +459,15 @@ pub fn get_primitive_sql_type(ty: &syn::Type) -> Option<DeferredSqlType> {
return some_known(SqlType::BigInt);
} else if *ty == parse_quote!(f32) || *ty == parse_quote!(f64) {
return some_known(SqlType::Real);
} else if *ty == parse_quote!(String) {
} else if *ty == parse_quote!(String)
|| *ty == parse_quote!(std::string::String)
|| *ty == parse_quote!(::std::string::String)
{
return some_known(SqlType::Text);
} else if *ty == parse_quote!(Vec<u8>) {
} else if *ty == parse_quote!(Vec<u8>)
|| *ty == parse_quote!(std::vec::Vec<u8>)
|| *ty == parse_quote!(::std::vec::Vec<u8>)
{
return some_known(SqlType::Blob);
}

Expand Down
Loading