fix: queries firing before having a table or connection id (#1003)

This commit is contained in:
Aaron Knudtson 2025-07-16 11:30:25 -05:00 committed by GitHub
parent 86f5fa7d2c
commit 4581a68a0b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 19 additions and 20 deletions

View file

@ -0,0 +1,5 @@
---
"@hyperdx/app": patch
---
fix: queries firing before having a valid table or connection id

View file

@ -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,

View file

@ -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]);

View file

@ -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);

View file

@ -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,
});
}