user2257: i want to convert an "asset32type" to a string, reason being the datatype in the "name" column of dbsync's multi_asset table is "asset32type".
what is an "asset32type"?

user5926: An asset32type is a raw Postgres octet string, but limited to a maximum of 32 bytes. It is defined in schema/migration-1-0004-20201026.sql as:
CREATE DOMAIN asset32type AS bytea CHECK (octet_length (VALUE) <= 32);

eg:
select * from multi_asset limit 3 ;
 id |                           policy                           |         name         |                 fingerprint                  
----+------------------------------------------------------------+----------------------+----------------------------------------------
  1 | \x00000002df633853f6a47465c9496721d2d5b1291b8398016c0e87ae | \x6e7574636f696e     | asset12h3p5l3nd5y26lr22am7y7ga3vxghkhf57zkhd
  2 | \x3a9241cd79895e3a8d65261b40077d4437ce71e9d7c8c6c00e3f658e | \x4669727374636f696e | asset1aq460y056c3mm4jmuv9vg39n7w8y5gykywjwge
  3 | \x02f68378e37af4545d027d0a9fa5581ac682897a3fc1f6d8f936ed2b | \x4154414441         | asset1tm62f04gz390cjxttq4gz0s43lswr9estr2jcz
(3 rows)

It is stored as a raw Postgres string because there is not guaranetee about the encoding. It might be UTF-8 but it also might not be.

user382: The above answer does a great job of explaining what it is, but doesn't answer how you get the value as a string. To pull the value as hex (which is the only thing that makes sense for a policy hash for example), you would encode it like so:
SELECT encode(policy::bytea, 'hex') AS policy_hex FROM multi_asset LIMIT 3;

Likewise, if you want to use a WHERE clause against it, you would decode it:
SELECT * FROM multi_asset WHERE policy = decode('00000002df633853f6a47465c9496721d2d5b1291b8398016c0e87ae', 'hex');

The asset name itself may make sense as ASCII/UTF8 or it might not. There's no guarantees in the system that an asset name resembles anything so should always be treated as raw hex as well and get the actual asset information from the metadata server or metadata on the minting transaction that explains what it actually represents.

2257: <p>i want to convert an &quot;asset32type&quot; to a string, reason being the datatype in the &quot;name&quot; column of dbsync's multi_asset table is &quot;asset32type&quot;.</p>
<p>what is an &quot;asset32type&quot;?</p>
 5926: <p>An <code>asset32type</code> is a raw Postgres octet string, but limited to a maximum of 32 bytes. It is defined in <code>schema/migration-1-0004-20201026.sql</code> as:</p>
<pre><code>CREATE DOMAIN asset32type AS bytea CHECK (octet_length (VALUE) &lt;= 32);
</code></pre>
<p>eg:</p>
<pre><code>select * from multi_asset limit 3 ;
 id |                           policy                           |         name         |                 fingerprint                  
----+------------------------------------------------------------+----------------------+----------------------------------------------
  1 | \x00000002df633853f6a47465c9496721d2d5b1291b8398016c0e87ae | \x6e7574636f696e     | asset12h3p5l3nd5y26lr22am7y7ga3vxghkhf57zkhd
  2 | \x3a9241cd79895e3a8d65261b40077d4437ce71e9d7c8c6c00e3f658e | \x4669727374636f696e | asset1aq460y056c3mm4jmuv9vg39n7w8y5gykywjwge
  3 | \x02f68378e37af4545d027d0a9fa5581ac682897a3fc1f6d8f936ed2b | \x4154414441         | asset1tm62f04gz390cjxttq4gz0s43lswr9estr2jcz
(3 rows)
</code></pre>
<p>It is stored as a raw Postgres string because there is not guaranetee about the encoding. It might be UTF-8 but it also might not be.</p>
 382: <p>The above answer does a great job of explaining what it is, but doesn't answer how you get the value as a string. To pull the value as hex (which is the only thing that makes sense for a policy hash for example), you would encode it like so:</p>
<pre><code>SELECT encode(policy::bytea, 'hex') AS policy_hex FROM multi_asset LIMIT 3;
</code></pre>
<p>Likewise, if you want to use a WHERE clause against it, you would decode it:</p>
<pre><code>SELECT * FROM multi_asset WHERE policy = decode('00000002df633853f6a47465c9496721d2d5b1291b8398016c0e87ae', 'hex');
</code></pre>
<p>The asset name itself may make sense as ASCII/UTF8 or it might not. There's no guarantees in the system that an asset name resembles anything so should always be treated as raw hex as well and get the actual asset information from the metadata server or metadata on the minting transaction that explains what it actually represents.</p>
