It seems that postgres "regclass" is not convertible to native rust strings.
Triage:
I was trying to fetch an array of columns for a table where primary keys are indexed using the following snippet:
// ... some function above
let table_indexed_attributes_query = r#"
SELECT array_agg(a.attname)
FROM pg_index i
JOIN pg_attribute a ON a.attrelid = i.indrelid AND a.attnum = ANY(i.indkey)
WHERE i.indrelid = $1::regclass
AND i.indisprimary;
"#;
let result_indexed_attributes = client.borrow_mut().query(table_indexed_attributes_query, &[&table_name]).unwrap();
let indexed_attributes = match result_indexed_attributes.get(0) {
Some(indexed_attributes) => {
let data: String = indexed_attributes.get(0);
let indexed_columns = data.split(",")
.map(|s| s.to_string())
.collect();
indexed_columns
}
None => vec![],
};
While running, I am getting the following error:
called `Result::unwrap()` on an `Err` value: Error { kind: ToSql(0), cause: Some(WrongType { postgres: Regclass, rust: "alloc::string::String" }) }
Question:
While I can't convert regclass to String, is there any rust native object I could convert it into? If not, I'd like to help build support for this.
Overview:
It seems that postgres "regclass" is not convertible to native rust strings.
Triage:
I was trying to fetch an array of columns for a table where primary keys are indexed using the following snippet:
While running, I am getting the following error:
Question:
While I can't convert
regclass
toString
, is there any rust native object I could convert it into? If not, I'd like to help build support for this.