FindFirst vs FindMany and Select

My goal is to just retrieve a candidate by it's id (the primary key of the Candidate table) I'm using Bun sqlite as the database I've written my query with select, findFirst and findMany but even though they generate the same sql query it does not give me results with findFirst. Could someone help me understand what i did wrong please ? ^^'
const candidate: Candidate | undefined = await db.query.candidates.findFirst({
where: eq(candidates.id, +params.id)
});

const allCandidates = await db.select()
.from(candidates)
.where(eq(candidates.id, +params.id))
.limit(1);

const allCandidates2 = await db.query.candidates.findMany({
where: eq(candidates.id, +params.id),
limit: 1
});
const candidate: Candidate | undefined = await db.query.candidates.findFirst({
where: eq(candidates.id, +params.id)
});

const allCandidates = await db.select()
.from(candidates)
.where(eq(candidates.id, +params.id))
.limit(1);

const allCandidates2 = await db.query.candidates.findMany({
where: eq(candidates.id, +params.id),
limit: 1
});
No description
5 Replies
Angelelz
Angelelz10mo ago
This is crazy! exact same queries, different result Can you create a repooduction repo? I'd like to investigate
Ly4m
Ly4mOP10mo ago
Will do ! I didn't specify but I'm using bun sqlite
Angelelz
Angelelz10mo ago
It's probably related. This is a well tested API, at least in node
Ly4m
Ly4mOP10mo ago
I Opened an Issue : https://github.com/drizzle-team/drizzle-orm/issues/1882 With the following reproduction repo : https://github.com/Ly4m/drizzle-bun-sqlite-findfirst I was able to narrow down the issue to a simple findFirst query
Angelelz
Angelelz10mo ago
Excellent, I'll look into it today
Want results from more Discord servers?
Add your server