golem icon indicating copy to clipboard operation
golem copied to clipboard

Inconsistent add / get: services that use RDB should return entities as they were stored in the RDB

Open noise64 opened this issue 5 months ago • 0 comments

Example side effect of not doing it:

Currently component add and update "sometimes" returns more fractional seconds compared to component get. This resulted in breaking cli-test on CI when the created_at field was added to the returned fields, but it did not happen on macos (locally). This is because:

  • the current macos clock has lower resolution then what our ci linux + hw provides.
  • the type we use in the DB has a smaller resolution then the linux one
  • services return the entity passed to the DB repos, and not what actually got inserted

Recommended fix

For now we apply some workarounds in the tests, but the recommendation would be to use "Insert .... Returning" in the repos, and return the actually saved data in services.

Note that this is also advisable in general, not just because of date times, because as the DB evolves it might get more and more logic compared to the DTOs (like default values, trimming, etc)

noise64 avatar Sep 17 '24 15:09 noise64