mirror of
https://github.com/hyperdxio/hyperdx
synced 2026-04-21 13:37:15 +00:00
fix: queries firing before having a table or connection id (#1003)
This commit is contained in:
parent
86f5fa7d2c
commit
4581a68a0b
5 changed files with 19 additions and 20 deletions
5
.changeset/violet-trainers-compete.md
Normal file
5
.changeset/violet-trainers-compete.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"@hyperdx/app": patch
|
||||
---
|
||||
|
||||
fix: queries firing before having a valid table or connection id
|
||||
|
|
@ -68,16 +68,11 @@ export default function DBColumnMultiSelect({
|
|||
values: string[];
|
||||
setValues: (value: string[]) => void;
|
||||
}) {
|
||||
const { data: columns, isLoading: isColumnsLoading } = useColumns(
|
||||
{
|
||||
databaseName: database ?? '',
|
||||
tableName: table ?? '',
|
||||
connectionId: connectionId ?? '',
|
||||
},
|
||||
{
|
||||
enabled: !!database && !!table && !!connectionId,
|
||||
},
|
||||
);
|
||||
const { data: columns } = useColumns({
|
||||
databaseName: database ?? '',
|
||||
tableName: table ?? '',
|
||||
connectionId: connectionId ?? '',
|
||||
});
|
||||
|
||||
const propertyOptions = (columns ?? []).map((column: { name: string }) => ({
|
||||
value: column.name,
|
||||
|
|
|
|||
|
|
@ -144,11 +144,7 @@ export default function SQLInlineEditor({
|
|||
additionalSuggestions = [],
|
||||
queryHistoryType,
|
||||
}: SQLInlineEditorProps) {
|
||||
const { data: fields } = useAllFields(tableConnections ?? [], {
|
||||
enabled:
|
||||
!!tableConnections &&
|
||||
(Array.isArray(tableConnections) ? tableConnections.length > 0 : true),
|
||||
});
|
||||
const { data: fields } = useAllFields(tableConnections ?? []);
|
||||
const filteredFields = useMemo(() => {
|
||||
return filterField ? fields?.filter(filterField) : fields;
|
||||
}, [fields, filterField]);
|
||||
|
|
|
|||
|
|
@ -27,11 +27,7 @@ export function useAutoCompleteOptions(
|
|||
},
|
||||
) {
|
||||
// Fetch and gather all field options
|
||||
const { data: fields } = useAllFields(tableConnections ?? [], {
|
||||
enabled:
|
||||
!!tableConnections &&
|
||||
(Array.isArray(tableConnections) ? tableConnections.length > 0 : true),
|
||||
});
|
||||
const { data: fields } = useAllFields(tableConnections ?? []);
|
||||
const { fieldCompleteOptions, fieldCompleteMap } = useMemo(() => {
|
||||
const _columns = (fields ?? []).filter(c => c.jsType !== null);
|
||||
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ export function useColumns(
|
|||
connectionId,
|
||||
});
|
||||
},
|
||||
enabled: !!databaseName && !!tableName && !!connectionId,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
|
|
@ -64,6 +65,11 @@ export function useAllFields(
|
|||
|
||||
return deduplicate2dArray<Field>(fields2d);
|
||||
},
|
||||
enabled:
|
||||
tableConnections.length > 0 &&
|
||||
tableConnections.every(
|
||||
tc => !!tc.databaseName && !!tc.tableName && !!tc.connectionId,
|
||||
),
|
||||
...options,
|
||||
});
|
||||
}
|
||||
|
|
@ -91,6 +97,7 @@ export function useTableMetadata(
|
|||
});
|
||||
},
|
||||
staleTime: 1000 * 60 * 5, // Cache every 5 min
|
||||
enabled: !!databaseName && !!tableName && !!connectionId,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue