fix(pgsql): handle default values for array types in migrations

* update default value quoting logic for PostgreSQL
* add tests for array default value handling
This commit is contained in:
Hein
2026-04-30 18:16:21 +02:00
parent d30fc24f55
commit 0a3966e6fc
6 changed files with 152 additions and 14 deletions

View File

@@ -8,6 +8,7 @@ import (
"text/template"
"git.warky.dev/wdevs/relspecgo/pkg/models"
"git.warky.dev/wdevs/relspecgo/pkg/writers"
)
//go:embed templates/*.tmpl
@@ -495,7 +496,11 @@ func BuildCreateTableData(schemaName string, table *models.Table) CreateTableDat
NotNull: col.NotNull,
}
if col.Default != nil {
colData.Default = fmt.Sprintf("%v", col.Default)
if value, ok := col.Default.(string); ok {
colData.Default = writers.QuoteDefaultValue(value, col.Type)
} else {
colData.Default = fmt.Sprintf("%v", col.Default)
}
}
columns = append(columns, colData)
}