where(gt) with timestamp returns wrong result

Might be a SQL inherent thing, but I'm a bit puzzled as to why this happens:

Edit: for terseness I left out some code. I think the issue is clear

const firstThing = await db.insert(table).values({ timestamp: new Date() })
const secondThing = await db.insert(table).values({ timestamp: new Date() })

const result = await db.query.table.findFirst({ where: gt(table.timestamp, firstThing.timestamp) })
console.log(result) // logs firstThing, not secondThing
Was this page helpful?