- Notifications
You must be signed in to change notification settings - Fork 41
Closed
Description
AFAICT, this library does not support retrieving binary as binary.
I added some code inspired by custom type casting function:
function inflate(field, value) { console.log("field.type", field.type) console.log("value", value) console.log("value type", typeof value) return cast(field, value) }When I do so, here is some representative output of some UUIDs:
field.type BINARY value ø0sô¼A¤ÿçÐsô value type string field.type BINARY value AD3ADFB038724973 value type string field.type BINARY value type string Yes, the third value is missing - it is seemingly unprintable and silently killed that console.log. This isn't surprising because not all binary is valid utf-8.
Some code, if you want gory details.
create table Media_User ( mediaId binary(16) not null, userId varchar(21) not null, primary key (mediaId, userId) ) collate = utf8mb4_unicode_ci; INSERT INTO Media_User (mediaId, userId) VALUES (0x11f830737ff4bc41a4ffe792d073f41f, 'ff') INSERT INTO Media_User (mediaId, userId) VALUES (0x41443341444642303338373234393733, 'ff') INSERT INTO Media_User (mediaId, userId) VALUES (0x737295711B1121479411906BBD2F7A34, 'ff') import { connect, cast } from "@planetscale/database" const config = { cast: inflate, url: somethngSecret, } const conn = connect(config) const results = await conn.execute("select mediaId from planetScaleDb.Media_User") console.log("------------------") console.log(results.rows[0]) console.log(results.rows[1]) console.log(results.rows[2])This occurs for me on cloudflare workers (and miniflare).
Metadata
Metadata
Assignees
Labels
No labels