Iterate over the deltas, create new deltas each time a new line is found,
this should make it simpler o work out which delta belongs to which attribute

@param array $inserts

@return array
966174
public function splitInsertsByNewline(array $inserts): array
    {
        $new_deltas = [];

        foreach ($inserts as $insert) {

            if ($insert['insert'] !== null) {

                // Check to see if we are dealing with a media based insert
                if (is_array($insert['insert']) === false) {

                    // We only want to split if there are no attributes
                    if (array_key_exists('attributes', $insert) === false) {

                        // First check for multiple newlines
                        if (preg_match("/[\n]{2,}/", $insert['insert']) !== 0) {

                            $multiple_matches = preg_split("/[\n]{2,}/", $insert['insert']);

                            foreach ($multiple_matches as $k => $match) {

                                $newlines = true;
                                if ($k === count($multiple_matches) - 1) {
                                    $newlines = false;
                                }

                                // Now check for single new matches
                                if (preg_match("/[\n]{1}/", $match) !== 0) {
                                    $new_deltas = array_merge(
                                        $new_deltas,
                                        $this->splitOnSingleNewlineOccurrences($match, $newlines)
                                    );
                                } else {
                                    $new_deltas[] = ['insert' => $match . ($newlines === true ? "\n\n" : null)];
                                }
                            }
                        } else {
                            // No multiple newlines detected, check for single new line matches
                            if (preg_match("/[\n]{1}/", $insert['insert']) !== 0) {
                                $new_deltas = array_merge(
                                    $new_deltas,
                                    $this->splitOnSingleNewlineOccurrences($insert['insert'])
                                );
                            } else {
                                $new_deltas[] = $insert;
                            }
                        }
                    } else {
                        // Attributes, for now return unaffected
                        $new_deltas[] = $insert;
                    }
                } else {
                    // Media based insert, return unaffected
                    $new_deltas[] = $insert;
                }
            }
        }

        return $new_deltas;
    }
1089525
public function insert($insert)
    {
        $this->type = self::INSERT;

        $this->from($insert);

        return $this;
    }
433374
protected function insertInternal(array $fields = [])
    {
        $dirty = $this->getDirtyAttributes();

        $values = $this->getChangedAttributes($fields);
        if (empty($values)) {
            return true;
        }

        $connection = static::getConnection();
        $qb = $this->getQueryBuilder();

        $tableName = $qb->getQuotedName(TableNameResolver::getTableName($this->tableName()));
        $sql = $qb
            ->insert()
            ->table($tableName)
            ->values($values)
            ->toSQL();
        $inserted = $connection->executeUpdate($sql);
        if (false === $inserted) {
            return false;
        }

        foreach (self::getMeta()->getPrimaryKeyName(true) as $primaryKeyName) {
            if (
                empty($this->getAttribute($this->getSequenceName())) ||
                false === in_array($primaryKeyName, $dirty)
            ) {
                $values[$primaryKeyName] = $connection->lastInsertId($this->getSequenceName());
            }
        }

        $this->setAttributes($values);

        return true;
    }
1311607
protected static function inserts_replacing_recursive ($data, $insert) {
		if (is_array($data)) {
			/** @noinspection ForeachSourceInspection */
			foreach ($data as &$d) {
				$d = static::inserts_replacing_recursive($d, $insert);
			}
			return $data;
		}
		foreach ($insert as $i => $d) {
			$data = str_replace("\$i[$i]", $d, $data);
		}
		return $data;
	}
677039
protected static function inserts_processing ($data, $insert) {
		if (static::is_array_indexed($insert) && is_array($insert[0])) {
			$new_data = [];
			foreach ($insert as $i) {
				$new_data[] = static::inserts_replacing_recursive($data, $i);
			}
			return $new_data;
		}
		return static::inserts_replacing_recursive($data, $insert);
	}
363517
public function insert(array $values = []): array
	{
		$sql = $this->query->getPrefix();

		if(empty($values))
		{
			$sql .= $this->insertWithoutValues();
		}
		else
		{
			$sql .= $this->insertWithValues($values);
		}

		return ['sql' => $sql, 'params' => $this->params];
	}
633393
protected static function getSequenceCurval( array $sequences, Pg $db )
    {

        // anything to do
        if( !$sequences ) {
            return array();
        }

        // sequence components
        foreach( $sequences as $key => &$sequence ) {

            $sequence = sprintf(
                "currval('%s'::regclass) as %s",
                $sequence,
                Query::quoteIdentifier( $key )
            );

        }
        $sequences = implode(', ', $sequences);

        return $db->query( new Query( "SELECT {$sequences};" ) )->fetchSingle( Result::FLATTEN_PREVENT );

    }
