fix(snowflake): Fix generateId() call for SnowflakeEntity

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2026-01-07 15:39:09 +01:00
parent 0cdd19271d
commit fe393c5dbf
No known key found for this signature in database
GPG key ID: F72FA5B49FFA96B0

View file

@ -95,6 +95,11 @@ abstract class QBMapper {
* @since 14.0.0
*/
public function insert(Entity $entity): Entity {
if ($entity instanceof SnowflakeAwareEntity) {
/** @psalm-suppress DocblockTypeContradiction */
$entity->generateId();
}
// get updated fields to save, fields have to be set using a setter to
// be saved
$properties = $entity->getUpdatedFields();
@ -115,11 +120,7 @@ abstract class QBMapper {
$qb->setValue($column, $qb->createNamedParameter($value, $type));
}
if ($entity instanceof SnowflakeAwareEntity) {
/** @psalm-suppress DocblockTypeContradiction */
$entity->generateId();
$qb->executeStatement();
} elseif ($entity->id === null) {
if ($entity->id === null) {
$qb->executeStatement();
// When autoincrement is used id is always an int
$entity->setId($qb->getLastInsertId());