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:
@@ -574,6 +574,10 @@ func TestTypeMapper_SQLTypeToGoType_Bun(t *testing.T) {
|
||||
{"boolean", false, "resolvespec_common.SqlBool"},
|
||||
{"uuid", false, "resolvespec_common.SqlUUID"},
|
||||
{"jsonb", false, "resolvespec_common.SqlJSONB"},
|
||||
{"text[]", true, "resolvespec_common.SqlStringArray"},
|
||||
{"text[]", false, "resolvespec_common.SqlStringArray"},
|
||||
{"integer[]", true, "resolvespec_common.SqlInt32Array"},
|
||||
{"bigint[]", false, "resolvespec_common.SqlInt64Array"},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
@@ -685,6 +689,24 @@ func TestTypeMapper_BuildBunTag(t *testing.T) {
|
||||
},
|
||||
want: []string{"id,", "type:bigserial,", "pk,", "autoincrement,"},
|
||||
},
|
||||
{
|
||||
name: "text array type",
|
||||
column: &models.Column{
|
||||
Name: "tags",
|
||||
Type: "text[]",
|
||||
NotNull: false,
|
||||
},
|
||||
want: []string{"tags,", "type:text[],", "array,"},
|
||||
},
|
||||
{
|
||||
name: "integer array type",
|
||||
column: &models.Column{
|
||||
Name: "scores",
|
||||
Type: "integer[]",
|
||||
NotNull: true,
|
||||
},
|
||||
want: []string{"scores,", "type:integer[],", "array,"},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
||||
Reference in New Issue
Block a user