MCPcopy Create free account
hub / github.com/bytebase/bytebase / extractAnyValues

Function extractAnyValues

backend/plugin/schema/differ.go:1287–1319  ·  view source on GitHub ↗

extractAnyValues extracts values from "(column = ANY (ARRAY['A'::text, 'B'::text]))" format

(expr string)

Source from the content-addressed store, hash-verified

1285
1286// extractAnyValues extracts values from "(column = ANY (ARRAY['A'::text, 'B'::text]))" format
1287func 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.
1322func comparePartitions(engine storepb.Engine, oldPartitions, newPartitions []*storepb.TablePartitionMetadata) []*PartitionDiff {

Callers 1

compareInVsAnyValuesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected