Execute a SQL statement, returning the text of each row's first column.
(&self, sql: &str)
| 9 | impl TestServer { |
| 10 | /// Execute a SQL statement, returning the text of each row's first column. |
| 11 | pub async fn query_text(&self, sql: &str) -> Result<Vec<String>, String> { |
| 12 | let client = self.client.as_ref(); |
| 13 | match client.simple_query(sql).await { |
| 14 | Ok(msgs) => { |
| 15 | let mut rows = Vec::new(); |
| 16 | for msg in msgs { |
| 17 | if let tokio_postgres::SimpleQueryMessage::Row(row) = msg { |
| 18 | rows.push(row.get(0).unwrap_or("").to_string()); |
| 19 | } |
| 20 | } |
| 21 | Ok(rows) |
| 22 | } |
| 23 | Err(e) => Err(pg_error_detail(&e)), |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | /// Execute a SQL statement, returning each row's columns joined by tab. |
| 28 | /// |