fix(mongodb): preserve int64 filter values

This commit is contained in:
miracle authored and GitHub committed 2026-07-23 17:06:31 +08:00
1 parent f07509b5ad
commit c11b0b160d
6 files changed
+78 -2

No files matched your search

@@ -1787,6 +1787,7 @@ defineExpose({ focusSearch });
rows="1"
class="document-query-input flex-1 min-w-0 text-xs bg-transparent outline-none placeholder:text-muted-foreground/60 font-mono"
placeholder="{}"
@keydown.enter.exact.prevent="applyFilter"
@keydown.ctrl.enter.prevent="applyFilter"
@keydown.meta.enter.prevent="applyFilter"
/>
@@ -1825,6 +1826,7 @@ defineExpose({ focusSearch });
rows="1"
class="document-query-input flex-1 min-w-0 text-xs bg-transparent outline-none placeholder:text-muted-foreground/60 font-mono"
placeholder="{}"
@keydown.enter.exact.prevent="applyFilter"
@keydown.ctrl.enter.prevent="applyFilter"
@keydown.meta.enter.prevent="applyFilter"
/>
@@ -1,4 +1,5 @@
import type { ComposerTranslation } from "vue-i18n";
import { normalizeJsonArgument } from "@dbx-app/mongo-shell";
import type { DatabaseType } from "@/types/database";
import { quoteUnquotedObjectKeys } from "@/lib/mongo/mongoShellCommand";
import { formatMongoShellLiteral } from "@/lib/mongo/mongoDocumentValues";
@@ -531,11 +532,23 @@ function isDigit(value: string | undefined): boolean {
export function parseDocumentFilterInput(input: string, options: DocumentFilterParseOptions = {}): Record<string, unknown> {
const trimmed = input.trim();
if (!trimmed) return {};
const safe = quoteUnquotedObjectKeys(trimmed);
const safe = normalizeDocumentQueryObjectInput(trimmed, options.kind);
const parsed = parseJsonPreservingLargeIntegers(safe, options);
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? (parsed as Record<string, unknown>) : {};
}
type DocumentQueryInputNormalizer = (input: string) => string | null;
const documentQueryInputNormalizers: Record<DocumentStoreKind, DocumentQueryInputNormalizer> = {
mongodb: normalizeJsonArgument,
elasticsearch: quoteUnquotedObjectKeys,
};
function normalizeDocumentQueryObjectInput(input: string, kind?: DocumentStoreKind): string {
const normalize = kind ? documentQueryInputNormalizers[kind] : quoteUnquotedObjectKeys;
return normalize(input) ?? input;
}
export function currentDocumentFilterJson(input: string, structured: Record<string, unknown> | null, kind?: DocumentStoreKind): string | undefined {
const manual = parseDocumentFilterInput(input, { kind });
const filter = structured ? (Object.keys(manual).length ? { $and: [manual, structured] } : structured) : manual;