1 parent
f621e40655
commit
e2fa810f2e
16 files changed
+146
-10
No files matched your search
@@ -36,6 +36,19 @@ describe("normalizeColumnFormatter", () => {
|
||||
expect(normalizeColumnFormatter({ ...base, filter: { column: "dict_type", mode: "between", value: "A" } })).toBeUndefined();
|
||||
expect(normalizeColumnFormatter({ ...base, filter: { column: "dict_type", mode: "raw-sql", value: "1=1" } })).toBeUndefined();
|
||||
});
|
||||
|
||||
it.each(["is-blank", "is-not-blank"] as const)("preserves the value-less %s manual reference filter", (mode) => {
|
||||
expect(
|
||||
normalizeColumnFormatter({
|
||||
kind: "foreign-key-display",
|
||||
referenceMode: "manual",
|
||||
refTable: "dictionary",
|
||||
refColumn: "dict_key",
|
||||
displayColumn: "dict_value",
|
||||
filter: { column: "dict_type", mode },
|
||||
}),
|
||||
).toMatchObject({ filter: { column: "dict_type", mode, value: undefined, endValue: undefined } });
|
||||
});
|
||||
});
|
||||
|
||||
describe("normalizeSupportedDateTimePattern", () => {
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ import type { DataGridContextFilterMode } from "@/lib/dataGrid/dataGridSql";
|
||||
|
||||
describe("VictoriaMetrics data grid filters", () => {
|
||||
it("does not expose SQL filter modes for MetricsQL results", () => {
|
||||
const modes: DataGridContextFilterMode[] = ["equals", "not-equals", "is-null", "is-not-null", "like", "not-like", "less-than", "greater-than", "in", "not-in", "between", "not-between"];
|
||||
const modes: DataGridContextFilterMode[] = ["equals", "not-equals", "is-null", "is-not-null", "is-blank", "is-not-blank", "like", "not-like", "less-than", "greater-than", "in", "not-in", "between", "not-between"];
|
||||
|
||||
expect(modes.every((mode) => !filterModeIsSupportedForDatabase(mode, "victoriametrics"))).toBe(true);
|
||||
expect(filterModeIsSupportedForDatabase("equals", "postgres")).toBe(true);
|
||||
|
||||
@@ -190,7 +190,7 @@ export function normalizeColumnFormatter(value: unknown): ColumnFormatterConfig
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const FOREIGN_KEY_DISPLAY_FILTER_MODES = new Set<DataGridContextFilterMode>(["equals", "not-equals", "is-null", "is-not-null", "like", "not-like", "less-than", "less-than-or-equal", "greater-than", "greater-than-or-equal", "in", "not-in", "between", "not-between"]);
|
||||
const FOREIGN_KEY_DISPLAY_FILTER_MODES = new Set<DataGridContextFilterMode>(["equals", "not-equals", "is-null", "is-not-null", "is-blank", "is-not-blank", "like", "not-like", "less-than", "less-than-or-equal", "greater-than", "greater-than-or-equal", "in", "not-in", "between", "not-between"]);
|
||||
|
||||
function normalizeForeignKeyDisplayFilter(value: unknown): ForeignKeyDisplayFilterConfig | undefined {
|
||||
if (!value || typeof value !== "object") return undefined;
|
||||
@@ -200,7 +200,7 @@ function normalizeForeignKeyDisplayFilter(value: unknown): ForeignKeyDisplayFilt
|
||||
const mode = filter.mode as DataGridContextFilterMode;
|
||||
const rawValue = typeof filter.value === "string" ? filter.value.trim() : "";
|
||||
const rawEndValue = typeof filter.endValue === "string" ? filter.endValue.trim() : "";
|
||||
if (mode !== "is-null" && mode !== "is-not-null" && !rawValue) return undefined;
|
||||
if (mode !== "is-null" && mode !== "is-not-null" && mode !== "is-blank" && mode !== "is-not-blank" && !rawValue) return undefined;
|
||||
if ((mode === "between" || mode === "not-between") && !rawEndValue) return undefined;
|
||||
return {
|
||||
column: filter.column.trim(),
|
||||
|
||||
@@ -172,7 +172,7 @@ export function combineWhereInputs(manualWhereInput?: string, structuredWhereInp
|
||||
}
|
||||
|
||||
export function filterModeNeedsValue(mode: DataGridContextFilterMode): boolean {
|
||||
return mode !== "is-null" && mode !== "is-not-null";
|
||||
return mode !== "is-null" && mode !== "is-not-null" && mode !== "is-blank" && mode !== "is-not-blank";
|
||||
}
|
||||
|
||||
export function filterModeUsesList(mode: DataGridContextFilterMode): boolean {
|
||||
|
||||
@@ -58,7 +58,7 @@ export interface DataGridCopyInsertStatementOptions {
|
||||
insertMode?: DataGridCopyInsertMode;
|
||||
}
|
||||
|
||||
export type DataGridContextFilterMode = "equals" | "not-equals" | "is-null" | "is-not-null" | "like" | "not-like" | "less-than" | "less-than-or-equal" | "greater-than" | "greater-than-or-equal" | "in" | "not-in" | "between" | "not-between";
|
||||
export type DataGridContextFilterMode = "equals" | "not-equals" | "is-null" | "is-not-null" | "is-blank" | "is-not-blank" | "like" | "not-like" | "less-than" | "less-than-or-equal" | "greater-than" | "greater-than-or-equal" | "in" | "not-in" | "between" | "not-between";
|
||||
|
||||
export interface DataGridContextFilterConditionOptions {
|
||||
databaseType?: DatabaseType;
|
||||
|
||||
Reference in new issue
Block a user