Closed Yihao-G closed 1 year ago
Firstly thanks for your great work.
It seems if I access an index-out-of-bound element in the returned array of raw(), it returns a function rather than undefined:
raw()
undefined
const stmt = binding<D1Database>('D1').prepare( 'SELECT author, post_slug FROM comments LIMIT 0', ); const raw = await stmt.raw(); expect(raw[0]).toBeUndefined(); // AssertionError: expected [Function] to be undefined
The raw[0] function seems to be pointing to here: https://github.com/james-elicx/cf-bindings-proxy/blob/a19f37277a742ff9333675c8d0af977a2c822dc9/src/proxy.ts#L68-L72
raw[0]
Drizzle ORM checks if there is a row in the returned result by checking if raw[0] is truthy. Because of this issue, Drizzle will return an object with every field set to undefined instead: https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-orm/src/d1/session.ts#L139-L141
Hey there, thanks for raising this. I've just added a fix and it is included in the latest release (v0.2.4).
Works like a charm! Thank you so much for such a speedy response!
Firstly thanks for your great work.
It seems if I access an index-out-of-bound element in the returned array of
raw()
, it returns a function rather thanundefined
:The
raw[0]
function seems to be pointing to here: https://github.com/james-elicx/cf-bindings-proxy/blob/a19f37277a742ff9333675c8d0af977a2c822dc9/src/proxy.ts#L68-L72Drizzle ORM checks if there is a row in the returned result by checking if
raw[0]
is truthy. Because of this issue, Drizzle will return an object with every field set toundefined
instead: https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-orm/src/d1/session.ts#L139-L141