microsoft / azuredatastudio-postgresql

azuredatastudio-postgresql is an extension for Azure Data Studio that enables you to work with PostgreSQL databases
Other
196 stars 37 forks source link

Unhandled exception while executing query: 'list' object has no attribute 'encode' #487

Open nasc17 opened 10 months ago

nasc17 commented 10 months ago

Run: select * from pg_catalog.pg_proc or select proacl from pg_catalog.pg_proc

image

Possible workaround: Discussed in #449 "The problem is ADS knows knows how to process basic encodings like integer (number,int,bigint,etc.) or string (varchar,etc.), there maybe more but I don't know what they are (maybe date and time?).

Encodings like CIDR causes problems. I can only assume your ip_address is an encoding that is not a varcahr. I am guessing there wasn't any logic put in place for ADS to process Postgres CIDR encodings.

You can add ::TEXT at the end of each attribute you are querying with an encoding type that ADS does not recognize (i.e. CIDR). Doing this will force ADS to convert the encoding to a string before presenting. From your example I would do the following.

select asset_id ,mac_address ,ip_address::TEXT from public.dim_asset Can you confirm if this helped? I bet you could do the same for other encoding types that ADS does not understand.

I would recommend ADS put this in their documentation because it is not obvious. More so, I'd like to recommend ADS do this conversion for us so we don't have to. This application presents data, so obviously we want any weird encodings to be converted to strings for presentation."

darkshoxx commented 6 months ago

Gonna piggyback here real quick to mention this issue that could be related, only difference is that the query is
select * from pg_database;, will your PR fix this as well @DaeunYim ? If not, I'm happy to raise a separate issue.