Skip to content

feat: dynamic datetime formatting with service-level @changelog and @Common.TimeZone#322

Open
stefanrudi wants to merge 4 commits into
mainfrom
feat/srv-timezone
Open

feat: dynamic datetime formatting with service-level @changelog and @Common.TimeZone#322
stefanrudi wants to merge 4 commits into
mainfrom
feat/srv-timezone

Conversation

@stefanrudi
Copy link
Copy Markdown
Contributor

Previously, @Common.TimeZone properties for dynamic datetime formatting were only collected when the database entity had a @changelog annotation. This PR extends this behavior to support both @changelog and @Common.TimeZone annotations just defined at the service level.

Closes #307

@stefanrudi stefanrudi requested a review from a team as a code owner May 22, 2026 12:15
@hyperspace-insights
Copy link
Copy Markdown
Contributor

Summary

The following content is AI-generated and provides a summary of the pull request:


Support @Common.Timezone with Service-Level @changelog for Dynamic DateTime Formatting

New Features

✨ Extended the @Common.Timezone timezone resolution logic to support entities where @changelog is defined only at the service level. Previously, valueTimeZone in ChangeView was populated only when @changelog was annotated at the DB schema level. This fix enables use cases where the same DB entity is reused across multiple services, and the changelog facet needs to be selectively enabled per service without polluting the DB layer.

Changes

  • lib/csn-enhancements/timezoneProperties.js: Refactored collectTrackedPropertiesWithTimezone to handle both DB-level and service-level entities. Added a deduplication map (collected), DB entity resolution via getBaseEntity, element name mapping via getDbElementName, and annotation normalization via normalizeAnnotationRefs. Extracted a _buildTimezoneValue helper for constructing dynamic timezone sub-SELECTs.
  • lib/utils/entity-collector.js: Updated _extractServiceAnnotations to use _getDbElementName for proper element name mapping (handles renamed/flattened columns). Exported normalizeAnnotationRefs and getDbElementName for use in timezone properties logic.
  • tests/bookshop/db/index.cds: Added new test fields (srvDateTimeWTZ, srvDateTimeWDTZ, srvRenamedDateTimeWDTZ, plainDateTime) to support service-level timezone annotation test scenarios.
  • tests/bookshop/srv/feature-testing.cds: Added new service projections (ServiceLevelTimezoneRenamed, ServiceOnlyTimezoneRenamed) and annotations to cover renamed columns and fully service-level @changelog + @Common.Timezone combinations.
  • tests/integration/cds-features.test.js: Added four new integration test cases covering static timezone, dynamic timezone, renamed columns with dynamic timezone, and fully service-level timezone resolution. Also cleaned up repeated testingSRV.entities references using destructuring.
  • CHANGELOG.md: Documented the new feature under v2.0.0-beta.13.

Jira Issues

GitHub Issues:

  • #307: Layer for annotation of DateTime with time zone context

  • 🔄 Regenerate and Update Summary
  • ✏️ Insert as PR Description (deletes this comment)
  • 🗑️ Delete comment
PR Bot Information

Version: 1.20.51

Copy link
Copy Markdown
Contributor

@hyperspace-insights hyperspace-insights Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR introduces solid support for service-level @Common.Timezone with @changelog, but there are a few substantive issues: a potential silent data-loss path in _buildTimezoneValue for ref-style annotations, a first-writer-wins deduplication that can silently drop service-level timezone overrides, a fragile implicit contract in elementAnnotations key naming, and a missing UPDATE assertion in the renamed-columns timezone test. Please address these before merging.

PR Bot Information

Version: 1.20.51

  • Event Trigger: pull_request.opened
  • File Content Strategy: Full file content
  • LLM: anthropic--claude-4.6-sonnet
  • Correlation ID: 05e72fdb-9918-4c15-9f0d-b191c74d62b7

Comment thread lib/csn-enhancements/timezoneProperties.js
Comment thread lib/csn-enhancements/timezoneProperties.js
Comment thread lib/utils/entity-collector.js Outdated
Comment thread tests/bookshop/srv/feature-testing.cds
Comment thread tests/integration/cds-features.test.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Layer for annotation of DateTime with time zone context

1 participant