Parameterized Entity Types?


#1

So I have created the following 3 files that I feel should break, but they don’t:

MyFancyType.c3typ:
extendable entity type MyFancyType<K,V> schema name “MY_FNCY_TYP”
{
myKey: K
myVal: V
}

MyChildFancyType.c3typ:
entity type MyChildFancyType extends MyFancyType<string, boolean> type key “MY_CHLD_FNCY_TYP”
{
myOther: double
}

MyOtherChildFancyType.c3typ:
entity type MyOtherChildFancyType extends MyFancyType<int, boolean> type key “MY_OTHR_CHLD_FNCY_TYP”
{
myNextOther: float
}

When I provision these files, I don’t see any errors. Why is that? What does the DB Schema look like? Does the system use Obj or Type (like Java) for parameters? If so, is the system susceptible to the issues of type erasure?

Thank you!


#2

You will end up with a table called “My_FNCY_TYP”

This table will have lots of columns including:

id, typeKey, myKey_s, myKey_i, myVal_b, myNextFloat_f, myOther_d

YOU SHOULD NOT RELY ON THIS STRUCTURE AS THIS IS AN INTERNAL IMPLEMENTATION DETAIL OF THE PERSISTENCE ENGINE AND CAN CHANGE AT ANY TIME


#3

Okay, awesome! Thank you!