extractInValues extracts values from "column IN('A', 'B')" format
(expr string)
| 1245 | |
| 1246 | // extractInValues extracts values from "column IN('A', 'B')" format |
| 1247 | func extractInValues(expr string) []string { |
| 1248 | // Find the IN part |
| 1249 | inIndex := strings.Index(expr, " IN") |
| 1250 | if inIndex == -1 { |
| 1251 | return nil |
| 1252 | } |
| 1253 | |
| 1254 | // Find the opening parenthesis |
| 1255 | openParen := strings.Index(expr[inIndex:], "(") |
| 1256 | if openParen == -1 { |
| 1257 | return nil |
| 1258 | } |
| 1259 | openParen += inIndex |
| 1260 | |
| 1261 | // Find the closing parenthesis |
| 1262 | closeParen := strings.LastIndex(expr, ")") |
| 1263 | if closeParen == -1 || closeParen <= openParen { |
| 1264 | return nil |
| 1265 | } |
| 1266 | |
| 1267 | // Extract the values part |
| 1268 | valuesStr := expr[openParen+1 : closeParen] |
| 1269 | |
| 1270 | // Split by comma and clean up |
| 1271 | var values []string |
| 1272 | parts := strings.Split(valuesStr, ",") |
| 1273 | for _, part := range parts { |
| 1274 | part = strings.TrimSpace(part) |
| 1275 | // Remove quotes |
| 1276 | if (part[0] == '\'' && part[len(part)-1] == '\'') || |
| 1277 | (part[0] == '"' && part[len(part)-1] == '"') { |
| 1278 | part = part[1 : len(part)-1] |
| 1279 | } |
| 1280 | values = append(values, part) |
| 1281 | } |
| 1282 | |
| 1283 | return values |
| 1284 | } |
| 1285 | |
| 1286 | // extractAnyValues extracts values from "(column = ANY (ARRAY['A'::text, 'B'::text]))" format |
| 1287 | func extractAnyValues(expr string) []string { |
no outgoing calls
no test coverage detected