clone method

Table clone()

Deep clone (used for transaction snapshots).

Implementation

Table clone() {
  final clonedRows = rows.map((r) => List<Object?>.from(r)).toList();
  final clonedDefs = Map<String, IndexDef>.from(indexDefs);
  final clonedIdx = <String, SplayTreeMap<Object, List<int>>>{};
  for (final e in indexes.entries) {
    final m = SplayTreeMap<Object, List<int>>(_compareKeys);
    for (final kv in e.value.entries) {
      m[kv.key] = List<int>.from(kv.value);
    }
    clonedIdx[e.key] = m;
  }
  return Table._raw(
      name,
      List<ColumnDef>.from(columns),
      List<TableConstraint>.from(constraints),
      clonedRows,
      clonedDefs,
      clonedIdx,
      Map<String, int>.from(autoInc),
      strict: strict,
      withoutRowid: withoutRowid);
}