Skip to content

Commit 898d24a

Browse files
committed
PL/Python: Fix hint about returning composite type from Python
('foo') is not a Python tuple: it is a string wrapped in parentheses. A valid 1-element Python tuple is ('foo',). Author: Daniele Varrazzo <daniele.varrazzo@gmail.com>
1 parent b295cc3 commit 898d24a

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/pl/plpython/expected/plpython_composite.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,6 @@ $$ LANGUAGE plpythonu;
589589
SELECT * FROM composite_type_as_list_broken();
590590
ERROR: malformed record literal: "first"
591591
DETAIL: Missing left parenthesis.
592-
HINT: To return a composite type in an array, return the composite type as a Python tuple, e.g. "[('foo')]"
592+
HINT: To return a composite type in an array, return the composite type as a Python tuple, e.g., "[('foo',)]".
593593
CONTEXT: while creating return value
594594
PL/Python function "composite_type_as_list_broken"

src/pl/plpython/plpy_typeio.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ PLyObject_ToDatum(PLyObToDatum *arg, int32 typmod, PyObject *plrv, bool inarray)
949949
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
950950
errmsg("malformed record literal: \"%s\"", str),
951951
errdetail("Missing left parenthesis."),
952-
errhint("To return a composite type in an array, return the composite type as a Python tuple, e.g. \"[('foo')]\"")));
952+
errhint("To return a composite type in an array, return the composite type as a Python tuple, e.g., \"[('foo',)]\".")));
953953
}
954954

955955
return InputFunctionCall(&arg->typfunc,
@@ -1387,7 +1387,7 @@ PLyGenericObject_ToComposite(PLyTypeInfo *info, TupleDesc desc, PyObject *object
13871387
(errcode(ERRCODE_UNDEFINED_COLUMN),
13881388
errmsg("attribute \"%s\" does not exist in Python object", key),
13891389
inarray ?
1390-
errhint("To return a composite type in an array, return the composite type as a Python tuple, e.g. \"[('foo')]\"") :
1390+
errhint("To return a composite type in an array, return the composite type as a Python tuple, e.g., \"[('foo',)]\".") :
13911391
errhint("To return null in a column, let the returned object have an attribute named after column with value None.")));
13921392
}
13931393

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy