Post default for array

I have the following types. When I fetch B, I don’t see myField, though it is in c3ShowType(B).

I don’t know if the problem is my use of post default or the overwrite of mixes field

type A {
  myField: [string] schema suffix 'ABC'
}

entity type B mixes A schema name 'CBA' {
  myField: [string] post default "['apple', 'orange']"
}
1 Like

Make sure you include “myField” in your include spec. Array fields are not included by default.

I did. The fetch result doesn’t contain myField at all

None of the following works for me

myField: [string] post default ['apple', 'orange']
myField: [string] post default "['apple', 'orange']"
myField: [string] post default ["'apple'", "'orange'"]

Don’t redefine the value type for myField. Instead use ~ to inherit the value type from the mixed in type:

myField: ~ post default ...

(not sure this will fix your issue though)

@qiwei.li This is a bug. Since arrays are never null, we see the empty array and think the value has been set. Can you please file a ticket?

Until that bug gets fixed, you might be able to achieve the behavior you are looking for by implmenting beforeCreate() and/or beforeUpdate() on your type to populate the array.

Was this ticket ever created and/or completed @qiwei.li @trothwein? experiencing the same issue.

@danielle.youngsmith Yes, see: https://c3energy.atlassian.net/browse/PLAT-16860

1 Like

Thank you @trothwein!!

For the people who can’t access JIRA, the correct syntax is
myField: [string] post default "['apple', 'orange']"

2 Likes