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
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Bug Fixes
---------
* Update `sqlglot` to v30.7.0 to fix has_bit_strings error.
* Adapt test suite to pygments 2.20.0


1.72.0 (2026/05/08)
Expand Down
10 changes: 9 additions & 1 deletion test/pytests/test_naive_completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from prompt_toolkit.document import Document
import pytest

from test.utils import pygments_at_least


@pytest.fixture
def completer():
Expand Down Expand Up @@ -37,7 +39,7 @@ def test_function_name_completion(completer, complete_event):
text = "SELECT MA"
position = len("SELECT MA")
result = list(completer.get_completions(Document(text=text, cursor_position=position), complete_event))
assert sorted(x.text for x in result) == [
expected = [
'MAKEDATE',
'MAKETIME',
'MAKE_SET',
Expand Down Expand Up @@ -80,6 +82,12 @@ def test_function_name_completion(completer, complete_event):
'MAX_USER_CONNECTIONS',
]

if pygments_at_least("2.20"):
expected.extend([
'MANUAL',
])
assert sorted(x.text for x in result) == sorted(expected)


def test_column_name_completion(completer, complete_event):
text = "SELECT FROM users"
Expand Down
28 changes: 26 additions & 2 deletions test/pytests/test_smart_completion_public_schema_only.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import pytest

import mycli.packages.special.main as special
from test.utils import pygments_at_least

metadata = {
"users": ["id", "email", "first_name", "last_name"],
Expand Down Expand Up @@ -848,7 +849,7 @@ def test_backticked_column_completion_two_character(completer, complete_event):
text = 'select `f'
position = len(text)
result = list(completer.get_completions(Document(text=text, cursor_position=position), complete_event))
assert result == [
expected = [
# todo it would be nicer if the column name "first_name" sorted to the top
Completion(text='`for`', start_position=-2),
Completion(text='`from`', start_position=-2),
Expand Down Expand Up @@ -912,12 +913,24 @@ def test_backticked_column_completion_two_character(completer, complete_event):
Completion(text='`references`', start_position=-2),
]

if pygments_at_least("2.20"):
expected.extend([
Completion(text='`file_format`', start_position=-2),
Completion(text='`file_name`', start_position=-2),
Completion(text='`file_pattern`', start_position=-2),
Completion(text='`file_prefix`', start_position=-2),
Completion(text='`files`', start_position=-2),
Completion(text='`from_vector`', start_position=-2),
])

assert sorted((x.text, x.start_position) for x in result) == sorted((x.text, x.start_position) for x in expected)


def test_backticked_column_completion_three_character(completer, complete_event):
text = 'select `fi'
position = len(text)
result = list(completer.get_completions(Document(text=text, cursor_position=position), complete_event))
assert result == [
expected = [
# todo it would be nicer if the column name "first_name" sorted to the top
Completion(text='`file`', start_position=-3),
Completion(text='`field`', start_position=-3),
Expand All @@ -942,6 +955,17 @@ def test_backticked_column_completion_three_character(completer, complete_event)
Completion(text='`foreign key`', start_position=-3),
]

if pygments_at_least("2.20"):
expected.extend([
Completion(text='`file_format`', start_position=-3),
Completion(text='`file_name`', start_position=-3),
Completion(text='`file_pattern`', start_position=-3),
Completion(text='`file_prefix`', start_position=-3),
Completion(text='`files`', start_position=-3),
])

assert sorted((x.text, x.start_position) for x in result) == sorted((x.text, x.start_position) for x in expected)


def test_backticked_column_completion_four_character(completer, complete_event):
text = 'select `fir'
Expand Down
8 changes: 8 additions & 0 deletions test/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
from types import SimpleNamespace
from typing import Any, Callable, Literal, cast

from packaging.version import Version
import pygments
import pymysql
import pytest

Expand All @@ -34,6 +36,12 @@
SSH_PORT = int(os.getenv("PYTEST_SSH_PORT", "22"))
TEMPFILE_PREFIX = 'mycli_test_suite_'

PYGMENTS_VERSION = Version(pygments.__version__)


def pygments_at_least(version: str) -> bool:
return PYGMENTS_VERSION >= Version(version)


class DummyLogger:
def __init__(self) -> None:
Expand Down