diff --git a/apps/studio/components/grid/components/grid/GridError.tsx b/apps/studio/components/grid/components/grid/GridError.tsx index b7654a52d1d..b3870798673 100644 --- a/apps/studio/components/grid/components/grid/GridError.tsx +++ b/apps/studio/components/grid/components/grid/GridError.tsx @@ -1,3 +1,4 @@ +import { useQueryClient } from '@tanstack/react-query' import { useParams } from 'common' import { useCallback } from 'react' import { Button } from 'ui' @@ -13,6 +14,7 @@ import { HighCostError } from '@/components/ui/HighQueryCost' import { InlineLink } from '@/components/ui/InlineLink' import { ENTITY_TYPE } from '@/data/entity-types/entity-type-constants' import { COST_THRESHOLD_ERROR } from '@/data/sql/execute-sql-query' +import { tableRowKeys } from '@/data/table-rows/keys' import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject' import { useTableEditorStateSnapshot } from '@/state/table-editor' import { useTableEditorTableStateSnapshot } from '@/state/table-editor-table' @@ -22,6 +24,8 @@ export const GridError = ({ error }: { error?: ResponseError | null }) => { const { id: _id } = useParams() const tableId = _id ? Number(_id) : undefined + const queryClient = useQueryClient() + const { data: project } = useSelectedProjectQuery() const newFilterBarEnabled = useIsTableFilterBarEnabled() const { filters: oldFilters, clearFilters: clearOldFilters } = useTableFilter() const { filters: newFilters, clearFilters: clearNewFilters } = useTableFilterNew() @@ -38,6 +42,17 @@ export const GridError = ({ error }: { error?: ResponseError | null }) => { } }, [clearOldFilters, clearNewFilters, newFilterBarEnabled]) + const handleLoadData = useCallback(() => { + if (!!tableId) { + tableEditorSnap.setTableToIgnorePreflightCheck(tableId) + + // Remove the cached error so useQuery re-fetches on the next render. + queryClient.removeQueries({ + queryKey: tableRowKeys.tableRowsAndCount(project?.ref, tableId), + }) + } + }, [tableEditorSnap, tableId, queryClient, project?.ref]) + if (!error) return null const tableEntityType = snap.originalTable?.entity_type @@ -63,9 +78,7 @@ export const GridError = ({ error }: { error?: ResponseError | null }) => { 'Remove any sorts or filters on unindexed columns, or', 'Create indexes for columns that you want to filter or sort on', ]} - onSelectLoadData={() => { - if (!!tableId) tableEditorSnap.setTableToIgnorePreflightCheck(tableId) - }} + onSelectLoadData={handleLoadData} /> ) } else if (isForeignTableMissingVaultKeyError) { diff --git a/apps/studio/components/ui/HighQueryCost.tsx b/apps/studio/components/ui/HighQueryCost.tsx index ca266201e1c..ce092d20f4c 100644 --- a/apps/studio/components/ui/HighQueryCost.tsx +++ b/apps/studio/components/ui/HighQueryCost.tsx @@ -171,9 +171,11 @@ const LoadDataWarningDialog = ({ Cancel - + + + diff --git a/apps/studio/data/table-rows/table-rows-query.ts b/apps/studio/data/table-rows/table-rows-query.ts index 524479225ed..57341288317 100644 --- a/apps/studio/data/table-rows/table-rows-query.ts +++ b/apps/studio/data/table-rows/table-rows-query.ts @@ -394,14 +394,15 @@ export const useTableRowsQuery = ( const queryClient = useQueryClient() const { connectionString, identifier: readReplicaIdentifier } = useConnectionStringForReadOps() - // [Joshen] Exclude preflightCheck from query key - const { preflightCheck, ...othersArgs } = args + // [Ali] Exclude preflightCheck from query key — it controls how the query + // executes (whether an EXPLAIN guard runs first), not what data is returned. + const { preflightCheck, ...queryKeyArgs } = args return useQuery({ queryKey: tableRowKeys.tableRows(projectRef, { table: { id: tableId }, readReplicaIdentifier, - ...othersArgs, + ...queryKeyArgs, }), queryFn: ({ signal }) => getTableRows({ queryClient, projectRef, connectionString, tableId, ...args }, signal), diff --git a/apps/studio/next.config.js b/apps/studio/next.config.js index 000ca88984b..7b865278390 100644 --- a/apps/studio/next.config.js +++ b/apps/studio/next.config.js @@ -613,9 +613,12 @@ const nextConfig = { // Make sure adding Sentry options is the last code to run before exporting, to // ensure that your source maps include changes from all other Webpack plugins +const platformConfig = + process.env.NEXT_PUBLIC_IS_PLATFORM === 'true' ? withBundleAnalyzer(nextConfig) : nextConfig + module.exports = - process.env.NEXT_PUBLIC_IS_PLATFORM === 'true' - ? withSentryConfig(withBundleAnalyzer(nextConfig), { + process.env.NEXT_PUBLIC_IS_PLATFORM === 'true' && process.env.VERCEL === '1' + ? withSentryConfig(platformConfig, { silent: true, // For all available options, see: @@ -647,4 +650,4 @@ module.exports = applicationKey: 'supabase-studio', }, }) - : nextConfig + : platformConfig