diff --git a/webapp/packages/plugin-sql-editor/src/SqlEditor/useSqlEditor.ts b/webapp/packages/plugin-sql-editor/src/SqlEditor/useSqlEditor.ts index d7e9b87d62..4370dd7fe3 100644 --- a/webapp/packages/plugin-sql-editor/src/SqlEditor/useSqlEditor.ts +++ b/webapp/packages/plugin-sql-editor/src/SqlEditor/useSqlEditor.ts @@ -447,12 +447,11 @@ export function useSqlEditor(state: ISqlEditorTabState): ISQLEditorData { const result = await this.sqlEditorService.parseSQLQuery(projectId, connectionId, this.value, this.cursor.begin); - const segment = this.parser.getSegment(result.start, result.end); - - if (!segment) { - throw new Error('Failed to get position'); + if (result.end === 0 && result.start === 0) { + return; } + const segment = this.parser.getSegment(result.start, result.end); return segment; },