rmtm
rmtm
DTDrizzle Team
Created by rmtm on 8/16/2023 in #help
Binary typing for Mysql & typescript
Okay so I finally figured this out, turns out the string type is correct as MYSQL accepts hex strings as input to a binary row. This might not be the most efficient way of handling this but it does seem to work
tx.insert(auth).values({signingKey: sql`UNHEX(${signKeyBytesString})`})

await db.select({
signingKey: sql<string>`HEX(${auth.signingKey})`,
}).from(auth).limit(1).where(...);
tx.insert(auth).values({signingKey: sql`UNHEX(${signKeyBytesString})`})

await db.select({
signingKey: sql<string>`HEX(${auth.signingKey})`,
}).from(auth).limit(1).where(...);
4 replies
DTDrizzle Team
Created by rmtm on 8/16/2023 in #help
Binary typing for Mysql & typescript
I've also tried just pushing the binary as-is into a string
const signKeyMessyString = String.fromCharCode(...signKeyBytes);
const signKeyMessyString = String.fromCharCode(...signKeyBytes);
but it's then complaining about the length (even though signKeyMessyString.length = 32).
4 replies