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
8 changes: 8 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Upcoming (TBD)
==============

Features
---------
* Prioritize common functions in the "value" position.


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

Expand Down
35 changes: 21 additions & 14 deletions mycli/sqlcompleter.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ class SQLCompleter(Completer):

# misclassified as keywords
# do they need to also be subtracted from keywords?
pygments_misclassified_functions = (
pygments_misclassified_functions = [
'ASCII',
'AVG',
'CHARSET',
Expand Down Expand Up @@ -807,9 +807,10 @@ class SQLCompleter(Completer):
'VALUES',
'WEEK',
'WEIGHT_STRING',
)
]

pygments_missing_functions = (
# should case be respected for functions styled as CamelCase?
pygments_missing_functions = [
'BINARY', # deprecated function, but available everywhere
'CHAR',
'DATE',
Expand All @@ -829,27 +830,33 @@ class SQLCompleter(Completer):
'VECTOR_DIM',
'VECTOR_TO_STRING',
'YEAR',
)
]

# so far an incomplete list
# these should be spun out and completed independently from functions
pygments_value_position_nonfunction_keywords = (
# these should be spun out and completed independently from functions in the value position
pygments_value_position_nonfunction_keywords = [
'BETWEEN',
'CASE',
'FALSE',
'NOT',
'NULL',
'TRUE',
)
]

# should https://dev.mysql.com/doc/refman/9.6/en/loadable-function-reference.html also be added?
functions = sorted({
x.upper()
for x in MYSQL_FUNCTIONS
+ pygments_misclassified_functions
+ pygments_missing_functions
+ pygments_value_position_nonfunction_keywords
})
pygments_functions_supplemented = sorted(
[x.upper() for x in MYSQL_FUNCTIONS]
+ [x.upper() for x in pygments_misclassified_functions]
+ [x.upper() for x in pygments_missing_functions]
+ [x.upper() for x in pygments_value_position_nonfunction_keywords]
)

favorite_functions = [
'JSON_EXTRACT',
'JSON_VALUE',
]
functions_raw = favorite_functions + pygments_functions_supplemented
functions = list(dict.fromkeys(functions_raw))

# https://docs.pingcap.com/tidb/dev/tidb-functions
tidb_functions = [
Expand Down
2 changes: 1 addition & 1 deletion test/test_smart_completion_public_schema_only.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,8 @@ def test_auto_case_heuristic(completer, complete_event):
position = len("select json_v")
result = list(completer.get_completions(Document(text=text, cursor_position=position), complete_event))
assert [x.text for x in result] == [
'json_valid',
'json_value',
'json_valid',
]


Expand Down