Closed KyriosGN0 closed 2 months ago
Hey @KyriosGN0! I'm here to help you with any issues, answer questions, and guide you to become a contributor. Let me know how I can assist you!
The customize
plugin does not recognize the array type when creating a new custom field in the issues table because, according to the latest documentation, only the following five types are supported for direct addition to the issues
table:
While the array type is indeed supported, it is handled differently. For array types, a new table called issue_custom_array_fields
is created, which contains issue_id
, field_id
, and value
columns. This table has a one-to-many relationship with the issues
table. Therefore, the array type cannot be directly added as a custom field in the issues
table but is instead managed through this separate table.
For more details, you can refer to the Customize Plugin documentation [1][2][3][4][5].
To continue talking to Dosu, mention @dosu.
@dosu how should i create this field in the issues table ?
To create a custom field of type array in the issues
table, you need to use the issue_custom_array_fields
table instead of directly adding the array type to the issues
table. Here are the steps:
Define the Struct: Create a struct for the custom array field in your codebase. Here is an example in Go:
package ticket
import "github.com/apache/incubator-devlake/core/models/common"
type IssueCustomArrayField struct {
IssueId string `gorm:"primaryKey;type:varchar(255)"`
FieldId string `gorm:"primaryKey;type:varchar(255)"`
FieldValue string `gorm:"primaryKey;type:varchar(255)"`
common.NoPKModel
}
func (IssueCustomArrayField) TableName() string {
return "issue_custom_array_fields"
}
Create the Table: Ensure that the issue_custom_array_fields
table is created in your database. This table will store the custom array fields.
Link the Custom Field to an Issue: Use the issue_id
to link the custom array field to an issue. Here is an example SQL query to join the issues
table with the issue_custom_array_fields
table:
SELECT
issues.id,
issues.title,
issue_custom_array_fields.field_id,
issue_custom_array_fields.field_value
FROM
issues
JOIN
issue_custom_array_fields
ON
issues.id = issue_custom_array_fields.issue_id
WHERE
issue_custom_array_fields.field_id = 'x_product_lines';
Insert Data: Insert the custom array field values into the issue_custom_array_fields
table. Here is an example SQL insert statement:
INSERT INTO issue_custom_array_fields (issue_id, field_id, field_value)
VALUES ('issue_123', 'x_tags', 'tag1'), ('issue_123', 'x_tags', 'tag2');
For more details, you can refer to the Apache DevLake documentation [1][2][3][4].
To continue talking to Dosu, mention @dosu.
Thx!
Search before asking
What happened
when trying to create a new custom field in the issues table, the docs mention that array is a supported type, but in the code it is not the oneof type.
What do you expect to happen
column of type array are created in issues table
How to reproduce
send a POST request https:///api/plugins/customize/issues/fields with a body like this
{ "columnName": "x_tags", "displayName": "Tags", "dataType": "array", "description": "Array of tags from jira" }
Anything else
No response
Version
v1.0.1-beta7@3f84bae
Are you willing to submit PR?
Code of Conduct