Skip to content

Commit

Permalink
clarify UpdatedAtMixin compatiblity
Browse files Browse the repository at this point in the history
  • Loading branch information
bfontaine committed Feb 29, 2024
1 parent 2603a32 commit 9af8d79
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Unreleased

* Document `UpdatedAtMixin`’s incompatibility with Postgres (#1)
* Document `UpdatedAtMixin`’s compatibility with Postgres (#1)

## 0.1.0 (2023/03/30)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ class MyModel(Base, CreatedAtMixin):

* `CreatedAtMixin`: add a `created_at` datetime field that’s automatically filled with the record’s creation date
* `UpdatedAtMixin`: add an `updated_at` datetime field that’s automatically filled with the record’s last update date.
Note this doesn't work on Postgres; you have to [create a trigger](https://stackoverflow.com/a/71072370/735926).
Note that on Postgres this is done in Python; for a database-level update you have to [create a trigger](https://stackoverflow.com/a/71072370/735926).
* `CreatedUpdatedAtMixin`: combined version of the previous two mixins
3 changes: 2 additions & 1 deletion bixomix/dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ class CreatedAtMixin:
class UpdatedAtMixin:
"""
SQLAlchemy mixin to add an `updated_at` datetime field to a table that’s set to `NOW()` every time the row is updated.
Note that on Postgres this creates the column but doesn't update it.
Note that on Postgres this creates the column but update it only from Python. If you need database-level update, use
a trigger.
See https://stackoverflow.com/a/71072370/735926 for a possible solution.
"""
# NOTE:
Expand Down

0 comments on commit 9af8d79

Please sign in to comment.