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 @@ -148,6 +148,7 @@ Contributors:
* Charalampos Stratakis
* Laszlo Bimba (bimlas)
* Anjanna
* youdie006

Creator:
--------
Expand Down
8 changes: 8 additions & 0 deletions changelog.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
4.5.1 (unreleased)
==================

Bug fixes:
----------
* Fix ``NoneType`` crash when completing functions with unnamed (variadic) arguments (#1204).


4.5.0 (2026-06-02)
==================

Expand Down
2 changes: 1 addition & 1 deletion pgcli/packages/parseutils/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,6 @@ def fields(self):

return [
ColumnMetadata(name, typ, [])
for name, typ, mode in zip(self.arg_names, self.arg_types, self.arg_modes)
for name, typ, mode in zip(self.arg_names or [], self.arg_types or [], self.arg_modes)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Return the scalar field for variadic-only functions

When proargmodes is populated only because the function has input/variadic parameters, this now zips an empty arg_names list and returns []. That avoids the crash, but it also means populate_scoped_cols() gets no column metadata for functions such as labels(variadic text[]) RETURNS hstore, even though the existing comment above says functions without output parameters should expose the function name as the output column. In completions for FROM labels(...) l, this silently drops the labels column instead of falling back to ColumnMetadata(self.func_name, self.return_type, []) when no OUT/INOUT/TABLE modes are present.

Useful? React with 👍 / 👎.

if mode in ("o", "b", "t")
] # OUT, INOUT, TABLE
22 changes: 22 additions & 0 deletions tests/parseutils/test_function_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,25 @@ def test_function_metadata_eq():
assert not (f1 == f3)
assert hash(f1) == hash(f2)
assert hash(f1) != hash(f3)


def test_function_metadata_fields_with_variadic_and_no_arg_names():
# Regression for issue #1204: a function with a VARIADIC argument that has
# a type but no name (e.g. `labels(variadic text[]) RETURNS hstore`) leaves
# arg_names as None while arg_modes is truthy. fields() must not raise
# "'NoneType' object is not iterable".
f = FunctionMetadata(
"public",
"labels",
None, # arg_names: variadic arg has no name
["text[]"],
["v"], # VARIADIC
"hstore",
False,
False,
False,
False,
None,
)
# No OUT/INOUT/TABLE columns, so fields() yields nothing.
assert f.fields() == []
Loading