-
Hi, I want to store values with different types in a vector and then bind it to a query. pub enum Value {
String(String),
Int16(i16),
Bool(bool),
} The problem happens when I'm trying to bind values in query builder: let mut query_builder = sqlx::query_as::<_, Self::Item>(&query);
query_builder.bind(value.clone()); As I had to implement Type for the Enum and it doesn't have &self available in it, so I cant determine which type is inside the Enum to return correct name of the type: impl Type<Postgres> for Value {
fn type_info() -> sqlx::postgres::PgTypeInfo {
sqlx::postgres::PgTypeInfo::with_name("INT")
}
} How I can preserve different types in a vector and then bind it then? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I think I figured it out, I added |
Beta Was this translation helpful? Give feedback.
I think I figured it out, I added
produces
in Encode implementation. Strange that type_info doesnt have access to self..