Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ Features
* Improve value-position keywords.


Bug Fixes
---------
* Fix crash for completion edge case (#1668)


1.59.0 (2026/03/03)
==============

Expand Down
7 changes: 6 additions & 1 deletion mycli/packages/parseutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,12 @@ def extract_columns_from_select(sql: str) -> list[str]:
if isinstance(token, IdentifierList):
# multiple columns
for identifier in token.get_identifiers():
column = identifier.get_real_name()
if isinstance(identifier, Identifier):
column = identifier.get_real_name()
elif isinstance(identifier, Token):
column = identifier.value
else:
continue
columns.append(column)
elif isinstance(token, Identifier):
# single column
Expand Down
9 changes: 9 additions & 0 deletions test/test_parseutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pytest

from mycli.packages.parseutils import (
extract_columns_from_select,
extract_tables,
extract_tables_from_complete_statements,
is_destructive,
Expand All @@ -13,6 +14,14 @@
)


def test_extract_columns_from_select():
try:
columns = extract_columns_from_select("SELECT COLUMN_NAME, DATA_TYPE, IS_NULLABLE, COLUMN_DEFAULT FROM INFORMATION_SCHEMA.COLUMNS")
except Exception:
columns = []
assert columns == ["COLUMN_NAME", "DATA_TYPE", "IS_NULLABLE", "COLUMN_DEFAULT"]


def test_empty_string():
tables = extract_tables("")
assert tables == []
Expand Down