binary columns in drizzle studio

I have implemented the following custom type for storing blockchain addresses:
const address = customType<{ data: string; driverData: Buffer }>({
dataType: () => 'BINARY(20)',
fromDriver(value) {
return '0x' + value.toString('hex')
},
toDriver(value: string) {
return sql`UNHEX(${value.replace('0x', '')})`
},
})
const address = customType<{ data: string; driverData: Buffer }>({
dataType: () => 'BINARY(20)',
fromDriver(value) {
return '0x' + value.toString('hex')
},
toDriver(value: string) {
return sql`UNHEX(${value.replace('0x', '')})`
},
})
It works fine but it looks like this in the studio (see the image):
{"type":"Buffer","data":[5,28,95,169,85,206,197,80,50,253,93,23,182,67,212,62,249,70,208,56]}
{"type":"Buffer","data":[5,28,95,169,85,206,197,80,50,253,93,23,182,67,212,62,249,70,208,56]}
It is pretty annoying because it is impossible to see or copy any address from the studio, nor use them as filters. I do not know if there is any better solution at the moment for my problem. I tried to use the built-in binary type but I haven't managed to insert any address with it.
No description
1 Reply
roman910
roman910OP13mo ago
[UPDATE] I updated bot drizzle-orm and drizzle-kit to the latest available versions (0.28.6 and 0.19.3 respectively) and the problem has disappeared. You can still not use the filters of studio with these columns but at least the values display as addresses now (using the format I specified in the custom type).
Want results from more Discord servers?
Add your server