APY-121 : Polymorphic support for models

Done the polymorphic encoder and query merging,
still required the decoder.