forTable method

MssqlTableBinding<TRow> forTable({
  1. String? schema,
  2. String? table,
})

This binding pointed at a different table.

Eloquent's protected $table. The columns, key, relations and conventions stay as generated — what changes is which table they are read from and written to. An archive table with the same shape, a per-tenant copy, or a synonym are the cases this exists for.

The name is not re-validated against a live schema, because there is no connection here to ask; the drift check is where that question belongs.

Implementation

MssqlTableBinding<TRow> forTable({String? schema, String? table}) {
  if (schema == null && table == null) return this;
  // Parsed here rather than left to the first query, so a name that cannot
  // be an identifier is reported where it was written.
  MssqlSql.quoteMultipartIdentifier(<String>[
    schema ?? this.schema,
    table ?? this.table,
  ]);
  return MssqlTableBinding<TRow>(
    schema: schema ?? this.schema,
    table: table ?? this.table,
    columns: columns,
    fromRow: fromRow,
    toColumns: toColumns,
    readColumn: readColumn,
    applyIdentity: applyIdentity,
    applyRelations: applyRelations,
    isRelationLoaded: isRelationLoaded,
    primaryKey: primaryKey,
    identityColumn: identityColumn,
    insertStrategy: insertStrategy,
    // Deliberately dropped: the fingerprint describes the table it was
    // generated from, and carrying it onto another one would make the drift
    // check compare a schema against a description of a different table.
    schemaFingerprint: '',
    decimalMode: decimalMode,
    apiVersion: apiVersion,
    softDelete: softDelete,
    timestamps: timestamps,
    scopes: scopes,
  );
}