Ensure discriminator field is always set on insert/upsert

Previously, if the discriminator value was not set (e.g. no map defined), the discriminator field would never be set.
Regression test for #942 (discriminator not set on insert/upsert)
Merge pull request #942