282476
protected function prepareInsert($inserts)
    {
        if ($this->isHasOneRelation($inserts)) {
            $inserts = array_dot($inserts);
        }

        foreach ($inserts as $column => $value) {
            if (is_null($field = $this->getFieldByColumn($column))) {
                unset($inserts[$column]);

                continue;
            }

            $inserts[$column] = $field->prepare($value);
        }

        $prepared = [];

        foreach ($inserts as $key => $value) {
            array_set($prepared, $key, $value);
        }

        return $prepared;
    }
505826
public function insert(array $values)
    {
        // get version values & values
        $versionValues = $this->getVersionValues($values);
        $values = $this->getValues($values);

        // set version, ref_id and latest_version
        $values[$this->model->getLatestVersionColumn()] = 1;

        // insert main table record
        if (! $id = $this->query->insertGetId($values)) {
            return false;
        }

        $versionValues[$this->model->getVersionKeyName()] = $id;
        $versionValues[$this->model->getVersionColumn()] = 1;

        // insert version table record
        $db = $this->model->getConnection();
        return $db->table($this->model->getVersionTable())->insert($versionValues);
    }
570986
final public function insert( $values ) {
		$current_time = current_time( 'mysql', $this->use_gmt() );
		foreach ( [ 'created', 'updated' ] as $col ) {
			if ( ! isset( $values[ $col ] ) ) {
				$values[ $col ] = $current_time;
			}
		}
		try {
			$place_holders = $this->get_place_holders( $values );
			$result = $this->db->insert( $this->table, $values, $place_holders );
			if ( !$result ) {
				return new \WP_Error( 'db_error', __( 'Failed to insert data. Something is wrong with database.', 'karma' ) );
			} else {
				return (int) $this->db->insert_id;
			}
		} catch ( \Exception $e ) {
			return new \WP_Error( 'db_error', $e->getMessage() );
		}
	}
1020853
protected function getGenericSequences(array $sequences)
    {
        $genericSequences = array();

        foreach ($sequences as $sequence) {
            $genericSequences[] = $this->getGenericSequence($sequence);
        }

        return $genericSequences;
    }
1060008
public static function create($attributes = [])
    {
        try {
            self::init();
            foreach ($attributes as $column => $value) {
                $columns[] = $column;
                $values[] = ':'.$column;
            }

            $sql = 'INSERT INTO ' . self::$modelTable . ' (' . implode(',', $columns) . ') VALUES (' . implode(',', $values) . ')';
            $stm = self::$connect->prepare($sql);
            $stm->execute($attributes);
            return self::find(self::$connect->lastInsertId());
        } catch (\Exception $exception) {
            var_dump($exception->getMessage());
        }
    }
444124
public function getInsertQuery()
    {
        $sql = 'INSERT INTO ' . $this->getTable();
        $sql .= "\n" . $this->getColumns();
        $sql .= "\nVALUES " . $this->getValues();

        return $sql;
    }
801264
public function insert(array $quill)
    {
        $this->deltas[] = new $this->class_delta_insert(
            $quill['insert'],
            (array_key_exists('attributes', $quill) ? $quill['attributes'] : [])
        );
    }
1094084
public function insert(array $values)
    {
        $result = $this->getBuilder()->insert($values);

        // Reset query builder
        $this->resetBuilder();

        return $result;
    }
569593
protected function prepareInsert($inserts)
    {
        if ($this->isHasOneRelation($inserts)) {
            $inserts = Arr::dot($inserts);
        }

        foreach ($inserts as $column => $value) {
            if (is_null($field = $this->getFieldByColumn($column))) {
                unset($inserts[$column]);
                continue;
            }

            $inserts[$column] = $field->prepare($value);
        }

        $prepared = [];

        foreach ($inserts as $key => $value) {
            Arr::set($prepared, $key, $value);
        }

        return $prepared;
    }
534421
public function insert(array $fields = [])
    {
        $connection = $this->getConnection();

        $this->beforeInsertInternal();

        $connection->beginTransaction();
        try {
            if (($inserted = $this->insertInternal($fields))) {
                $connection->commit();
            } else {
                $connection->rollBack();
            }
        } catch (\Exception $e) {
            $connection->rollBack();
            throw $e;
        }

        $this->afterInsertInternal();

        if ($inserted) {
            $this->setIsNewRecord(false);
            $this->updateRelated();
            $this->attributes->resetOldAttributes();
        }

        return $inserted;
    }