Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: unify database and project label filter (#17462)
ecmadaoeea5750eebbd
diff --git a/backend/api/v1/database_service.go b/backend/api/v1/database_service.goindex 25a8cb7952..b2e6704f72 100644--- a/backend/api/v1/database_service.go+++ b/backend/api/v1/database_service.go@@ -141,6 +141,25 @@ func getSubConditionFromExpr(expr celast.Expr, getFilter func(expr celast.Expr)return strings.Join(args, fmt.Sprintf(" %s ", join)), nil}+func parseToLabelFilterSQL(resource, key string, value any) (string, error) {+ switch v := value.(type) {+ case string:+ return fmt.Sprintf("%s->'labels'->>'%s' = '%s'", resource, key, v), nil+ case []any:+ if len(v) == 0 {+ return "", connect.NewError(connect.CodeInvalidArgument, errors.Errorf("empty label filter"))+ }++ labelValueList := []string{}+ for _, raw := range v {+ labelValueList = append(labelValueList, fmt.Sprintf(`'%s'`, raw.(string)))+ }+ return fmt.Sprintf("%s->'labels'->>'%s' IN (%s)", resource, key, strings.Join(labelValueList, ",")), nil+ default:+ return "", connect.NewError(connect.CodeInvalidArgument, errors.Errorf("empty value %v for label filter", value))+ }+}+func parseToEngineSQL(expr celast.Expr, relation string) (string, error) {variable, value := getVariableAndValueFromExpr(expr)if variable != "engine" {@@ -225,15 +244,6 @@ func getListDatabaseFilter(filter string) (*store.ListResourceFilter, error) {case "name":positionalArgs = append(positionalArgs, value)return fmt.Sprintf("db.name = $%d", len(positionalArgs)), nil- case "label":- keyVal := strings.Split(value.(string), ":")- if len(keyVal) != 2 {- return "", connect.NewError(connect.CodeInvalidArgument, errors.Errorf(`invalid label filter %q, should be in "{label key}:{label value} format"`, value))- }- labelKey := keyVal[0]- labelValues := strings.Split(keyVal[1], ",")- positionalArgs = append(positionalArgs, labelValues)- return fmt.Sprintf("db.metadata->'labels'->>'%s' = ANY($%d)", labelKey, len(positionalArgs)), nilcase "drifted":drifted, ok := value.(bool)if !ok {@@ -261,6 +271,13 @@ func getListDatabaseFilter(filter string) (*store.ListResourceFilter, error) {)`, len(positionalArgs)), nildefault:+ varStr, ok := variable.(string)+ if !ok {+ return "", connect.NewError(connect.CodeInvalidArgument, errors.Errorf("unsupport variable %q", variable))+ }+ if labelKey, ok := strings.CutPrefix(varStr, "labels."); ok {+ return parseToLabelFilterSQL("db.metadata", labelKey, value)+ }return "", connect.NewError(connect.CodeInvalidArgument, errors.Errorf("unsupport variable %q", variable))}}@@ -303,7 +320,13 @@ func getListDatabaseFilter(filter string) (*store.ListResourceFilter, error) {return "", connect.NewError(connect.CodeInvalidArgument, errors.Errorf(`only "name" or "table" support %q operator, but found %q`, celoverloads.Matches, variable))}case celoperators.In:- return parseToEngineSQL(expr, "IN")+ variable, value := getVariableAndValueFromExpr(expr)+ if variable == "engine" {+ return parseToEngineSQL(expr, "IN")+ } else if labelKey, ok := strings.CutPrefix(variable, "labels."); ok {+ return parseToLabelFilterSQL("db.metadata", labelKey, value)+ }+ return "", connect.NewError(connect.CodeInvalidArgument, errors.Errorf("unsupport variable %q", variable))case celoperators.LogicalNot:args := expr.AsCall().Args()if len(args) != 1 {diff --git a/backend/api/v1/database_service_test.go b/backend/api/v1/database_service_test.goindex 14af28730b..fb6bd14d47 100644--- a/backend/api/v1/database_service_test.go+++ b/backend/api/v1/database_service_test.go@@ -51,17 +51,24 @@ func TestListDatabaseFilter(t *testing.T) {},},{- input: `label == "region:asia" && label == "tenant:bytebase"`,+ input: `labels.region == "asia" && labels.tenant == "bytebase"`,want: &store.ListResourceFilter{- Where: `((db.metadata->'labels'->>'region' = ANY($1)) AND (db.metadata->'labels'->>'tenant' = ANY($2)))`,- Args: []any{"asia", "bytebase"},+ Where: `((db.metadata->'labels'->>'region' = 'asia') AND (db.metadata->'labels'->>'tenant' = 'bytebase'))`,+ Args: []any{},+ },+ },+ {+ input: `(labels.region == "asia" || labels.tenant == "bytebase") && exclude_unassigned == true`,+ want: &store.ListResourceFilter{+ Where: `(((db.metadata->'labels'->>'region' = 'asia') OR (db.metadata->'labels'->>'tenant' = 'bytebase')) AND (db.project != $1))`,+ Args: []any{common.DefaultProjectID},},},{- input: `(label == "region:asia" || label == "tenant:bytebase") && exclude_unassigned == true`,+ input: `labels.region in ["asia", "europe"] && labels.tenant == "bytebase"`,want: &store.ListResourceFilter{- Where: `(((db.metadata->'labels'->>'region' = ANY($1)) OR (db.metadata->'labels'->>'tenant' = ANY($2))) AND (db.project != $3))`,- Args: []any{"asia", "bytebase", common.DefaultProjectID},+ Where: `((db.metadata->'labels'->>'region' IN ('asia','europe')) AND (db.metadata->'labels'->>'tenant' = 'bytebase'))`,+ Args: []any{},},},}diff --git a/backend/api/v1/project_service.go b/backend/api/v1/project_service.goindex b8c69c3998..ccbce4331b 100644--- a/backend/api/v1/project_service.go+++ b/backend/api/v1/project_service.go@@ -155,16 +155,8 @@ func getListProjectFilter(filter string) (*store.ListResourceFilter, error) {if !ok {return "", connect.NewError(connect.CodeInvalidArgument, errors.Errorf("unsupport variable %q", variable))}- if strings.HasPrefix(varStr, "labels.") {- labelKey := strings.TrimPrefix(varStr, "labels.")- labelValueStr, ok := value.(string)- if !ok {- return "", connect.NewError(connect.CodeInvalidArgument, errors.Errorf("label value must be a string, got %T", value))- }- // Use JSONB containment operator to check if the label exists with the specified value- // The setting column contains a proto message with a labels field- positionalArgs = append(positionalArgs, fmt.Sprintf(`{"%s":"%s"}`, labelKey, labelValueStr))- return fmt.Sprintf("project.setting->'labels' @> $%d::jsonb", len(positionalArgs)), nil+ if labelKey, ok := strings.CutPrefix(varStr, "labels."); ok {+ return parseToLabelFilterSQL("project.setting", labelKey, value)}return "", connect.NewError(connect.CodeInvalidArgument, errors.Errorf("unsupport variable %q", variable))}@@ -202,6 +194,12 @@ func getListProjectFilter(filter string) (*store.ListResourceFilter, error) {default:return "", connect.NewError(connect.CodeInvalidArgument, errors.Errorf("unsupport variable %q", variable))}+ case celoperators.In:+ variable, value := getVariableAndValueFromExpr(expr)+ if labelKey, ok := strings.CutPrefix(variable, "labels."); ok {+ return parseToLabelFilterSQL("project.setting", labelKey, value)+ }+ return "", connect.NewError(connect.CodeInvalidArgument, errors.Errorf("unexpected %v operator for %v", functionName, variable))default:return "", connect.NewError(connect.CodeInvalidArgument, errors.Errorf("unexpected function %v", functionName))}diff --git a/backend/api/v1/setting_service.go b/backend/api/v1/setting_service.goindex b5bd0433d4..9c2e8fe3f2 100644--- a/backend/api/v1/setting_service.go+++ b/backend/api/v1/setting_service.go@@ -458,9 +458,6 @@ func (s *SettingService) UpdateSetting(ctx context.Context, request *connect.Req}storeSettingValue = string(bytes)case storepb.SettingName_AI:- if s.profile.SaaS {- return nil, connect.NewError(connect.CodeFailedPrecondition, errors.Errorf("cannot change ai setting in the saas mode"))- }aiSetting := convertAISetting(request.Msg.Setting.Value.GetAiSetting())if aiSetting.Enabled {if aiSetting.Endpoint == "" || aiSetting.Model == "" {diff --git a/backend/component/config/profile.go b/backend/component/config/profile.goindex 80daae6a38..b80aa09cb7 100644--- a/backend/component/config/profile.go+++ b/backend/component/config/profile.go@@ -62,6 +62,7 @@ func (prof *Profile) UseEmbedDB() bool {var saasFeatureControlMap = map[string]bool{storepb.SettingName_WORKSPACE_ID.String(): true,+ storepb.SettingName_AI.String(): true,}// IsFeatureUnavailable returns if the feature is unavailable in SaaS mode.diff --git a/backend/generated-go/v1/database_service.pb.go b/backend/generated-go/v1/database_service.pb.goindex 9c901fe3d0..170c66bddd 100644--- a/backend/generated-go/v1/database_service.pb.go+++ b/backend/generated-go/v1/database_service.pb.go@@ -745,10 +745,10 @@ type ListDatabasesRequest struct {// - project: the project full name in "projects/{id}" format, support "==" operator.// - instance: the instance full name in "instances/{id}" format, support "==" operator.// - engine: the database engine, check Engine enum for values. Support "==", "in [xx]", "!(in [xx])" operator.- // - label: the database label in "{key}:{value1},{value2}" format. Support "==" operator.// - exclude_unassigned: should be "true" or "false", will not show unassigned databases if it's true, support "==" operator.// - drifted: should be "true" or "false", show drifted databases if it's true, support "==" operator.// - table: filter by the database table, support "==" and ".matches()" operator.+ // - labels.{key}: the database label, support "==" and "in" operators.//// For example:// environment == "environments/{environment resource id}"@@ -759,13 +759,13 @@ type ListDatabasesRequest struct {// engine == "MYSQL"// engine in ["MYSQL", "POSTGRES"]// !(engine in ["MYSQL", "POSTGRES"])- // label == "region:asia"- // label == "tenant:asia,europe"- // label == "region:asia" && label == "tenant:bytebase"// exclude_unassigned == true// drifted == true// table == "sample"// table.matches("sam")+ // labels.environment == "production"+ // labels.region == "asia"+ // labels.region in ["asia", "europe"]//// You can combine filter conditions like:// environment == "environments/prod" && name.matches("employee")diff --git a/backend/generated-go/v1/project_service.pb.go b/backend/generated-go/v1/project_service.pb.goindex 84d7a5c2cd..4951d0f575 100644--- a/backend/generated-go/v1/project_service.pb.go+++ b/backend/generated-go/v1/project_service.pb.go@@ -234,6 +234,7 @@ type ListProjectsRequest struct {ShowDeleted bool `protobuf:"varint,3,opt,name=show_deleted,json=showDeleted,proto3" json:"show_deleted,omitempty"`// Filter the project.// Check filter for SearchProjectsRequest for details.+ // Supports filtering by name, resource_id, state, and labels (e.g., labels.environment == "production").Filter string `protobuf:"bytes,4,opt,name=filter,proto3" json:"filter,omitempty"`unknownFields protoimpl.UnknownFieldssizeCache protoimpl.SizeCache@@ -364,6 +365,7 @@ type SearchProjectsRequest struct {// - resource_id: the project id, support "==" and ".matches()" operator.// - exclude_default: if not include the default project, should be "true" or "false", support "==" operator.// - state: check the State enum for the values, support "==" operator.+ // - labels.{key}: the project label, support "==" and "in" operators.//// For example:// name = "project name"@@ -372,9 +374,13 @@ type SearchProjectsRequest struct {// resource_id.matches("project id")// exclude_default == true// state == "DELETED"+ // labels.environment == "production"+ // labels.tier == "critical"+ // labels.environment in ["staging", "prod"]// You can combine filter conditions like:// name = "project name" && resource_id.matches("project id")// name.matches("project name") || resource_id = "project id"+ // labels.environment == "production" && labels.tier == "critical"Filter string `protobuf:"bytes,2,opt,name=filter,proto3" json:"filter,omitempty"`// The maximum number of projects to return. The service may return fewer than// this value.diff --git a/frontend/src/components/AdvancedSearch/useCommonSearchScopeOptions.ts b/frontend/src/components/AdvancedSearch/useCommonSearchScopeOptions.tsindex f5d6b4dbf1..1b77b8c571 100644--- a/frontend/src/components/AdvancedSearch/useCommonSearchScopeOptions.ts+++ b/frontend/src/components/AdvancedSearch/useCommonSearchScopeOptions.ts@@ -159,15 +159,6 @@ export const useCommonSearchScopeOptions = (description: t("issue.advanced-search.scope.label.description"),allowMultiple: true,}),- "database-label": () => ({- id: "database-label",- title: t("issue.advanced-search.scope.database-label.title"),- description: t(- "issue.advanced-search.scope.database-label.description"- ),- allowMultiple: true,- deprecated: true, // Show deprecation notice- }),table: () => ({id: "table",title: t("issue.advanced-search.scope.table.title"),diff --git a/frontend/src/components/GrantRequestPanel/DatabaseResourceForm/DatabaseResourceSelector.vue b/frontend/src/components/GrantRequestPanel/DatabaseResourceForm/DatabaseResourceSelector.vueindex 72c67829a6..8812a3c172 100644--- a/frontend/src/components/GrantRequestPanel/DatabaseResourceForm/DatabaseResourceSelector.vue+++ b/frontend/src/components/GrantRequestPanel/DatabaseResourceForm/DatabaseResourceSelector.vue@@ -88,7 +88,6 @@ const scopeOptions = useCommonSearchScopeOptions([...CommonFilterScopeIdList,"project","label",- "database-label", // Keep for backward compatibility"engine","table",]);@@ -227,7 +226,7 @@ const filterTableList = computed(() => {const selectedLabels = computed(() => {return params.value.scopes- .filter((scope) => scope.id === "label" || scope.id === "database-label")+ .filter((scope) => scope.id === "label").map((scope) => scope.value);});diff --git a/frontend/src/components/IssueV1/components/IssueSearch/useIssueSearchScopeOptions.ts b/frontend/src/components/IssueV1/components/IssueSearch/useIssueSearchScopeOptions.tsindex b59b959fed..ba7a155d04 100644--- a/frontend/src/components/IssueV1/components/IssueSearch/useIssueSearchScopeOptions.ts+++ b/frontend/src/components/IssueV1/components/IssueSearch/useIssueSearchScopeOptions.ts@@ -251,8 +251,8 @@ export const useIssueSearchScopeOptions = (},{id: "issue-label",- title: t("issue.advanced-search.scope.label.title"),- description: t("issue.advanced-search.scope.label.description"),+ title: t("issue.advanced-search.scope.issue-label.title"),+ description: t("issue.advanced-search.scope.issue-label.description"),options: projectLabels.value.map((label) => {return {value: label.value,diff --git a/frontend/src/components/Project/ProjectSwitch/ProjectSwitchContent.vue b/frontend/src/components/Project/ProjectSwitch/ProjectSwitchContent.vueindex 58a04e9e17..c29df24dea 100644--- a/frontend/src/components/Project/ProjectSwitch/ProjectSwitchContent.vue+++ b/frontend/src/components/Project/ProjectSwitch/ProjectSwitchContent.vue@@ -17,7 +17,7 @@<div class="flex flex-row justify-end items-center gap-x-2"><SearchBoxv-model:value="state.searchText"- :placeholder="$t('common.search-by-name')"+ :placeholder="$t('common.filter-by-name')":autofocus="false"class="!w-40"size="small"diff --git a/frontend/src/components/Project/Settings/ProjectGeneralSettingPanel.vue b/frontend/src/components/Project/Settings/ProjectGeneralSettingPanel.vueindex eb31e3d1a0..37f367a412 100644--- a/frontend/src/components/Project/Settings/ProjectGeneralSettingPanel.vue+++ b/frontend/src/components/Project/Settings/ProjectGeneralSettingPanel.vue@@ -75,14 +75,14 @@ const state = reactive<LocalState>({// Convert labels to KVList format for LabelListEditorconst labelKVList = ref(- convertLabelsToKVList(props.project.labels || {}, true /* sort */)+ convertLabelsToKVList(props.project.labels, true /* sort */));// Watch for external changes to project labelswatch(() => props.project.labels,(newLabels) => {- labelKVList.value = convertLabelsToKVList(newLabels || {}, true /* sort */);+ labelKVList.value = convertLabelsToKVList(newLabels, true /* sort */);});@@ -129,7 +129,7 @@ defineExpose({revert: () => {state.title = props.project.title;labelKVList.value = convertLabelsToKVList(- props.project.labels || {},+ props.project.labels,true /* sort */);},diff --git a/frontend/src/components/ProjectDatabasesPanel.vue b/frontend/src/components/ProjectDatabasesPanel.vueindex 47b0357fd2..0442cd6e31 100644--- a/frontend/src/components/ProjectDatabasesPanel.vue+++ b/frontend/src/components/ProjectDatabasesPanel.vue@@ -124,7 +124,6 @@ const allowToCreateDB = computed(() => {const scopeOptions = useCommonSearchScopeOptions([...CommonFilterScopeIdList,"label",- "database-label", // Keep for backward compatibility"engine","drifted",]);@@ -151,7 +150,7 @@ const selectedEnvironment = computed(() => {const selectedLabels = computed(() => {return state.params.scopes- .filter((scope) => scope.id === "label" || scope.id === "database-label")+ .filter((scope) => scope.id === "label").map((scope) => scope.value);});diff --git a/frontend/src/components/v2/Model/ProjectV1Table.vue b/frontend/src/components/v2/Model/ProjectV1Table.vueindex 575e2fb077..85ecaa683e 100644--- a/frontend/src/components/v2/Model/ProjectV1Table.vue+++ b/frontend/src/components/v2/Model/ProjectV1Table.vue@@ -130,6 +130,7 @@ const columnList = computed((): ProjectDataTableColumn[] => {},{key: "title",+ resizable: true,title: t("project.table.name"),render: (project) => (<ProjectNameCell@@ -142,15 +143,11 @@ const columnList = computed((): ProjectDataTableColumn[] => {{key: "labels",title: t("common.labels"),+ resizable: true,width: 300,- ellipsis: true,hide: !props.showLabels,render: (project) => (- <LabelsCell- labels={project.labels || {}}- showCount={3}- placeholder=""- />+ <LabelsCell labels={project.labels} showCount={3} placeholder="-" />),},] as ProjectDataTableColumn[]diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex f929b02fb6..caa18e0f69 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -204,8 +204,6 @@"info": "Info","minutes": "Minutes","filter-by-name": "Filter by name",- "filter-by-name-or-label": "Filter by name or label (e.g., labels.environment == \"production\")",- "search-by-name": "Search by name","license": "License","view-details": "View details","force-verb": "Force {verb}",@@ -916,8 +914,8 @@"description": "Search by the issue approval status","title": "Approval Status"},- "label": {- "title": "Label",+ "issue-label": {+ "title": "Issue label","description": "Filter by issue label"},"table": {@@ -925,11 +923,6 @@"description": "Input the value then press Enter"},"label": {- "title": "Label",- "description": "Input the \"key:value\" pair then press Enter"- },- "database-label": {- "title": "Database Label (Deprecated - use Label)","description": "Input the \"key:value\" pair then press Enter"},"engine": {@@ -1738,6 +1731,7 @@}},"project": {+ "filter-projects": "Filter projects","table": {"name": "@:common.name"},@@ -2355,7 +2349,6 @@"delete": "Delete SQL review policy","input-then-press-enter": "Input the value then press enter to add","not-available-for-free": "Rule is not available for {plan}",- "search-by-name": "Search by name","attach-resource": {"no-linked-resources": "No attached resources","change-resources": "Change attached resources",diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex 8d156e5395..3a899901c8 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -204,8 +204,6 @@"info": "Información","minutes": "Minutos","filter-by-name": "Filtrar por nombre",- "filter-by-name-or-label": "Filtrar por nombre o etiqueta (ej: labels.environment == \"production\")",- "search-by-name": "Buscar por nombre","license": "Licencia","view-details": "Ver detalles","force-verb": "forzar {verbo}",@@ -916,17 +914,16 @@"description": "Buscar por estado de revisión del problema","title": "Estado de aprobación"},- "label": {- "title": "Etiqueta",+ "issue-label": {+ "title": "Etiqueta de emisión","description": "Filtrar por etiqueta de problema"},"table": {"title": "Mesa","description": "Ingrese el valor y luego presione Enter"},- "database-label": {- "title": "Etiqueta de base de datos",- "description": "Ingrese la \"key:value\" y luego presione Enter"+ "label": {+ "description": "Ingrese el par \"clave:valor\" y luego presione Enter"},"engine": {"title": "Motor",@@ -1734,6 +1731,7 @@}},"project": {+ "filter-projects": "Filtrar proyectos","table": {"name": "@:common.name"},@@ -2351,7 +2349,6 @@"delete": "Eliminar política de revisión SQL","input-then-press-enter": "Ingrese el valor y luego presione enter para agregar","not-available-for-free": "La regla no está disponible para {plan}",- "search-by-name": "Buscar por nombre","attach-resource": {"no-linked-resources": "Sin recursos adjuntos","change-resources": "Cambiar recursos adjuntos",diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.jsonindex 400f434f1c..a24524a030 100644--- a/frontend/src/locales/ja-JP.json+++ b/frontend/src/locales/ja-JP.json@@ -204,8 +204,6 @@"info": "情報","minutes": "分","filter-by-name": "名前でフィルタリングする",- "filter-by-name-or-label": "名前またはラベルでフィルタリング (例: labels.environment == \"production\")",- "search-by-name": "名前で検索","license": "ライセンス","view-details": "詳細を確認する","force-verb": "フォース{verb}",@@ -916,17 +914,16 @@"description": "イシューの承認ステータスで検索する","title": "承認状況"},- "label": {- "title": "ラベル",- "description": "イシュータグで絞り込む"+ "issue-label": {+ "title": "問題ラベル",+ "description": "問題ラベルでフィルタリング"},"table": {"title": "テーブル","description": "値を入力してEnterを押します"},- "database-label": {- "title": "データベースラベル",- "description": "\"key:value\"を入力し、Enterを押します。"+ "label": {+ "description": "「キー:値」のペアを入力し、Enterを押します"},"engine": {"title": "エンジン",@@ -1734,6 +1731,7 @@}},"project": {+ "filter-projects": "プロジェクトをフィルタリング","table": {"name": "@:common.name"},@@ -2351,7 +2349,6 @@"delete": "監査ポリシーの削除","input-then-press-enter": "入力後、Enterを押して追加します","not-available-for-free": "{plan}定期購入ではこのルールを使用できません",- "search-by-name": "名前で検索","attach-resource": {"no-linked-resources": "リソースのバインドはありません","change-resources": "バインドされたリソースを変更する",diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.jsonindex 9661f87774..0dce9815ee 100644--- a/frontend/src/locales/vi-VN.json+++ b/frontend/src/locales/vi-VN.json@@ -204,8 +204,6 @@"info": "Thông tin","minutes": "Phút","filter-by-name": "Lọc theo tên",- "filter-by-name-or-label": "Lọc theo tên hoặc nhãn (ví dụ: labels.environment == \"production\")",- "search-by-name": "Tìm kiếm theo tên","license": "Giấy phép","view-details": "Xem chi tiết","force-verb": "Buộc {verb}",@@ -916,17 +914,16 @@"description": "Tìm kiếm theo trạng thái phê duyệt của vấn đề","title": "Trạng thái phê duyệt"},- "label": {- "title": "Nhãn",+ "issue-label": {+ "title": "Nhãn vấn đề","description": "Lọc theo nhãn vấn đề"},"table": {"title": "bề mặt","description": "Nhập giá trị sau đó nhấn Enter"},- "database-label": {- "title": "Nhãn cơ sở dữ liệu",- "description": "Nhập \"key:value\" rồi nhấn Enter"+ "label": {+ "description": "Nhập cặp \"key:value\" rồi nhấn Enter"},"engine": {"title": "Động cơ",@@ -1734,6 +1731,7 @@}},"project": {+ "filter-projects": "Lọc dự án","table": {"name": "@:common.name"},@@ -2351,7 +2349,6 @@"delete": "Xóa chính sách đánh giá SQL","input-then-press-enter": "Nhập giá trị sau đó nhấn enter để thêm","not-available-for-free": "Quy tắc không khả dụng cho {plan}",- "search-by-name": "Tìm kiếm theo tên","attach-resource": {"no-linked-resources": "Không có tài nguyên nào được đính kèm","change-resources": "Thay đổi tài nguyên đính kèm",diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex 5bdf0d9592..36dacaf034 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -204,8 +204,6 @@"info": "信息","minutes": "分钟","filter-by-name": "按名称过滤",- "filter-by-name-or-label": "按名称或标签过滤 (例如: labels.environment == \"production\")",- "search-by-name": "按名称搜索","license": "证书","view-details": "查看详情","force-verb": "强制{verb}",@@ -916,16 +914,15 @@"description": "按工单的审批状态搜索","title": "审批状态"},- "label": {- "title": "标签",+ "issue-label": {+ "title": "工单标签","description": "按工单标签过滤"},"table": {"title": "表","description": "输入值然后按 Enter"},- "database-label": {- "title": "数据库标签",+ "label": {"description": "输入 \"key:value\" 后按下回车"},"engine": {@@ -1734,6 +1731,7 @@}},"project": {+ "filter-projects": "过滤项目","table": {"name": "@:common.name"},@@ -2351,7 +2349,6 @@"delete": "删除审核策略","input-then-press-enter": "输入后按下回车来添加","not-available-for-free": "{plan}订阅不能使用该规则",- "search-by-name": "按名称搜索","attach-resource": {"no-linked-resources": "没有绑定的资源","change-resources": "更改绑定的资源",diff --git a/frontend/src/store/modules/v1/database.ts b/frontend/src/store/modules/v1/database.tsindex a61407b7e0..5abcb4f7c4 100644--- a/frontend/src/store/modules/v1/database.ts+++ b/frontend/src/store/modules/v1/database.ts@@ -71,6 +71,39 @@ const isValidParentName = (parent: string): boolean => {return false;};+// getLabelFilter convert the input to API label filter format like: labels.{key} == {value}+// the input label should be "{label key}:{value1},{value2}" format+export const getLabelFilter = (labels: string[]): string[] => {+ const labelMap = new Map<string, string[]>(); // key: value[]+ for (const label of labels) {+ const sections = label.split(":");+ if (sections.length !== 2) {+ continue;+ }+ const [key, rawValue] = sections;+ const values = rawValue.split(",");+ if (!labelMap.has(key)) {+ labelMap.set(key, []);+ }+ labelMap.get(key)?.push(...values);+ }++ return [...labelMap.entries()].reduce((result, [key, values]) => {+ switch (values.length) {+ case 0:+ return result;+ case 1:+ result.push(`labels.${key} == "${values[0]}"`);+ return result;+ default:+ result.push(+ `labels.${key} in [${values.map((v) => `"${v}"`).join(", ")}]`+ );+ return result;+ }+ }, [] as string[]);+};+const getListDatabaseFilter = (filter: DatabaseFilter): string => {const params: string[] = [];if (isValidProjectName(filter.project)) {@@ -107,24 +140,11 @@ const getListDatabaseFilter = (filter: DatabaseFilter): string => {if (keyword) {params.push(`name.matches("${keyword}")`);}+if (filter.labels) {- // label filter like:- // label == "region:asia,europe" && label == "tenant:bytebase"- const labelMap = new Map<string, Set<string>>();- for (const label of filter.labels) {- const sections = label.split(":");- if (sections.length !== 2) {- continue;- }- if (!labelMap.has(sections[0])) {- labelMap.set(sections[0], new Set());- }- labelMap.get(sections[0])!.add(sections[1]);- }- for (const [labelKey, labelValues] of labelMap.entries()) {- params.push(`label == "${labelKey}:${[...labelValues].join(",")}"`);- }+ params.push(...getLabelFilter(filter.labels));}+if (filter.table) {params.push(`table.matches("${filter.table}")`);}diff --git a/frontend/src/store/modules/v1/project.ts b/frontend/src/store/modules/v1/project.tsindex a7010fa160..81edc35752 100644--- a/frontend/src/store/modules/v1/project.ts+++ b/frontend/src/store/modules/v1/project.ts@@ -30,6 +30,7 @@ import {} from "@/types/proto-es/v1/project_service_pb";import { hasWorkspacePermissionV2 } from "@/utils";import { projectNamePrefix } from "./common";+import { getLabelFilter } from "./database";import { useProjectIamPolicyStore } from "./projectIamPolicy";export interface ProjectFilter {@@ -52,17 +53,8 @@ const getListProjectFilter = (params: ProjectFilter) => {);}- // Handle label filters from structured labels array- if (params.labels && params.labels.length > 0) {- // label filter like: labels.environment == "production" && labels.tier == "critical"- for (const label of params.labels) {- const sections = label.split(":");- if (sections.length !== 2) {- continue;- }- const [key, value] = sections;- list.push(`labels.${key} == "${value}"`);- }+ if (params.labels) {+ list.push(...getLabelFilter(params.labels));}if (params.excludeDefault) {diff --git a/frontend/src/types/proto-es/v1/database_service_pb.d.ts b/frontend/src/types/proto-es/v1/database_service_pb.d.tsindex 7e8ee17367..467cf65afb 100644--- a/frontend/src/types/proto-es/v1/database_service_pb.d.ts+++ b/frontend/src/types/proto-es/v1/database_service_pb.d.ts@@ -122,10 +122,10 @@ export declare type ListDatabasesRequest = Message<"bytebase.v1.ListDatabasesReq* - project: the project full name in "projects/{id}" format, support "==" operator.* - instance: the instance full name in "instances/{id}" format, support "==" operator.* - engine: the database engine, check Engine enum for values. Support "==", "in [xx]", "!(in [xx])" operator.- * - label: the database label in "{key}:{value1},{value2}" format. Support "==" operator.* - exclude_unassigned: should be "true" or "false", will not show unassigned databases if it's true, support "==" operator.* - drifted: should be "true" or "false", show drifted databases if it's true, support "==" operator.* - table: filter by the database table, support "==" and ".matches()" operator.+ * - labels.{key}: the database label, support "==" and "in" operators.** For example:* environment == "environments/{environment resource id}"@@ -136,13 +136,13 @@ export declare type ListDatabasesRequest = Message<"bytebase.v1.ListDatabasesReq* engine == "MYSQL"* engine in ["MYSQL", "POSTGRES"]* !(engine in ["MYSQL", "POSTGRES"])- * label == "region:asia"- * label == "tenant:asia,europe"- * label == "region:asia" && label == "tenant:bytebase"* exclude_unassigned == true* drifted == true* table == "sample"* table.matches("sam")+ * labels.environment == "production"+ * labels.region == "asia"+ * labels.region in ["asia", "europe"]** You can combine filter conditions like:* environment == "environments/prod" && name.matches("employee")diff --git a/frontend/src/types/proto-es/v1/project_service_pb.d.ts b/frontend/src/types/proto-es/v1/project_service_pb.d.tsindex 9753eb9397..bf99648ff1 100644--- a/frontend/src/types/proto-es/v1/project_service_pb.d.ts+++ b/frontend/src/types/proto-es/v1/project_service_pb.d.ts@@ -67,6 +67,7 @@ export declare type ListProjectsRequest = Message<"bytebase.v1.ListProjectsReque/*** Filter the project.* Check filter for SearchProjectsRequest for details.+ * Supports filtering by name, resource_id, state, and labels (e.g., labels.environment == "production").** @generated from field: string filter = 4;*/@@ -125,6 +126,7 @@ export declare type SearchProjectsRequest = Message<"bytebase.v1.SearchProjectsR* - resource_id: the project id, support "==" and ".matches()" operator.* - exclude_default: if not include the default project, should be "true" or "false", support "==" operator.* - state: check the State enum for the values, support "==" operator.+ * - labels.{key}: the project label, support "==" and "in" operators.** For example:* name = "project name"@@ -133,9 +135,13 @@ export declare type SearchProjectsRequest = Message<"bytebase.v1.SearchProjectsR* resource_id.matches("project id")* exclude_default == true* state == "DELETED"+ * labels.environment == "production"+ * labels.tier == "critical"+ * labels.environment in ["staging", "prod"]* You can combine filter conditions like:* name = "project name" && resource_id.matches("project id")* name.matches("project name") || resource_id = "project id"+ * labels.environment == "production" && labels.tier == "critical"** @generated from field: string filter = 2;*/diff --git a/frontend/src/utils/v1/advanced-search/common.ts b/frontend/src/utils/v1/advanced-search/common.tsindex 804272d055..d860e87d15 100644--- a/frontend/src/utils/v1/advanced-search/common.ts+++ b/frontend/src/utils/v1/advanced-search/common.ts@@ -28,7 +28,6 @@ export const AllSearchScopeIdList = ["label",// database related search scopes."engine",- "database-label", // Deprecated: use "label" instead"drifted","table",// issue related search scopes.diff --git a/frontend/src/views/DatabaseDashboard.vue b/frontend/src/views/DatabaseDashboard.vueindex ce830962f4..eb230f04e7 100644--- a/frontend/src/views/DatabaseDashboard.vue+++ b/frontend/src/views/DatabaseDashboard.vue@@ -123,13 +123,12 @@ const scopeOptions = useCommonSearchScopeOptions([...CommonFilterScopeIdList,"project","label",- "database-label", // Keep for backward compatibility"engine",]);const selectedLabels = computed(() => {return state.params.scopes- .filter((scope) => scope.id === "label" || scope.id === "database-label")+ .filter((scope) => scope.id === "label").map((scope) => scope.value);});diff --git a/frontend/src/views/InstanceDetail.vue b/frontend/src/views/InstanceDetail.vueindex 93a7ab8ba3..23339c8f18 100644--- a/frontend/src/views/InstanceDetail.vue+++ b/frontend/src/views/InstanceDetail.vue@@ -195,7 +195,6 @@ const scopeOptions = useCommonSearchScopeOptions([...CommonFilterScopeIdList,"project","label",- "database-label", // Keep for backward compatibility]);watch(@@ -256,7 +255,7 @@ const selectedProject = computed(() => {const selectedLabels = computed(() => {return state.params.scopes- .filter((scope) => scope.id === "label" || scope.id === "database-label")+ .filter((scope) => scope.id === "label").map((scope) => scope.value);});diff --git a/frontend/src/views/ProjectDashboard.vue b/frontend/src/views/ProjectDashboard.vueindex 528a3e56d6..fa190581b7 100644--- a/frontend/src/views/ProjectDashboard.vue+++ b/frontend/src/views/ProjectDashboard.vue@@ -5,7 +5,7 @@v-model:params="state.params":scope-options="scopeOptions":autofocus="false"- :placeholder="$t('common.filter-by-name-or-label')"+ :placeholder="$t('project.filter-projects')"/><NButtonv-if="hasWorkspacePermissionV2('bb.projects.create')"diff --git a/frontend/src/views/SettingWorkspaceSQLReview.vue b/frontend/src/views/SettingWorkspaceSQLReview.vueindex 8dbf48fd0a..3f527b0866 100644--- a/frontend/src/views/SettingWorkspaceSQLReview.vue+++ b/frontend/src/views/SettingWorkspaceSQLReview.vue@@ -17,7 +17,7 @@v-model:value="searchText"style="max-width: 100%":autofocus="true"- :placeholder="$t('sql-review.search-by-name')"+ :placeholder="$t('common.filter-by-name')"/><NButtonv-if="hasCreatePolicyPermission"diff --git a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/ConnectionPane.vue b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/ConnectionPane.vueindex 5bcecbd1d0..9de6877cc9 100644--- a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/ConnectionPane.vue+++ b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/ConnectionPane.vue@@ -420,7 +420,6 @@ const handleUncheckDatabaseGroup = (databaseGroupName: string) => {const scopeOptions = useCommonSearchScopeOptions([...CommonFilterScopeIdList.filter((scope) => scope !== "environment"),"label",- "database-label", // Keep for backward compatibility"engine",]);@@ -617,7 +616,7 @@ useEmitteryEventListener(editorEvents, "tree-ready", async () => {const selectedLabels = computed(() => {return state.params.scopes- .filter((scope) => scope.id === "label" || scope.id === "database-label")+ .filter((scope) => scope.id === "label").map((scope) => scope.value);});diff --git a/proto/gen/grpc-doc/openapi.yaml b/proto/gen/grpc-doc/openapi.yamlindex b5795026b4..9bff0be591 100644--- a/proto/gen/grpc-doc/openapi.yaml+++ b/proto/gen/grpc-doc/openapi.yaml@@ -1210,10 +1210,10 @@ paths:- project: the project full name in "projects/{id}" format, support "==" operator.- instance: the instance full name in "instances/{id}" format, support "==" operator.- engine: the database engine, check Engine enum for values. Support "==", "in [xx]", "!(in [xx])" operator.- - label: the database label in "{key}:{value1},{value2}" format. Support "==" operator.- exclude_unassigned: should be "true" or "false", will not show unassigned databases if it's true, support "==" operator.- drifted: should be "true" or "false", show drifted databases if it's true, support "==" operator.- table: filter by the database table, support "==" and ".matches()" operator.+ - labels.{key}: the database label, support "==" and "in" operators.For example:environment == "environments/{environment resource id}"@@ -1224,13 +1224,13 @@ paths:engine == "MYSQL"engine in ["MYSQL", "POSTGRES"]!(engine in ["MYSQL", "POSTGRES"])- label == "region:asia"- label == "tenant:asia,europe"- label == "region:asia" && label == "tenant:bytebase"exclude_unassigned == truedrifted == truetable == "sample"table.matches("sam")+ labels.environment == "production"+ labels.region == "asia"+ labels.region in ["asia", "europe"]You can combine filter conditions like:environment == "environments/prod" && name.matches("employee")@@ -3297,6 +3297,7 @@ paths:description: |-Filter the project.Check filter for SearchProjectsRequest for details.+ Supports filtering by name, resource_id, state, and labels (e.g., labels.environment == "production").schema:type: stringresponses:@@ -3992,10 +3993,10 @@ paths:- project: the project full name in "projects/{id}" format, support "==" operator.- instance: the instance full name in "instances/{id}" format, support "==" operator.- engine: the database engine, check Engine enum for values. Support "==", "in [xx]", "!(in [xx])" operator.- - label: the database label in "{key}:{value1},{value2}" format. Support "==" operator.- exclude_unassigned: should be "true" or "false", will not show unassigned databases if it's true, support "==" operator.- drifted: should be "true" or "false", show drifted databases if it's true, support "==" operator.- table: filter by the database table, support "==" and ".matches()" operator.+ - labels.{key}: the database label, support "==" and "in" operators.For example:environment == "environments/{environment resource id}"@@ -4006,13 +4007,13 @@ paths:engine == "MYSQL"engine in ["MYSQL", "POSTGRES"]!(engine in ["MYSQL", "POSTGRES"])- label == "region:asia"- label == "tenant:asia,europe"- label == "region:asia" && label == "tenant:bytebase"exclude_unassigned == truedrifted == truetable == "sample"table.matches("sam")+ labels.environment == "production"+ labels.region == "asia"+ labels.region in ["asia", "europe"]You can combine filter conditions like:environment == "environments/prod" && name.matches("employee")@@ -7927,10 +7928,10 @@ paths:- project: the project full name in "projects/{id}" format, support "==" operator.- instance: the instance full name in "instances/{id}" format, support "==" operator.- engine: the database engine, check Engine enum for values. Support "==", "in [xx]", "!(in [xx])" operator.- - label: the database label in "{key}:{value1},{value2}" format. Support "==" operator.- exclude_unassigned: should be "true" or "false", will not show unassigned databases if it's true, support "==" operator.- drifted: should be "true" or "false", show drifted databases if it's true, support "==" operator.- table: filter by the database table, support "==" and ".matches()" operator.+ - labels.{key}: the database label, support "==" and "in" operators.For example:environment == "environments/{environment resource id}"@@ -7941,13 +7942,13 @@ paths:engine == "MYSQL"engine in ["MYSQL", "POSTGRES"]!(engine in ["MYSQL", "POSTGRES"])- label == "region:asia"- label == "tenant:asia,europe"- label == "region:asia" && label == "tenant:bytebase"exclude_unassigned == truedrifted == truetable == "sample"table.matches("sam")+ labels.environment == "production"+ labels.region == "asia"+ labels.region in ["asia", "europe"]You can combine filter conditions like:environment == "environments/prod" && name.matches("employee")@@ -13291,6 +13292,7 @@ components:- resource_id: the project id, support "==" and ".matches()" operator.- exclude_default: if not include the default project, should be "true" or "false", support "==" operator.- state: check the State enum for the values, support "==" operator.+ - labels.{key}: the project label, support "==" and "in" operators.For example:name = "project name"@@ -13299,9 +13301,13 @@ components:resource_id.matches("project id")exclude_default == truestate == "DELETED"+ labels.environment == "production"+ labels.tier == "critical"+ labels.environment in ["staging", "prod"]You can combine filter conditions like:name = "project name" && resource_id.matches("project id")name.matches("project name") || resource_id = "project id"+ labels.environment == "production" && labels.tier == "critical"pageSize:type: integerdescription: |-diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.mdindex 1371ec70fe..4d7f86375c 100644--- a/proto/gen/grpc-doc/v1/README.md+++ b/proto/gen/grpc-doc/v1/README.md@@ -2729,9 +2729,9 @@ Combine multiple functions with "&&" and "||", we MUST uWhen paginating, all other parameters provided to `ListDatabases` must match the call that provided the page token. || filter | [string](#string) | | Filter is used to filter databases returned in the list. The syntax and semantics of CEL are documented at https://github.com/google/cel-spec-Supported filter: - environment: the environment full name in "environments/{id}" format, support "==" operator. - name: the database name, support ".matches()" operator. - project: the project full name in "projects/{id}" format, support "==" operator. - instance: the instance full name in "instances/{id}" format, support "==" operator. - engine: the database engine, check Engine enum for values. Support "==", "in [xx]", "!(in [xx])" operator. - label: the database label in "{key}:{value1},{value2}" format. Support "==" operator. - exclude_unassigned: should be "true" or "false", will not show unassigned databases if it's true, support "==" operator. - drifted: should be "true" or "false", show drifted databases if it's true, support "==" operator. - table: filter by the database table, support "==" and ".matches()" operator.+Supported filter: - environment: the environment full name in "environments/{id}" format, support "==" operator. - name: the database name, support ".matches()" operator. - project: the project full name in "projects/{id}" format, support "==" operator. - instance: the instance full name in "instances/{id}" format, support "==" operator. - engine: the database engine, check Engine enum for values. Support "==", "in [xx]", "!(in [xx])" operator. - exclude_unassigned: should be "true" or "false", will not show unassigned databases if it's true, support "==" operator. - drifted: should be "true" or "false", show drifted databases if it's true, support "==" operator. - table: filter by the database table, support "==" and ".matches()" operator. - labels.{key}: the database label, support "==" and "in" operators.-For example: environment == "environments/{environment resource id}" environment == "" (find databases which environment is not set) project == "projects/{project resource id}" instance == "instances/{instance resource id}" name.matches("database name") engine == "MYSQL" engine in ["MYSQL", "POSTGRES"] !(engine in ["MYSQL", "POSTGRES"]) label == "region:asia" label == "tenant:asia,europe" label == "region:asia" && label == "tenant:bytebase" exclude_unassigned == true drifted == true table == "sample" table.matches("sam")+For example: environment == "environments/{environment resource id}" environment == "" (find databases which environment is not set) project == "projects/{project resource id}" instance == "instances/{instance resource id}" name.matches("database name") engine == "MYSQL" engine in ["MYSQL", "POSTGRES"] !(engine in ["MYSQL", "POSTGRES"]) exclude_unassigned == true drifted == true table == "sample" table.matches("sam") labels.environment == "production" labels.region == "asia" labels.region in ["asia", "europe"]You can combine filter conditions like: environment == "environments/prod" && name.matches("employee") || show_deleted | [bool](#bool) | | Show deleted database if specified. |@@ -7864,7 +7864,7 @@ This value should be 4-63 characters, and valid characters are /[a-z][0-9]-/. |When paginating, all other parameters provided to `ListProjects` must match the call that provided the page token. || show_deleted | [bool](#bool) | | Show deleted projects if specified. |-| filter | [string](#string) | | Filter the project. Check filter for SearchProjectsRequest for details. |+| filter | [string](#string) | | Filter the project. Check filter for SearchProjectsRequest for details. Supports filtering by name, resource_id, state, and labels (e.g., labels.environment == "production"). |@@ -7976,9 +7976,9 @@ When paginating, all other parameters provided to `ListProjects` must match the| show_deleted | [bool](#bool) | | Show deleted projects if specified. || filter | [string](#string) | | Filter the project. The syntax and semantics of CEL are documented at https://github.com/google/cel-spec-Supported filters: - name: the project name, support "==" and ".matches()" operator. - resource_id: the project id, support "==" and ".matches()" operator. - exclude_default: if not include the default project, should be "true" or "false", support "==" operator. - state: check the State enum for the values, support "==" operator.+Supported filters: - name: the project name, support "==" and ".matches()" operator. - resource_id: the project id, support "==" and ".matches()" operator. - exclude_default: if not include the default project, should be "true" or "false", support "==" operator. - state: check the State enum for the values, support "==" operator. - labels.{key}: the project label, support "==" and "in" operators.-For example: name = "project name" name.matches("project name") resource_id = "project id" resource_id.matches("project id") exclude_default == true state == "DELETED" You can combine filter conditions like: name = "project name" && resource_id.matches("project id") name.matches("project name") || resource_id = "project id" |+For example: name = "project name" name.matches("project name") resource_id = "project id" resource_id.matches("project id") exclude_default == true state == "DELETED" labels.environment == "production" labels.tier == "critical" labels.environment in ["staging", "prod"] You can combine filter conditions like: name = "project name" && resource_id.matches("project id") name.matches("project name") || resource_id = "project id" labels.environment == "production" && labels.tier == "critical" || page_size | [int32](#int32) | | The maximum number of projects to return. The service may return fewer than this value. If unspecified, at most 10 projects will be returned. The maximum value is 1000; values above 1000 will be coerced to 1000. || page_token | [string](#string) | | A page token, received from a previous `SearchProjects` call. Provide this to retrieve the subsequent page.diff --git a/proto/gen/grpc-doc/v1/index.html b/proto/gen/grpc-doc/v1/index.htmlindex 4cfe93e016..2d5e89d07c 100644--- a/proto/gen/grpc-doc/v1/index.html+++ b/proto/gen/grpc-doc/v1/index.html@@ -8216,10 +8216,10 @@ Supported filter:- project: the project full name in "projects/{id}" format, support "==" operator.- instance: the instance full name in "instances/{id}" format, support "==" operator.- engine: the database engine, check Engine enum for values. Support "==", "in [xx]", "!(in [xx])" operator.-- label: the database label in "{key}:{value1},{value2}" format. Support "==" operator.- exclude_unassigned: should be "true" or "false", will not show unassigned databases if it's true, support "==" operator.- drifted: should be "true" or "false", show drifted databases if it's true, support "==" operator.- table: filter by the database table, support "==" and ".matches()" operator.+- labels.{key}: the database label, support "==" and "in" operators.For example:environment == "environments/{environment resource id}"@@ -8230,13 +8230,13 @@ name.matches("database name")engine == "MYSQL"engine in ["MYSQL", "POSTGRES"]!(engine in ["MYSQL", "POSTGRES"])-label == "region:asia"-label == "tenant:asia,europe"-label == "region:asia" && label == "tenant:bytebase"exclude_unassigned == truedrifted == truetable == "sample"table.matches("sam")+labels.environment == "production"+labels.region == "asia"+labels.region in ["asia", "europe"]You can combine filter conditions like:environment == "environments/prod" && name.matches("employee") </p></td>@@ -22010,7 +22010,8 @@ the call that provided the page token. </p></td><td><a href="#string">string</a></td><td></td><td><p>Filter the project.-Check filter for SearchProjectsRequest for details. </p></td>+Check filter for SearchProjectsRequest for details.+Supports filtering by name, resource_id, state, and labels (e.g., labels.environment == "production"). </p></td></tr></tbody>@@ -22307,6 +22308,7 @@ Supported filters:- resource_id: the project id, support "==" and ".matches()" operator.- exclude_default: if not include the default project, should be "true" or "false", support "==" operator.- state: check the State enum for the values, support "==" operator.+- labels.{key}: the project label, support "==" and "in" operators.For example:name = "project name"@@ -22315,9 +22317,13 @@ resource_id = "project id"resource_id.matches("project id")exclude_default == truestate == "DELETED"+labels.environment == "production"+labels.tier == "critical"+labels.environment in ["staging", "prod"]You can combine filter conditions like:name = "project name" && resource_id.matches("project id")-name.matches("project name") || resource_id = "project id" </p></td>+name.matches("project name") || resource_id = "project id"+labels.environment == "production" && labels.tier == "critical" </p></td></tr><tr>diff --git a/proto/v1/v1/database_service.proto b/proto/v1/v1/database_service.protoindex 2793ecc4a8..56b197b3e9 100644--- a/proto/v1/v1/database_service.proto+++ b/proto/v1/v1/database_service.proto@@ -207,10 +207,10 @@ message ListDatabasesRequest {// - project: the project full name in "projects/{id}" format, support "==" operator.// - instance: the instance full name in "instances/{id}" format, support "==" operator.// - engine: the database engine, check Engine enum for values. Support "==", "in [xx]", "!(in [xx])" operator.- // - label: the database label in "{key}:{value1},{value2}" format. Support "==" operator.// - exclude_unassigned: should be "true" or "false", will not show unassigned databases if it's true, support "==" operator.// - drifted: should be "true" or "false", show drifted databases if it's true, support "==" operator.// - table: filter by the database table, support "==" and ".matches()" operator.+ // - labels.{key}: the database label, support "==" and "in" operators.//// For example:// environment == "environments/{environment resource id}"@@ -221,13 +221,13 @@ message ListDatabasesRequest {// engine == "MYSQL"// engine in ["MYSQL", "POSTGRES"]// !(engine in ["MYSQL", "POSTGRES"])- // label == "region:asia"- // label == "tenant:asia,europe"- // label == "region:asia" && label == "tenant:bytebase"// exclude_unassigned == true// drifted == true// table == "sample"// table.matches("sam")+ // labels.environment == "production"+ // labels.region == "asia"+ // labels.region in ["asia", "europe"]//// You can combine filter conditions like:// environment == "environments/prod" && name.matches("employee")diff --git a/proto/v1/v1/project_service.proto b/proto/v1/v1/project_service.protoindex e16596a877..0b75376e75 100644--- a/proto/v1/v1/project_service.proto+++ b/proto/v1/v1/project_service.proto@@ -218,7 +218,7 @@ message SearchProjectsRequest {// - resource_id: the project id, support "==" and ".matches()" operator.// - exclude_default: if not include the default project, should be "true" or "false", support "==" operator.// - state: check the State enum for the values, support "==" operator.- // - labels.{key}: the project label, support "==" operator for exact match.+ // - labels.{key}: the project label, support "==" and "in" operators.//// For example:// name = "project name"@@ -229,6 +229,7 @@ message SearchProjectsRequest {// state == "DELETED"// labels.environment == "production"// labels.tier == "critical"+ // labels.environment in ["staging", "prod"]// You can combine filter conditions like:// name = "project name" && resource_id.matches("project id")// name.matches("project name") || resource_id = "project id"