toEntity method

Convert this partial into a full entity.

Validates that all required (non-nullable) fields are present.

Throws StateError if any required field is null/missing. The error message should indicate which required fields are missing.

Example

final partial = $UserPartial(id: 1, name: 'Alice', email: null);

try {
  final user = partial.toEntity();
} on StateError catch (e) {
  // "Required field 'email' is null on UserPartial"
  print(e.message);
}

Implementation

@override
$OrmMigrationRecord toEntity() {
  // Basic required-field check: non-nullable fields must be present.
  final String? idValue = id;
  if (idValue == null) {
    throw StateError('Missing required field: id');
  }
  final String? checksumValue = checksum;
  if (checksumValue == null) {
    throw StateError('Missing required field: checksum');
  }
  final DateTime? appliedAtValue = appliedAt;
  if (appliedAtValue == null) {
    throw StateError('Missing required field: appliedAt');
  }
  final int? batchValue = batch;
  if (batchValue == null) {
    throw StateError('Missing required field: batch');
  }
  return $OrmMigrationRecord(
    id: idValue,
    checksum: checksumValue,
    appliedAt: appliedAtValue,
    batch: batchValue,
  );
}