extractAnyValues extracts values from "(column = ANY (ARRAY['A'::text, 'B'::text]))" format
(expr string)
| 1285 | |
| 1286 | // extractAnyValues extracts values from "(column = ANY (ARRAY['A'::text, 'B'::text]))" format |
| 1287 | func extractAnyValues(expr string) []string { |
| 1288 | // Find the ARRAY part |
| 1289 | arrayIndex := strings.Index(expr, "ARRAY[") |
| 1290 | if arrayIndex == -1 { |
| 1291 | return nil |
| 1292 | } |
| 1293 | |
| 1294 | // Find the closing bracket |
| 1295 | closeBracket := strings.Index(expr[arrayIndex:], "]") |
| 1296 | if closeBracket == -1 { |
| 1297 | return nil |
| 1298 | } |
| 1299 | closeBracket += arrayIndex |
| 1300 | |
| 1301 | // Extract the values part |
| 1302 | valuesStr := expr[arrayIndex+6 : closeBracket] // Skip "ARRAY[" |
| 1303 | |
| 1304 | // Split by comma and clean up |
| 1305 | var values []string |
| 1306 | parts := strings.Split(valuesStr, ",") |
| 1307 | for _, part := range parts { |
| 1308 | part = strings.TrimSpace(part) |
| 1309 | // Remove ::text suffix and quotes |
| 1310 | part = strings.TrimSuffix(part, "::text") |
| 1311 | if (part[0] == '\'' && part[len(part)-1] == '\'') || |
| 1312 | (part[0] == '"' && part[len(part)-1] == '"') { |
| 1313 | part = part[1 : len(part)-1] |
| 1314 | } |
| 1315 | values = append(values, part) |
| 1316 | } |
| 1317 | |
| 1318 | return values |
| 1319 | } |
| 1320 | |
| 1321 | // comparePartitions compares two lists of partitions. |
| 1322 | func comparePartitions(engine storepb.Engine, oldPartitions, newPartitions []*storepb.TablePartitionMetadata) []*PartitionDiff { |
no outgoing calls
no test coverage detected