Missing required argument even when that argument is provided

#1

I have a type that mixes TimedCharacteristicHistory, which has name as a required field. However, even when I supply a name, it still throws an error:

Has anyone seen this before?

0 Likes

#2

Your spec should work!!
It may be related to the quotes, make sure you are using them properly.

0 Likes

#3

Tried re-doing the quotes, single quotes, no quotes around parameter names, doing make() and then merge(), all produce the same error

I tried creating other types with different required fields, and they only errored until I supplied the field, as expected. So maybe it is specifically a TimedCharacteristicHistory thing?

0 Likes

#4

name is defined as required in the parent type TimedCharacteristic, but also defined in Persistable but as non required.
How are you defining your type MetricResultValueHistory?

0 Likes

#5

The definition is

entity type MetricResultValueHistory mixes TimedCharacteristicHistory<MobileAsset> schema name 'MRVH' {

It does not currently contain its own definition for name. Do you think it should?

0 Likes

#6

no you don’t need to explicitly have name as you’re mixing Persistable (implicitly via entity).

I think your definition is missing the type for your values, for instance the characteristic value is a Double

entity type MetricResultValueHistory mixes TimedCharacteristicHistory<MobileAsset>, Double schema name 'MRVH'

or

entity type MetricResultValueHistory mixes TimedCharacteristicHistory<MobileAsset> schema name 'MRVH' {
  // in this case you can even normalize the values by adding `@ts` 
  value: Double
}
0 Likes

#7

I think you have @db(compactType=true) annotation on your type. When compactType is set to true, name field isn’t persisted.

So you need to remove compactType=true

0 Likes

#8

You’re right! Even though compactType=true wasn’t in my .c3typ file, it was still showing up when I did c3ShowType(). I manually set compactType=false in my .c3typ file, and it seems to be working now.

0 Likes