Parses a string containing a comma-separated list of identifiers and returns their underlying string values. This is analogous to the `SplitIdentifierString` function in PostgreSQL.
(s: &str)
| 211 | /// |
| 212 | /// This is analogous to the `SplitIdentifierString` function in PostgreSQL. |
| 213 | pub fn split_identifier_string(s: &str) -> Result<Vec<String>, ParserError> { |
| 214 | // SplitIdentifierString ignores leading and trailing whitespace, and |
| 215 | // accepts empty input as a 0-length result. |
| 216 | if s.trim().is_empty() { |
| 217 | Ok(vec![]) |
| 218 | } else { |
| 219 | let tokens = lexer::lex(s)?; |
| 220 | let mut parser = Parser::new(s, tokens); |
| 221 | let values = parser.parse_comma_separated(Parser::parse_set_variable_value)?; |
| 222 | Ok(values |
| 223 | .into_iter() |
| 224 | .map(|v| v.into_unquoted_value()) |
| 225 | .collect()) |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | macro_rules! maybe { |
| 230 | ($e:expr) => {{ |
no test coverage detected