Skip to content

Commit 897b44a

Browse files
paulovieiraporsager
authored andcommitted
readme: add correction in the "Multiple updates in one query" section
In the "Multiple updates in one query" it seems it is necessary to do explicit type casting if the data type is not text (in both the SET and WHERE clauses). If not, I see one of these errors: - `column "sort_order" is of type integer but expression is of type text` - `operator does not exist: integer = text` I also added the "returning" at the end to confirm that the data was updated.
1 parent c2fe67b commit 897b44a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,10 @@ const users = [
242242
]
243243

244244
sql`
245-
update users set name = update_data.name, age = update_data.age
245+
update users set name = update_data.name, (age = update_data.age)::int
246246
from (values ${sql(users)}) as update_data (id, name, age)
247-
where users.id = update_data.id
247+
where users.id = (update_data.id)::int
248+
returning users.id, users.sort_order
248249
`
249250
```
250251

0 commit comments

Comments
 (0)