fix(dolt): proper server mode support for routing and storage
- FindDatabasePath now handles Dolt server mode (no local dir required) - main.go uses NewFromConfigWithOptions for Dolt to read server settings - Routing uses factory via callback to respect backend configuration - Handle Dolt "database exists" error (error 1007) gracefully Previously, Dolt server mode failed because: 1. FindDatabasePath required a local directory to exist 2. main.go bypassed server mode config when creating Dolt storage 3. Routing always opened SQLite regardless of backend config Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
committed by
Steve Yegge
parent
13c362e67e
commit
e82f5136c1
@@ -312,8 +312,13 @@ func openServerConnection(ctx context.Context, cfg *Config) (*sql.DB, string, er
|
||||
|
||||
_, err = initDB.ExecContext(ctx, fmt.Sprintf("CREATE DATABASE IF NOT EXISTS %s", cfg.Database))
|
||||
if err != nil {
|
||||
_ = db.Close()
|
||||
return nil, "", fmt.Errorf("failed to create database: %w", err)
|
||||
// Dolt may return error 1007 even with IF NOT EXISTS - ignore if database already exists
|
||||
errLower := strings.ToLower(err.Error())
|
||||
if !strings.Contains(errLower, "database exists") && !strings.Contains(errLower, "1007") {
|
||||
_ = db.Close()
|
||||
return nil, "", fmt.Errorf("failed to create database: %w", err)
|
||||
}
|
||||
// Database already exists - that's fine, continue
|
||||
}
|
||||
|
||||
return db, connStr, nil
|
||||
|
||||
Reference in New Issue
Block a user