🔧 v2.1.6 Improve sync hooks, allow index-only upserts, and bugfixes. #152
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
v2.1.6
Move
success_tuple
from arg to kwarg for@post_sync_hook
functions.To match the signature of
@pre_sync_hook
functions,@post_sync_hook
functions now only acceptpipe
as the positional argument. The return value of the sync will now be passed as the kwargsuccess_tuple
. This allows you to use the same callback function as both the pre- and post-sync hooks.Add
sync_timestamp
andsync_complete_timestamp
to sync hooks.The UTC datetime right before the sync is added to the sync hook kwargs, allowing for linking the two callbacks to the same datetime. For convenience, the UTC datetime is also captured at the end of the sync and is passed as
sync_complete_timestamp
.Improved performance of sync hooks.
Sync hooks are now called asynchronously in their own threads to avoid slowing down or crashing the main thread.
Rename
duration
tosync_duration
for sync hooks.To avoid potential conflicts, the kwarg
duration
is prefixed withsync_
to denote that it was specifically added to provide context on the sync.Allow for sync hooks to return
SuccessTuple
.If a sync hook returns a
SuccessTuple
(Tuple[bool, str]
), the result will be printed.Add
is_success_tuple()
tomeerschaum.utils.typing
.You can now quickly check whether an object is a
SuccessTuple
:Allow for index-only pipes when
upsert=True
.If all columns are indices and
upsert
isTrue
, then the upsert will insert net-new rows (ignore duplicates).Allow for prelimary null index support for
upsert=True
(inserts only, PostgreSQL only).Like with regular syncs, upsert syncs now coalesce indices to allow for syncing null values. NOTE: the transaction will fail if a null index is synced again, so this is only for the initial insert.
Remove automatic instance table renaming.
This patch removes automatic detection and renaming of old instance tables to the new names (e.g.
users
->mrsm_users
). Users migrating from an old installation will need to rename the tables manually themselves.