Bholmesdev
Bholmesdev
Explore posts from servers
DTDrizzle Team
Created by Bholmesdev on 9/9/2024 in #help
`ilike` in sqlite
We received an issue on the Astro repo recently about ilike support for our SQLite driver. We decided not to expose ilike as a utility, since we noticed it was incompatible with sqlite on the Drizzle docs: https://orm.drizzle.team/docs/operators#ilike That said, it seems strange that ilike is incompatible but notIlike is. Can someone confirm the documentation badge is correct?
2 replies
DTDrizzle Team
Created by Bholmesdev on 7/26/2023 in #help
sqlite http-proxy can't handle undefined values on `.get()` ?
Hi drizzle team! I've been playing with the http-proxy plugin to see how it works, and I hit a funny edge case trying to handle undefined values on get(). The docs show this barebones example to set up an http proxy:
const db = drizzle(async (sql, params, method) => {
try {
const rows = await axios.post('http://localhost:3000/query', { sql, params, method });

return { rows: rows.data };
} catch (e: any) {
console.error('Error from sqlite proxy server: ', e.response.data)
return { rows: [] };
}
});
const db = drizzle(async (sql, params, method) => {
try {
const rows = await axios.post('http://localhost:3000/query', { sql, params, method });

return { rows: rows.data };
} catch (e: any) {
console.error('Error from sqlite proxy server: ', e.response.data)
return { rows: [] };
}
});
They, I attempted a .get() request for a value that doesn't exist in the database:
const email = await db.select().from(emails).where(eq(emails.email, '[email protected]')).get();
const email = await db.select().from(emails).where(eq(emails.email, '[email protected]')).get();
I tested the better-sqlite3 adapter and found email should return undefined (which doesn't match the type inference mind you!). But in the SQlite proxy, I get a much funnier result:
email = {
id: undefined,
email: undefined,
submitted: Invalid Date
}
email = {
id: undefined,
email: undefined,
submitted: Invalid Date
}
It seems it's trying to parse the value even when rows is an empty array in the adapter. Is there a way to return undefined for this case as in the better-sqlite adapter? Thanks!
24 replies