From 539873001a0810b23dfa010192c77287bc73288d Mon Sep 17 00:00:00 2001 From: "Edgar R. M" Date: Mon, 20 Jun 2022 23:03:10 -0500 Subject: [PATCH] fix: Check if RK is sortable before comparing (#737) * fix: Check if RK is sortable before comparing * Update changelog --- CHANGELOG.md | 1 + singer_sdk/helpers/_state.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e4cb50aab..3356487ee8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### New - Tap and Target SDK: Adds the ability to override the [logging level](https://sdk.meltano.com/en/latest/implementation/logging.html) via `LOGLEVEL` environment variables. ([!300](https://gitlab.com/meltano/sdk/-/merge_requests/300)) - Thanks, _**[Eric Boucher](https://gitlab.com/ericboucher)**_! +- Tap SDK: Compare replication key values when incrementing state, only if the `not check_sorted` flag is set to True ([#736](https://github.com/meltano/sdk/issues/736), [#737](https://github.com/meltano/sdk/pull/737)). ### Changes diff --git a/singer_sdk/helpers/_state.py b/singer_sdk/helpers/_state.py index 08bc5b26b1..57449348db 100644 --- a/singer_sdk/helpers/_state.py +++ b/singer_sdk/helpers/_state.py @@ -218,7 +218,7 @@ def increment_state( progress_dict = stream_or_partition_state[PROGRESS_MARKERS] old_rk_value = to_json_compatible(progress_dict.get("replication_key_value")) new_rk_value = to_json_compatible(latest_record[replication_key]) - if old_rk_value is None or new_rk_value >= old_rk_value or not check_sorted: + if old_rk_value is None or not check_sorted or new_rk_value >= old_rk_value: progress_dict["replication_key"] = replication_key progress_dict["replication_key_value"] = new_rk_value return