Skip to content

Single attachment#376

Draft
eric-pSAP wants to merge 20 commits intomainfrom
singleAttachment
Draft

Single attachment#376
eric-pSAP wants to merge 20 commits intomainfrom
singleAttachment

Conversation

@eric-pSAP
Copy link
Contributor

Allowing attachments to be assignable as a type. Allows for only 1 single attachment instead of a composition of many.

@hyperspace-insights
Copy link
Contributor

Summary

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


Add Support for Single Attachment Type

New Features

✨ Introduced a new Attachment type that allows entities to have a single attachment instead of requiring a composition of many attachments. This provides more flexibility in modeling data where only one attachment is needed.

Changes

Core Schema Updates:

  • db/index.cds: Added new Attachment type derived from sap.attachments.SingleMediaData and introduced SingleMediaData type definition with media data properties (url, content, mimeType, filename, hash, status, lastScan)

Service Layer Improvements:

  • srv/basic.js:
    • Refactored attachment deletion logic to improve draft handling
    • Fixed draft entity deletion to use req.data?.ID instead of diff-based approach
    • Optimized attachDeletionData() method to compare active and draft attachments directly instead of using diff operations
    • Enhanced attachNonDraftDeletionData() to handle single attachment deletions
    • Minor code style improvements (semicolon consistency)

Test Application Updates:

  • tests/incidents-app/db/schema.cds: Added new SingleAttachment entity to demonstrate single attachment usage
  • tests/incidents-app/db/attachments.cds: Extended SingleAttachment entity with myAttachment field of type Attachment
  • tests/incidents-app/srv/services.cds: Exposed SingleAttachment entity as draft-enabled service
  • tests/incidents-app/app/incidents/annotations.cds: Added UI annotations for SingleAttachment including LineItem, Facets, and FieldGroup definitions

Test Coverage:

  • tests/integration/attachments.test.js:
    • Added comprehensive test suite for single attachment entity functionality
    • Verified creation, activation, and deletion of single attachments
    • Added test to ensure discarding a saved draft does not delete attachment content
    • Improved code style consistency across existing tests
    • Fixed various semicolon inconsistencies throughout test file

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

Version: 1.17.61 | 📖 Documentation | 🚨 Create Incident | 💬 Feedback

  • Output Template: Default Template
  • Event Trigger: pull_request.opened
  • LLM: anthropic--claude-4.5-sonnet
  • Correlation ID: e0eda0c0-0ccb-11f1-993b-86fda88b4de0
  • Summary Prompt: Default Prompt

💌 Have ideas or want to contribute? Create an issue and share your thoughts with us!
📑 Check out the documentation for more information.
📬 Subscribe to the Hyperspace PR Bot DL to get the latest announcements and pilot features!

Made with ❤️ by Hyperspace.

Copy link
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.

Summary

This PR introduces several substantive issues: the SingleMediaData type has an incorrectly defined association that won't work with types (only entities support associations), and the attachDeletionData method contains unsafe array operations that could fail when attachments lack ID fields. Additionally, the test schema redundantly redefines the ID key. These should be addressed before merging.

PR Bot Information

Version: 1.17.61 | 📖 Documentation | 🚨 Create Incident | 💬 Feedback

  • Correlation ID: e0eda0c0-0ccb-11f1-993b-86fda88b4de0
  • Event Trigger: pull_request.opened
  • LLM: anthropic--claude-4.5-sonnet

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.

1 participant