Skip to content

v2.8.0

Choose a tag to compare

@github-actions github-actions released this 16 Sep 15:02
· 26 commits to main since this release
Immutable release. Only release title and notes can be modified.
v2.8.0
fa94488

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 of filters to 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 as score:gt are no longer accepted
    and raise ValueError.
  • The filters and data passed to db_upsert must together form a valid
    row to insert, even when the row already exists, since Postgres checks
    NOT NULL constraints before it detects the conflict.
  • db_upsert without data updates the existing row to its own key values
    instead of selecting it, so it takes a row lock and fires UPDATE triggers.
  • Column onupdate defaults are not applied when db_upsert updates an
    existing row.

New features

  • CrudDB.db_upsert_many
    upserts a list of records on the given key columns, in batches of
    batch_size records (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.