Cannot read properties of undefined (reading '0')

Ttacomanator3/27/2023
What is the expected behavior when using get() when there would be no matching results for a given select query? Does it return null or would this be an error? At present it's giving an error. I'm new to discord, but I guess I expected it to return a null. For example, the following query works and returns an empty array:
db.select().from(users).where(eq(users.email, email)).all();

whereas changing all() to get() results in error trying to access first element of an empty array (drizzle-orm/utils.js:40:37):

db.select().from(users).where(eq(users.email, email)).get();
Bbloberenober3/27/2023
Do you know what is the behavior of the raw driver in this case?
Bbloberenober3/27/2023
We tried to model the execution methods in SQLite the same way they work in raw drivers
Ttacomanator3/28/2023
I'm using better-sqlite3. Assuming the equivalent statement is something like:
db.prepare("SELECT * FROM users WHERE email = ?").get(email);

If there are no matching records, there is no error and the result will be undefined.

The error happens at line 34 of utils.ts:

https://github.com/drizzle-team/drizzle-orm/blob/70ff50bb7c9bd956bae8cceca937374614576c11/drizzle-orm/src/utils.ts#L34

The driver is returning undefined for the row value (as expected), but the mapResultRow is not checking for that, and attempts the process the values anyway. Before logging a bug I thought I had better check if this is expected or not.
Bbloberenober3/28/2023
Thanks! We'll definitely check and fix once we figure out our current stuff 🫠