-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Report hasn't been filed before.
- I have verified that the bug I'm about to report hasn't been filed before.
What version of drizzle-orm
are you using?
0.36.3
What version of drizzle-kit
are you using?
0.28.1
Other packages
No response
Describe the Bug
When using the nested object syntax with a leftJoin, I found a bug where the order of the properties defined if the all nested object is null. It looks like it only look the first field to define if the nested object will be defined.
My address table:
export const addressTable = pgTable("address", {
latitude: customDecimal().notNull(),
longitude: customDecimal().notNull(),
name: text(),
}, (table) => [
index().on(table.latitude, table.longitude),
]);
In this query, if my addressName is null, the all object is null even if the latitude and longitude is set.
db.select({
id: sessionTable.id,
inPersonDetails: {
addressName: addressTable.name,
addressLatitude: addressTable.latitude,
addressLongitude: addressTable.longitude,
}
})
.from(sessionTable)
.leftJoin(addressTable, eq(addressTable.id, sessionTable.addressId))
The address is not mandatory but in my test it was set.
But if I but the addressName at the end of the object, even if the addressName is null I still receive my inPersonDetails object with my latitude and longitude. (This is the behavior that is the more logical to me.
db.select({
id: sessionTable.id,
inPersonDetails: {
addressLatitude: addressTable.latitude,
addressLongitude: addressTable.longitude,
addressName: addressTable.name,
}
})
.from(sessionTable)
.leftJoin(addressTable, eq(addressTable.id, sessionTable.addressId))
antoinerochat
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working