Rph
Rph
Explore posts from servers
DTDrizzle Team
Created by sammccord on 1/18/2024 in #help
Issue querying with relations in bun+sqlite
🤔
17 replies
DTDrizzle Team
Created by sammccord on 1/18/2024 in #help
Issue querying with relations in bun+sqlite
but forcing drizzle-orm to the latest version (which has this code change) doesn't seem to work
17 replies
DTDrizzle Team
Created by sammccord on 1/18/2024 in #help
Issue querying with relations in bun+sqlite
I also found this PR: https://github.com/drizzle-team/drizzle-orm/pull/1885 that seems to already be merged
17 replies
DTDrizzle Team
Created by sammccord on 1/18/2024 in #help
Issue querying with relations in bun+sqlite
opened last year
17 replies
DTDrizzle Team
Created by sammccord on 1/18/2024 in #help
Issue querying with relations in bun+sqlite
oh, it seems there is a PR for this already: https://github.com/drizzle-team/drizzle-orm/pull/1276
17 replies
DTDrizzle Team
Created by sammccord on 1/18/2024 in #help
Issue querying with relations in bun+sqlite
I did some more debugging, it seems like the better-sqlite3 driver calls
const row = stmt.raw().get(...params);
const row = stmt.raw().get(...params);
which returns an array of values ([ '0.9687278431702451', '[["0.07639715656862389","0.9687278431702451"]]'] in this example) after this block
if (!fields && !customResultMapper) {
return stmt.get(...params);
}
if (!fields && !customResultMapper) {
return stmt.get(...params);
}
inside PreparedQuery.get where the get would return a mapped value. Meanwhile, the bun driver seemingly always calls the api to get a mapped value ( const row = this.stmt.get(...params);) and works with that value for the rest of the PreparedQuery.get function, including in parts where an array is expected
17 replies
DTDrizzle Team
Created by sammccord on 1/18/2024 in #help
Issue querying with relations in bun+sqlite
hey @alexblokh, are you aware of this issue/discrepancy in behavior between the better-sqlite3 and bun:sqlite driver?
17 replies
DTDrizzle Team
Created by sammccord on 1/18/2024 in #help
Issue querying with relations in bun+sqlite
which orm are you using now, out of curiosity?
17 replies
DTDrizzle Team
Created by sammccord on 1/18/2024 in #help
Issue querying with relations in bun+sqlite
I feel like this is an issue to be resolved at the bun-sqlite driver level, since there could be other behaviors that depend on the row being an array
17 replies
DTDrizzle Team
Created by sammccord on 1/18/2024 in #help
Issue querying with relations in bun+sqlite
Maybe someone from the drizzle team could take a look at this?
17 replies
DTDrizzle Team
Created by sammccord on 1/18/2024 in #help
Issue querying with relations in bun+sqlite
but i am unsure if this breaks something or not
17 replies
DTDrizzle Team
Created by sammccord on 1/18/2024 in #help
Issue querying with relations in bun+sqlite
i was able to get it to work by adding this:
if (!Array.isArray(row)) {
let or = row;
row = [];
for (let b of buildQueryResultSelection) {
row.push(or[b.dbKey]);
}
}
if (!Array.isArray(row)) {
let or = row;
row = [];
for (let b of buildQueryResultSelection) {
row.push(or[b.dbKey]);
}
}
on line 262 of node_modules/drizzle-orm/relations.js
17 replies
DTDrizzle Team
Created by sammccord on 1/18/2024 in #help
Issue querying with relations in bun+sqlite
I've ran into this same issue, @sammccord were you ever able to resolve this?
17 replies
DTDrizzle Team
Created by Rph on 9/3/2023 in #help
Get plain typescript type from enum
My app is purely server side rendered, so I have no worries about client code, the whole thing is a Nest codebase
6 replies
DTDrizzle Team
Created by Rph on 9/3/2023 in #help
Get plain typescript type from enum
Okay I figured out, though I'd appreciate feedback on if this is the "correct way" to do this:
permissions: typeof users.$inferSelect.permissionLevel
permissions: typeof users.$inferSelect.permissionLevel
6 replies