drizzle-team / drizzle-team/drizzle-orm
[BUG]: The update method returns the updated information even when a non-existent key is used to update a value.
- 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.30.4
### What version of `drizzle-kit` are you using?
0.20.14
### Describe the Bug
As the title, the update method returns the updated information even when a non-existent key is used to update a value. For example, the below result is `[{ updatedUserId: 2 }]`, however, `age` column does not exist.
```sh
curl -X 'PATCH' \
'http://localhost:8787/users/2' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{"age": 2}'
```
```typescript:index.ts
import type { User } from './schema'
...
const app = new Hono()
app.patch(
'/users',
async (c) => {
const userId = c.req.param('id')
const body = await c.req.json()
const result = await db
.update(users)
.set(body)
.where(eq(users.id, Number(userId)))
.returning({ updatedUserId: users.id })
console.log(result)
return c.json({ ok })
}
)
```
```typescript:schema.ts
export const users = sqliteTable('users', {
id: integer('id').primaryKey({ autoIncrement: true }),
name: text('name').unique(),
})
export type User = typeof users.$inferSelect
```
### Expected behavior
Non-existent column error occurs.
### Environment & setup
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.