Skip to content

Commit 6fcf0cc

Browse files
authored
Merge pull request tecladocode#157 from tecladocode/jose/cou-332-fix-code-mismatch-between-lecture-video-ebook-and-github
🐛 fix(Item Update): Fix `ItemUpdateSchema` by adding `store_id`
2 parents 2fd689b + 19366be commit 6fcf0cc

File tree

1 file changed

+21
-0
lines changed
  • docs/docs/06_sql_storage_sqlalchemy/07_updating_models_sqlalchemy

1 file changed

+21
-0
lines changed

docs/docs/06_sql_storage_sqlalchemy/07_updating_models_sqlalchemy/README.md

+21
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,24 @@ def put(self, item_data, item_id):
3030
return item
3131
# highlight-end
3232
```
33+
34+
Our `ItemUpdateSchema` at the moment looks like this:
35+
36+
```python title="schemas.py"
37+
class ItemUpdateSchema(Schema):
38+
name = fields.Str()
39+
price = fields.Float()
40+
```
41+
42+
But since now our update endpoint may create items, we need to change the schema to optionally accept a `store_id`.
43+
44+
When updating an item, `name` or `price` (or both) may be passed, but when creating an item, `name`, `price`, and `store_id` must be passed.
45+
46+
Update the `ItemUpdateSchema` to this:
47+
48+
```python title="schemas.py"
49+
class ItemUpdateSchema(Schema):
50+
name = fields.Str()
51+
price = fields.Float()
52+
store_id = fields.Int()
53+
```

0 commit comments

Comments
 (0)