Skip to content

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

fix: handle legacy enum value in localStorage (#16753)

boojack497f87577583
diff --git a/frontend/src/composables/useExecuteSQL.ts b/frontend/src/composables/useExecuteSQL.ts
index 206d8ab05d..65cc908155 100644
--- a/frontend/src/composables/useExecuteSQL.ts
+++ b/frontend/src/composables/useExecuteSQL.ts
@@ -399,6 +399,9 @@ const useExecuteSQL = () => {
});
}
+ const queryOption = create(QueryOptionSchema, {
+ redisRunCommandsOn: sqlEditorStore.redisCommandOption,
+ });
const resultSet = await sqlStore.query(
create(QueryRequestSchema, {
name: database.name,
@@ -408,9 +411,7 @@ const useExecuteSQL = () => {
explain: context.params.explain,
schema: context.params.connection.schema,
container: context.params.connection.table,
- queryOption: create(QueryOptionSchema, {
- redisRunCommandsOn: sqlEditorStore.redisCommandOption,
- }),
+ queryOption: queryOption,
}),
abortController.signal
);
diff --git a/frontend/src/store/modules/sqlEditor/editor.ts b/frontend/src/store/modules/sqlEditor/editor.ts
index 499f4bd9ff..7a5dff8f1e 100644
--- a/frontend/src/store/modules/sqlEditor/editor.ts
+++ b/frontend/src/store/modules/sqlEditor/editor.ts
@@ -1,4 +1,5 @@
import { useLocalStorage } from "@vueuse/core";
+import { includes } from "lodash-es";
import { defineStore } from "pinia";
import { computed, ref, watch } from "vue";
import { type ComposedDatabase, isValidProjectName } from "@/types";
@@ -12,7 +13,25 @@ export const useSQLEditorStore = defineStore("sqlEditor", () => {
);
const redisCommandOption = useLocalStorage<QueryOption_RedisRunCommandsOn>(
"bb.sql-editor.redis-command-node",
- QueryOption_RedisRunCommandsOn.SINGLE_NODE
+ QueryOption_RedisRunCommandsOn.SINGLE_NODE,
+ {
+ // Use a custom merge function to ensure the value is valid.
+ mergeDefaults(storageValue, defaults) {
+ if (
+ !includes(
+ [
+ QueryOption_RedisRunCommandsOn.SINGLE_NODE,
+ QueryOption_RedisRunCommandsOn.ALL_NODES,
+ ],
+ storageValue
+ )
+ ) {
+ return defaults;
+ }
+ // Otherwise, return the storage value
+ return storageValue;
+ },
+ }
);
// empty to "ALL" projects for high-privileged users