Skip to content

Commit b377104

Browse files
committed
addressing comments
1 parent 42a1fa5 commit b377104

File tree

3 files changed

+8
-17
lines changed

3 files changed

+8
-17
lines changed

sqlmesh/lsp/commands.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1 @@
1-
from sqlmesh.utils.pydantic import PydanticModel
2-
31
EXTERNAL_MODEL_UPDATE_COLUMNS = "sqlmesh.external_model_update_columns"
4-
5-
6-
class ExternalModelUpdateColumnsRequest(PydanticModel):
7-
model_name: str

sqlmesh/lsp/context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ def get_code_actions(
236236
edit=types.WorkspaceEdit(changes={params.text_document.uri: text_edits}),
237237
)
238238
code_actions.append(code_action)
239-
return code_actions
239+
return code_actions if code_actions else None
240240

241241
def get_code_lenses(self, uri: URI) -> t.Optional[t.List[types.CodeLens]]:
242242
models_in_file = self.map.get(uri.to_path())

sqlmesh/lsp/main.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
ApiResponseGetLineage,
2424
ApiResponseGetModels,
2525
)
26-
from sqlmesh.lsp.commands import ExternalModelUpdateColumnsRequest, EXTERNAL_MODEL_UPDATE_COLUMNS
26+
from sqlmesh.lsp.commands import EXTERNAL_MODEL_UPDATE_COLUMNS
2727
from sqlmesh.lsp.completions import get_sql_completions
2828
from sqlmesh.lsp.context import (
2929
LSPContext,
@@ -325,31 +325,28 @@ def command_external_models_update_columns(ls: LanguageServer, raw: t.Any) -> No
325325
if not isinstance(model_name, str):
326326
raise ValueError("Command parameter must be a string")
327327

328-
request = ExternalModelUpdateColumnsRequest(model_name=model_name)
329328
context = self._context_get_or_load()
330329
if not isinstance(context, LSPContext):
331330
raise ValueError("Context is not loaded or invalid")
332-
model = context.context.get_model(request.model_name)
331+
model = context.context.get_model(model_name)
333332
if model is None:
334-
raise ValueError(f"External model '{request.model_name}' not found")
333+
raise ValueError(f"External model '{model_name}' not found")
335334
if model._path is None:
336-
raise ValueError(
337-
f"External model '{request.model_name}' does not have a file path"
338-
)
335+
raise ValueError(f"External model '{model_name}' does not have a file path")
339336
uri = URI.from_path(model._path)
340337
updated = context.update_external_model_columns(
341338
ls=ls,
342339
uri=uri,
343-
model_name=request.model_name,
340+
model_name=model_name,
344341
)
345342
if updated:
346343
ls.show_message(
347-
f"Updated columns for '{request.model_name}'",
344+
f"Updated columns for '{model_name}'",
348345
types.MessageType.Info,
349346
)
350347
else:
351348
ls.show_message(
352-
f"Columns for '{request.model_name}' are already up to date",
349+
f"Columns for '{model_name}' are already up to date",
353350
)
354351
except Exception as e:
355352
ls.show_message(f"Error executing command: {e}", types.MessageType.Error)

0 commit comments

Comments
 (0)