Fix array formatting for SQL
This commit is contained in:
parent
0d9631b6c4
commit
5c8e72a733
@ -79,21 +79,24 @@ where
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn format_array_for_sql<T>(values: &[T]) -> String
|
||||
fn format_array_for_sql<I, T>(values: I) -> String
|
||||
where
|
||||
T: Display
|
||||
I: IntoIterator<Item=T>,
|
||||
T: Display,
|
||||
{
|
||||
match values.len() {
|
||||
1.. => {
|
||||
let mut output = values[0].to_string();
|
||||
for v in &values[1..] {
|
||||
let mut iter = values.into_iter();
|
||||
|
||||
let mut output = match iter.next() {
|
||||
Some(first) => first.to_string(),
|
||||
None => return String::new(),
|
||||
};
|
||||
|
||||
for v in iter {
|
||||
output += ",";
|
||||
output += &v.to_string();
|
||||
}
|
||||
|
||||
output
|
||||
},
|
||||
_ => values.first().map(|v| v.to_string()).unwrap_or(String::new()),
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
Loading…
Reference in New Issue
Block a user