Repository: meltano/sdk
Pull request #2580 (2024-07-31 00:17:29)

fix: Date fields are now properly serialized as ISO dates, i.e. "YYYY-MM-DD"


<!-- readthedocs-preview meltano-sdk start -->
----
📚 Documentation preview 📚: https://meltano-sdk--2580.org.readthedocs.build/en/2580/

<!-- readthedocs-preview meltano-sdk end -->

codspeed-hq[bot]: ## [CodSpeed Performance Report](https://codspeed.io/meltano/sdk/branches/1831-bug-json-serialization-of-date-types-causes-schema-validation-to-fail-in-target-postgres)

### Merging #2580 will **not alter performance**

<sub>Comparing <code>1831-bug-json-serialization-of-date-types-causes-schema-validation-to-fail-in-target-postgres</code> (44559be) with <code>main</code> (cb163bf)</sub>



### Summary

`✅ 6` untouched benchmarks





codecov[bot]: ## [Codecov](https://app.codecov.io/gh/meltano/sdk/pull/2580?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=meltano) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 89.47%. Comparing base [(`cb163bf`)](https://app.codecov.io/gh/meltano/sdk/commit/cb163bf05aa1357e6b140bdbbaca5ebe9a11743f?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=meltano) to head [(`44559be`)](https://app.codecov.io/gh/meltano/sdk/commit/44559be72bbf3024546bb75edcc629b74ceda767?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=meltano).
> Report is 1 commits behind head on main.

<details><summary>Additional details and impacted files</summary>


```diff
@@           Coverage Diff           @@
##             main    #2580   +/-   ##
=======================================
  Coverage   89.47%   89.47%           
=======================================
  Files          58       58           
  Lines        4799     4799           
  Branches      937      937           
=======================================
  Hits         4294     4294           
  Misses        352      352           
  Partials      153      153           
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/meltano/sdk/pull/2580?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=meltano).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=meltano).


Patch:
diff --git a/singer_sdk/helpers/_typing.py b/singer_sdk/helpers/_typing.py
index 2ccb9c47..1e7370fd 100644
--- a/singer_sdk/helpers/_typing.py
+++ b/singer_sdk/helpers/_typing.py
@@ -511,7 +511,7 @@ def _conform_primitive_property(  # noqa: PLR0911
     if isinstance(elem, (datetime.datetime,)):
         return to_json_compatible(elem)
     if isinstance(elem, datetime.date):
-        return f"{elem.isoformat()}T00:00:00+00:00"
+        return elem.isoformat()
     if isinstance(elem, datetime.timedelta):
         epoch = datetime.datetime.fromtimestamp(0, UTC)
         timedelta_from_epoch = epoch + elem


Test patch:
diff --git a/tests/core/test_typing.py b/tests/core/test_typing.py
index 66182c52..5043c75e 100644
--- a/tests/core/test_typing.py
+++ b/tests/core/test_typing.py
@@ -294,7 +294,7 @@ def test_conform_primitives():
     )
     assert (
         _conform_primitive_property(datetime.date(2020, 5, 17), {"type": "string"})
-        == "2020-05-17T00:00:00+00:00"
+        == "2020-05-17"
     )
     assert (
         _conform_primitive_property(datetime.timedelta(365), {"type": "string"})