Skip to content

Commit

Permalink
bumped version
Browse files Browse the repository at this point in the history
  • Loading branch information
dantownsend committed Sep 24, 2024
1 parent 9467248 commit c93a370
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
36 changes: 36 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,42 @@
Changes
=======

1.19.0
------

Added support for row locking (i.e. ``SELECT ... FOR UPDATE``).

For example, if we have this table:

.. code-block:: python
class Concert(Table):
name = Varchar()
tickets_available = Integer()
And we want to make sure that ``tickets_available`` never goes below 0, we can
do the following:

.. code-block:: python
async def book_tickets(ticket_count: int):
async with Concert._meta.db.transaction():
concert = await Concert.objects().where(
Concert.name == "Awesome Concert"
).first().lock_rows()
if concert.tickets_available >= ticket_count:
await concert.update_self({
Concert.tickets_available: Concert.tickets_available - ticket_count
})
else:
raise ValueError("Not enough tickets are available!")
This means that when multiple transactions are running at the same time, it
isn't possible to book more tickets than are available.

-------------------------------------------------------------------------------

1.18.0
------

Expand Down
2 changes: 1 addition & 1 deletion piccolo/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__VERSION__ = "1.18.0"
__VERSION__ = "1.19.0"

0 comments on commit c93a370

Please sign in to comment.