MCPcopy Index your code
hub / github.com/bytebase/bytebase / cleanDefaultExpression

Function cleanDefaultExpression

backend/plugin/db/oracle/sync.go:1321–1345  ·  view source on GitHub ↗

cleanDefaultExpression cleans up Oracle default expressions to make them more portable and fix common syntax issues like schema-qualified sequence NEXTVAL calls

(defaultExpr, currentSchema string)

Source from the content-addressed store, hash-verified

1319// cleanDefaultExpression cleans up Oracle default expressions to make them more portable
1320// and fix common syntax issues like schema-qualified sequence NEXTVAL calls
1321func cleanDefaultExpression(defaultExpr, currentSchema string) string {
1322 if defaultExpr == "" {
1323 return defaultExpr
1324 }
1325
1326 // Remove leading/trailing whitespace
1327 cleaned := strings.TrimSpace(defaultExpr)
1328
1329 // Fix schema-qualified sequence NEXTVAL calls
1330 // Pattern: "SCHEMA"."SEQUENCE_NAME"."NEXTVAL" -> "SEQUENCE_NAME".NEXTVAL
1331 // Keep sequence name quoted for compatibility
1332 if strings.Contains(cleaned, ".\"NEXTVAL\"") {
1333 // Use regex to match quoted schema and sequence names followed by quoted NEXTVAL
1334 re := regexp.MustCompile(`"` + regexp.QuoteMeta(currentSchema) + `"\."([^"]+)"\."NEXTVAL"`)
1335 cleaned = re.ReplaceAllString(cleaned, `"$1".NEXTVAL`)
1336 }
1337
1338 // Also handle unquoted NEXTVAL (less common)
1339 if strings.Contains(cleaned, ".NEXTVAL") {
1340 re := regexp.MustCompile(`"` + regexp.QuoteMeta(currentSchema) + `"\."([^"]+)"\.NEXTVAL`)
1341 cleaned = re.ReplaceAllString(cleaned, `"$1".NEXTVAL`)
1342 }
1343
1344 return cleaned
1345}
1346
1347// getViewComments gets comments for views from Oracle system views
1348func getViewComments(txn *sql.Tx, schemaName string) (map[db.TableKey]string, error) {

Callers 1

getTableColumnsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected