Skip to content

Commit dd411b5

Browse files
Update views.py
1 parent ce8989d commit dd411b5

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

frameworks/Python/aiohttp/app/views.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import ujson
88
from aiohttp.web import Response, json_response
99
from sqlalchemy import select
10+
from sqlalchemy.orm.attributes import flag_modified
1011

1112
from .models import sa_fortunes, sa_worlds, Fortune, World
1213

@@ -137,6 +138,9 @@ async def updates(request):
137138
for id_, number in updates:
138139
world = await sess.get(World, id_, populate_existing=True)
139140
world.randomnumber = number
141+
# Force sqlalchemy to UPDATE entry even if the value has not changed
142+
# doesn't make sense in a real application, added only to pass tests.
143+
flag_modified(world, "randomnumber")
140144
return json_response(worlds)
141145

142146
async def updates_raw(request):

0 commit comments

Comments
 (0)