Skip to content
Open
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 AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ Contributors:
* Devadathan M B (devadathanmb)
* Charalampos Stratakis
* Laszlo Bimba (bimlas)
* Tommi Kyntölä (kynde)

Creator:
--------
Expand Down
1 change: 1 addition & 0 deletions changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Bug fixes:
* Add `VERSION` to built-in function completion so `SELECT VERSION();` is suggested.
* Hide timezone notice at startup when local and server timezones are the same.
* Let `sqlparse` accept arbitrarily-large queries.
* Suggest columns after `GROUP BY`, like `ORDER BY` already does.

4.4.0 (2025-12-24)
==================
Expand Down
2 changes: 1 addition & 1 deletion pgcli/packages/sqlcompletion.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ def suggest_based_on_last_token(token, stmt):
# E.g. 'UPDATE foo SET'
return (Column(table_refs=stmt.get_tables(), local_tables=stmt.local_tables),)

elif token_v in ("select", "where", "having", "order by", "distinct"):
elif token_v in ("select", "where", "having", "group by", "order by", "distinct"):
return _suggest_expression(token_v, stmt)
elif token_v == "as":
# Don't suggest anything for aliases
Expand Down
9 changes: 9 additions & 0 deletions tests/test_sqlcompletion.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,11 @@ def test_distinct_suggests_cols(text):
"SELECT * FROM tbl x JOIN tbl1 y ORDER BY ",
"ORDER BY",
),
(
"SELECT * FROM tbl x JOIN tbl1 y GROUP BY ",
"SELECT * FROM tbl x JOIN tbl1 y GROUP BY ",
"GROUP BY",
),
],
)
def test_distinct_and_order_by_suggestions_with_aliases(text, text_before, last_keyword):
Expand All @@ -247,6 +252,10 @@ def test_distinct_and_order_by_suggestions_with_aliases(text, text_before, last_
"SELECT * FROM tbl x JOIN tbl1 y ORDER BY x.",
"SELECT * FROM tbl x JOIN tbl1 y ORDER BY x.",
),
(
"SELECT * FROM tbl x JOIN tbl1 y GROUP BY x.",
"SELECT * FROM tbl x JOIN tbl1 y GROUP BY x.",
),
],
)
def test_distinct_and_order_by_suggestions_with_alias_given(text, text_before):
Expand Down
Loading