public function lastInsertId($sequenceName = null)
    {
        if (isset($this->lastInsertedIds[$sequenceName])) {
            $lastInsertId = $this->lastInsertedIds[$sequenceName];
            unset($this->lastInsertedIds[$sequenceName]);

            return $lastInsertId;
        }

        return $this->connection->lastInsertId($sequenceName);
    }