fix(type_mapper): handle PostgreSQL array types in tags
* Update BuildBunTag to append "array" for array types * Add tests for handling array types in TypeMapper * Adjust regex in SanitizeStructTagValue to preserve array suffix
This commit is contained in:
@@ -658,6 +658,10 @@ func TestTypeMapper_SQLTypeToGoType(t *testing.T) {
|
||||
{"timestamp", false, "sql_types.SqlTimeStamp"},
|
||||
{"boolean", true, "bool"},
|
||||
{"boolean", false, "sql_types.SqlBool"},
|
||||
{"text[]", true, "sql_types.SqlStringArray"},
|
||||
{"text[]", false, "sql_types.SqlStringArray"},
|
||||
{"integer[]", true, "sql_types.SqlInt32Array"},
|
||||
{"bigint[]", false, "sql_types.SqlInt64Array"},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
@@ -670,6 +674,21 @@ func TestTypeMapper_SQLTypeToGoType(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestTypeMapper_BuildGormTag_ArrayType(t *testing.T) {
|
||||
mapper := NewTypeMapper("")
|
||||
|
||||
col := &models.Column{
|
||||
Name: "tags",
|
||||
Type: "text[]",
|
||||
NotNull: false,
|
||||
}
|
||||
|
||||
tag := mapper.BuildGormTag(col, nil)
|
||||
if !strings.Contains(tag, "type:text[]") {
|
||||
t.Fatalf("expected array type to be preserved, got %q", tag)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTypeMapper_BuildGormTag_PreservesExplicitTypeModifiers(t *testing.T) {
|
||||
mapper := NewTypeMapper("")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user