'list' object has no attribute 'encode'
LSIND opened this issue · 1 comments
LSIND commented
Describe the bug
Faced an error Unhandled exception while executing query: 'list' object has no attribute 'encode'
when querying columns of type aclitem (catalog representation of access privileges).
To Reproduce
- SELECT-statements to system tables which query column of type aclitem (limit for short output):
-- column relacl
SELECT relname, relacl
FROM pg_class
WHERE relacl IS NOT NULL LIMIT 2;
-- column attacl
SELECT attrelid::regclass, attname, attoptions, attacl
FROM pg_attribute
WHERE attacl IS NOT NULL LIMIT 2;
- Error (same for both queries, result is exactly two rows)
SELECT 2
Unhandled exception while executing query: 'list' object has no attribute 'encode'
Expected behavior
psql (13.6) produces correct results (your output can be different based on privileges and roles in your system):
SELECT relname, relacl
FROM pg_class
WHERE relacl IS NOT NULL LIMIT 2;
relname | relacl |
---|---|
users_depts | {postgres=arwdDxt/postgres,alice=r/postgres,bob=r/postgres} |
revenue | {postgres=arwdDxt/postgres,alice=r/postgres,bob=r/postgres} |
SELECT attrelid::regclass, attname, attoptions, attacl
FROM pg_attribute
WHERE attacl IS NOT NULL LIMIT 2;
attrelid | attname | attoptions | attacl |
---|---|---|---|
pg_subscription | subdbid | {=r/postgres} | |
pg_subscription | subname | {=r/postgres} |
Desktop (please complete the following information):
- OS: Windows Server 2019 x64 and Windows 10 x64
ADS:
- ADS Version 1.47.1 (system setup)
- ADS PostgresSQL extension version 0.6.0
- PostgreSQL version 13.8, compiled by Visual C++ build 1914, 64-bit
Additional context
As a temporary solution I use function pg_catalog.array_to_string(array, delimiter) to convert each array element of aclitem type to its text representation:
SELECT relname, pg_catalog.array_to_string(relacl, ', ') as relacl
FROM pg_class
WHERE relacl IS NOT NULL LIMIT 2;
-- or just cast to text
SELECT relname, relacl::text as relacl
FROM pg_class
WHERE relacl IS NOT NULL LIMIT 2;
relname | relacl |
---|---|
users_depts | postgres=arwdDxt/postgres, alice=r/postgres, bob=r/postgres |
revenue | postgres=arwdDxt/postgres, alice=r/postgres, bob=r/postgres |
craftzneko commented
I have the same issue when running this query
SELECT *
FROM pg_class
WHERE relname = 'MYTABLENAME';