Merge pull request #8319 from swordqiu/hotfix/qj-resolve-with-meta-filter-conflict

fix: resolve with_meta filter conflict
This commit is contained in:
yunion-ci-robot
2020-10-16 11:38:32 +08:00
committed by GitHub
2 changed files with 7 additions and 4 deletions
+5 -2
View File
@@ -199,12 +199,15 @@ type MetadataResourceListInput struct {
// 返回资源的标签不包含用户标签
WithoutUserMeta *bool `json:"without_user_meta"`
// 返回资源的标签包含用户标签
// 返回包含用户标签的资源
WithUserMeta *bool `json:"with_user_meta"`
// 返回资源的标签包含外部标签
// 返回包含外部标签的资源
WithCloudMeta *bool `json:"with_cloud_meta"`
// 返回包含任意标签的资源
WithAnyMeta *bool `json:"with_any_meta"`
// 返回列表数据中包含资源的标签数据(Metadata)
WithMeta *bool `json:"with_meta"`
}
+2 -2
View File
@@ -90,10 +90,10 @@ func (meta *SMetadataResourceBaseModelManager) ListItemFilter(
}
}
if input.WithMeta != nil {
if input.WithAnyMeta != nil {
metadatas := Metadata.Query().Equals("obj_type", manager.Keyword()).SubQuery()
sq := metadatas.Query(metadatas.Field("obj_id")).Distinct().SubQuery()
if *input.WithMeta {
if *input.WithAnyMeta {
q = q.Filter(sqlchemy.In(q.Field("id"), sq))
} else {
q = q.Filter(sqlchemy.NotIn(q.Field("id"), sq))