diff --git a/airbyte-integrations/connectors/source-commcare/source_commcare/source.py b/airbyte-integrations/connectors/source-commcare/source_commcare/source.py index 5ade905c2618..f82445973c37 100644 --- a/airbyte-integrations/connectors/source-commcare/source_commcare/source.py +++ b/airbyte-integrations/connectors/source-commcare/source_commcare/source.py @@ -98,12 +98,16 @@ class IncrementalStream(CommcareStream, IncrementalMixin): @property def state(self) -> Mapping[str, Any]: - if self._cursor_value: - return {self.cursor_field: self._cursor_value} + return {self.cursor_field: self._cursor_value} @state.setter def state(self, value: Mapping[str, Any]): - self._cursor_value = datetime.strptime(value[self.cursor_field], self.dateformat) + if self.cursor_field in value: + if "Z" in value[self.cursor_field]: + date_format = "%Y-%m-%dT%H:%M:%S.%fZ" + else: + date_format = "%Y-%m-%dT%H:%M:%S.%f" + self._cursor_value = datetime.strptime(value[self.cursor_field], date_format) @property def sync_mode(self): @@ -140,7 +144,6 @@ def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapp class Case(IncrementalStream): - """ docs: https://www.commcarehq.org/a/[domain]/api/[version]/case/ """