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

Array of enums not supported #507

Open
ondratra opened this issue Aug 10, 2022 · 0 comments
Open

Array of enums not supported #507

ondratra opened this issue Aug 10, 2022 · 0 comments

Comments

@ondratra
Copy link
Contributor

ondratra commented Aug 10, 2022

There is no way how to create a list of enums.

The following input schema will generate uncompilable code:

enum ChannelActionPermission {
  UpdateChannelMetadata
  ManageNonVideoChannelAssets
  ManageChannelCollaborators
  UpdateVideoMetadata
  AddVideo
  ManageVideoAssets
  DeleteChannel
  DeleteVideo
  ManageVideoNfts
  AgentRemark
  TransferChannel
  ClaimChannelReward
  WithdrawFromChannelBalance
  IssueCreatorToken
  ClaimCreatorTokenPatronage
  InitAndManageCreatorTokenSale
  CreatorTokenIssuerTransfer
  MakeCreatorTokenPermissionless
  ReduceCreatorTokenPatronageRate
  ManageRevenueSplits
  DeissueCreatorToken
}

type ChannelAgentPermissions @entity {
  ...

  "List of member's permissions"
  permissions: [ChannelActionPermission!]!
}

The generated snippet in channel-agent-permissions.model.ts doesn't represent the schema (there is enum instead of array of enums created):

 @EnumField('ChannelActionPermission', ChannelActionPermission, {
    description: `List of member's permissions`,
  })
  permissions!: ChannelActionPermission;

After manually changing the generated code to

  @EnumField('ChannelActionPermission', ChannelActionPermission, {
    description: `List of member's permissions`,
    array: true, // none of these two works
    isArray: true, // none of these two works
  })
  permissions!: ChannelActionPermission[];

the code compiles, but an error during db setup occurs:

DataTypeNotSupportedError: Data type "Array" in "ChannelAgentPermissions.permissions" is not supported by "postgres" database

This will require a change in Warthog's EnumField decorator. I wasn't able to make it work in a couple of hours, so I'm putting it on ice for now.

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

No branches or pull requests

2 participants