Better implementation of autoIncrement

Before this patch id === null was required for autoIncrement ids.
This patch also accepts id === undefined