Repository navigation
v2.8.0
·
26 commits
to main
since this release
Immutable
release. Only release title and notes can be modified.
Upserts are atomic and can write many rows at once. CrudDB.db_upsert now
runs a single INSERT ... ON CONFLICT (...) DO UPDATE statement, which
requires its lookup columns to match a unique constraint: see Breaking
changes below.
Breaking changes
- CrudDB.db_upsert
requires the columns offiltersto match exactly a primary key or unique
constraint of the table. Upserting on columns without one now fails with
there is no unique or exclusion constraint matching the ON CONFLICT specification. Filter operators such asscore:gtare no longer accepted
and raiseValueError. - The
filtersanddatapassed todb_upsertmust together form a valid
row to insert, even when the row already exists, since Postgres checks
NOT NULLconstraints before it detects the conflict. db_upsertwithoutdataupdates the existing row to its own key values
instead of selecting it, so it takes a row lock and firesUPDATEtriggers.- Column
onupdatedefaults are not applied whendb_upsertupdates an
existing row.
New features
- CrudDB.db_upsert_many
upserts a list of records on the given key columns, in batches of
batch_sizerecords (1000 by default) within a single transaction. Every
record must have the same columns and no two records can share a key. See
the upsert tutorial.