Versioning issues on session.flush

Hey, opening a pull request with some fixes related to mid-transaction flushes. Check the added tests to see what I think the expected behavior should be
- Keep the version's type as INSERT when a new object is flushed and then modified within the same single transaction. Currently there is no insert entry ever created.
- Ensure the same versioning behavior when primary keys of objects are modified after a flush, with the behavior that you get when they are modified without a flush.

Update:
- When a new object is created, flushed, then deleted (all in the same transaction), no version entry to be saved.
- Postgres triggers have also been updated.
Hmm thanks for pointing that out! I removed the generated changes attr from version classes.