pgweb icon indicating copy to clipboard operation
pgweb copied to clipboard

Display bytea columns hex encoded

Open felixbuenemann opened this issue 9 years ago • 2 comments

Currently (on 0.9.4) the content of bytea columns is shown as a UTF-8 string in the table view. It would be nice if these columns could be shown using hex encoding instead.

The encoding can be done in postgres using:

SELECT encode(my_checksum, 'hex') FROM my_table;

felixbuenemann avatar Sep 05 '16 16:09 felixbuenemann

But this kind of behavior would require the server to keep tabs on types of fields used in each table. I understand that it will be a much nicer user experience, but i dont really have the time to work on something like this. If you have any suggestions / code snippets i would definitely help getting the feature added, but otherwise i'll leave this issue open.

sosedoff avatar Sep 05 '16 16:09 sosedoff

I'm not familiar with go, but would it be easier to do the hex encoding in go?

If it's possible to reflect on the result's column type to see if it's a Bytea, it should be possible to encode it using something like hex.EncodeToString().

felixbuenemann avatar Sep 06 '16 04:09 felixbuenemann

This is now supported with --binary-codec= option.

--binary-codec=    Codec for binary data serialization, one of 'none', 'hex', 'base58', 'base64' (default: none)

sosedoff avatar Dec 02 '22 19:12 sosedoff