diff --git a/apps/studio/components/interfaces/SQLEditor/SQLEditor.tsx b/apps/studio/components/interfaces/SQLEditor/SQLEditor.tsx index d4577ae1a8f..965e3d930c3 100644 --- a/apps/studio/components/interfaces/SQLEditor/SQLEditor.tsx +++ b/apps/studio/components/interfaces/SQLEditor/SQLEditor.tsx @@ -147,9 +147,12 @@ export const SQLEditor = () => { const { data: subscription } = useOrgSubscriptionQuery({ orgSlug: org?.slug }) const hasHipaaAddon = subscriptionHasHipaaAddon(subscription) - const { data: databases, isSuccess: isSuccessReadReplicas } = useReadReplicasQuery({ - projectRef: ref, - }) + const { data: databases, isSuccess: isSuccessReadReplicas } = useReadReplicasQuery( + { + projectRef: ref, + }, + { enabled: Boolean(project?.connectionString) } + ) const { data, refetch: refetchEntityDefinitions } = useEntityDefinitionsQuery( { @@ -157,7 +160,7 @@ export const SQLEditor = () => { projectRef: project?.ref, connectionString: project?.connectionString, }, - { enabled: includeSchemaMetadata } + { enabled: Boolean(project?.connectionString) && includeSchemaMetadata } ) const entityDefinitions = includeSchemaMetadata ? data?.map((def) => def.sql.trim()) : undefined @@ -308,6 +311,7 @@ export const SQLEditor = () => { const connectionString = databases?.find( (db) => db.identifier === databaseSelectorState.selectedDatabaseId )?.connectionString + // TODO: in which case if it's not "IS_PLATFORM" it would work ? if (IS_PLATFORM && !connectionString) { return toast.error('Unable to run query: Connection string is missing') } diff --git a/apps/studio/data/sql/execute-sql-query.ts b/apps/studio/data/sql/execute-sql-query.ts index ce00ebf3a23..a0aab57e08b 100644 --- a/apps/studio/data/sql/execute-sql-query.ts +++ b/apps/studio/data/sql/execute-sql-query.ts @@ -42,6 +42,7 @@ export async function executeSql( headersInit?: HeadersInit ): Promise<{ result: any }> { if (!projectRef) throw new Error('projectRef is required') + if (!connectionString) throw new Error('Project connection string is required') const sqlSize = new Blob([sql]).size // [Joshen] I think the limit is around 1MB from testing, but its not exactly 1MB it seems