insertFromSelect<T extends Table, D> method

void insertFromSelect<T extends Table, D>(
  1. TableInfo<T, D> table,
  2. BaseSelectStatement select, {
  3. required Map<Column<Object>, Expression<Object>> columns,
  4. InsertMode? mode,
  5. UpsertClause<T, D>? onConflict,
})

Inserts rows from the select statement.

This method creates an INSERT INTO SELECT statement in SQL which will insert a row into this table for each row returned by the select statement.

The columns map describes which column from the select statement should be written into which column of the table. The keys of the map are the target column, and values are expressions added to the select statement.

See also:

Implementation

void insertFromSelect<T extends Table, D>(
    TableInfo<T, D> table, BaseSelectStatement select,
    {required Map<Column, Expression> columns,
    InsertMode? mode,
    UpsertClause<T, D>? onConflict}) {
  _addUpdate(table, UpdateKind.insert);
  final actualMode = mode ?? InsertMode.insert;
  final context = InsertStatement<T, D>(_user, table).createContextFromSelect(
      select, columns, actualMode,
      onConflict: onConflict);
  _addContext(context);
}