Skip to content

fix: enum lists are now sets#24

Merged
mvhenten merged 1 commit intomainfrom
fix-enum-type
Dec 3, 2025
Merged

fix: enum lists are now sets#24
mvhenten merged 1 commit intomainfrom
fix-enum-type

Conversation

@mvhenten
Copy link
Owner

@mvhenten mvhenten commented Dec 3, 2025

Fixes #21

Copilot AI review requested due to automatic review settings December 3, 2025 14:19
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the TypeSpec-to-ElectroDB emitter to correctly handle enum arrays by converting them to DynamoDB/ElectroDB "set" types instead of "list" types. This change ensures that enum arrays use the more appropriate set type for storing multiple enum values, which aligns better with DynamoDB's native set data type for storing collections of unique values.

Key changes:

  • Modified emitArrayModel function to detect enum arrays and emit them as "set" type with enum values as items
  • Added two new enum definitions (PersonStatus and CoffeePreferences) to the test model
  • Added comprehensive test coverage for the enum array to set conversion

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
test/main.tsp Added two new enum types and corresponding fields to the Person model: status (single enum) and coffeePreferences (enum array) to demonstrate and test the new functionality
test/entities.test.js Added comprehensive test suite for the coffeePreferences enum array field, verifying it's correctly emitted as a set type with the appropriate enum values
src/emitter.ts Enhanced emitArrayModel function to detect enum element types and emit them as "set" type instead of "list" type, extracting enum values as the set items

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mvhenten mvhenten merged commit e7f1535 into main Dec 3, 2025
11 of 12 checks passed
@mvhenten mvhenten deleted the fix-enum-type branch December 3, 2025 14:24
@github-actions
Copy link

github-actions bot commented Dec 3, 2025

🎉 This PR is included in version 3.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Render correct syntax for list with union of strings

2 participants