Fixed #380. Ported propelorm/propel#590

Fixed #380. Ported propelorm/propel#590