Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default Enum Values to Name #104

Merged
merged 4 commits into from
Nov 13, 2023
Merged

Default Enum Values to Name #104

merged 4 commits into from
Nov 13, 2023

Conversation

daogrady
Copy link
Contributor

@daogrady daogrady commented Nov 8, 2023

Fixes #99

Enums that did not provide an explicit value for enum fields would have undefined for their values in the generated index.js files before.

// model.cds
type Foo : String enum {
    Bar;
    Baz = "baz";
}

⬇️ (more or less)

// index.js
const Foo = {
  Bar: undefined,
  Baz: "baz"
}

To rectify this, the field's name is now used as fallback value:

// index.js
const Foo = {
  Bar: "Bar",
  Baz: "baz"
}

@daogrady daogrady mentioned this pull request Nov 8, 2023
1 task
@daogrady daogrady enabled auto-merge (squash) November 13, 2023 08:31
@daogrady daogrady merged commit b682251 into main Nov 13, 2023
7 checks passed
@daogrady daogrady deleted the fix/default-enum-values branch November 13, 2023 08:35
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.

[BUG] Enum values all undefined
1 participant