drizzle-team / drizzle-team/drizzle-orm
[BUG]: undefined field occurs when using full join without specify select field
- Dominant language
- TypeScript
- Stars
- 35.8k
- Forks
- 1.6k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 4
Description
### What version of `drizzle-orm` are you using?
0.29.3
### What version of `drizzle-kit` are you using?
0.20.13
### Describe the Bug
It looks like that when using full join without specify select field, the result which return from query does not have value from the last column in joined table. This behavior happens in `drizzle-orm/bun-sqlite`
```ts
const queryData = async () => {
const projectEntry = await db
.select()
.from(schema.projects)
.fullJoin(schema.users, eq(schema.users.userId, schema.projects.userId))
.where(eq(schema.users.userId, "1234"));
console.log(projectEntry); // <- This one returns missing users.testing
const projectEntry2 = await db
.select({
userId: schema.users.userId,
projectId: schema.projects.projectId,
data: schema.users.data,
testing: schema.users.testing
})
.from(schema.projects)
.fullJoin(schema.users, eq(schema.users.userId, schema.projects.userId))
.where(eq(schema.users.userId, "1234"));
console.log(projectEntry2); // <- users.testing is found
};
```
if we clone the repository below and run it, it will give these results
```
[
{
projects: {
userId: "1234",
projectId: "Hello World",
},
users: {
userId: "1234",
data: "Hello world",
testing: undefined,
},
}
]
[
{
userId: "1234",
projectId: "Hello World",
data: "Hello world",
testing: "Hello 1234",
}
]
```
### Expected behavior
`users.testing` value should not be undefined
```
[
{
projects: {
userId: "1234",
projectId: "Hello World",
},
users: {
userId: "1234",
data: "Hello world",
testing: "Hello 1234",
},
}
]
```
### Environment & setup
- Repository: https://github.com/miello/poc-drizzle-bun-sqlite
- OS: Windows 10 on Ubuntu WSL2
- Runtime: Bun@1.0.22
Contributor guide
Assessment
This issue has not been assessed yet.