Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix(BYT-9319): stabilize default QueryDataPolicy reference (#20064)

h3n4ld5a5c21c355d
diff --git a/frontend/src/store/modules/v1/policy.ts b/frontend/src/store/modules/v1/policy.ts
index 194dd9c789..fee29e01e0 100644
--- a/frontend/src/store/modules/v1/policy.ts
+++ b/frontend/src/store/modules/v1/policy.ts
@@ -42,6 +42,13 @@ export const replacePolicyTypeNameToLowerCase = (name: string) => {
return replaced;
};
+// Shared default returned when no DATA_QUERY policy exists for a parent.
+// Must be a stable singleton so subscribers (e.g. React useVueState) don't
+// see a new reference on every call and thrash their effects.
+const EMPTY_QUERY_DATA_POLICY: QueryDataPolicy = create(QueryDataPolicySchema, {
+ maximumResultRows: -1,
+});
+
export const usePolicyV1Store = defineStore("policy_v1", () => {
const state = reactive<PolicyState>({
policyMapByName: new Map(),
@@ -54,9 +61,7 @@ export const usePolicyV1Store = defineStore("policy_v1", () => {
});
return policy?.policy?.case === "queryDataPolicy"
? policy.policy.value
- : create(QueryDataPolicySchema, {
- maximumResultRows: -1,
- });
+ : EMPTY_QUERY_DATA_POLICY;
};
const getOrFetchPolicyByParentAndType = async ({