Fix creating new tags with null parent
This fixes a regression introduced in 9d83f0752 that set default
value for Tag.parentId column as -1, so the Entity logic code tries
to insert -1, even though there's no Tag with ID -1, which triggers
foreign key constraint violation. This roots in our inability to
express absence of a value by plain integer.
This change reverts the patch partially and instead workarounds it
by resetting the parentId to -1 when reading a NULL value from the
table.