ColumnDefinition.fromJson constructor
Implementation
factory ColumnDefinition.fromJson(Map<String, Object?> json) {
final overridesJson =
(json['driverOverrides'] as Map<String, Object?>?) ?? const {};
return ColumnDefinition(
name: json['name'] as String,
type: ColumnType.fromJson(json['type'] as Map<String, Object?>),
unsigned: json['unsigned'] as bool? ?? false,
nullable: json['nullable'] as bool? ?? false,
unique: json['unique'] as bool? ?? false,
indexed: json['indexed'] as bool? ?? false,
primaryKey: json['primaryKey'] as bool? ?? false,
autoIncrement: json['autoIncrement'] as bool? ?? false,
defaultValue: json['default'] == null
? null
: ColumnDefault.fromJson(json['default'] as Map<String, Object?>),
comment: json['comment'] as String?,
charset: json['charset'] as String?,
collation: json['collation'] as String?,
afterColumn: json['after'] as String?,
first: json['first'] as bool? ?? false,
generatedAs: json['generatedAs'] as String?,
storedAs: json['storedAs'] as String?,
virtualAs: json['virtualAs'] as String?,
useCurrentOnUpdate: json['useCurrentOnUpdate'] as bool? ?? false,
invisible: json['invisible'] as bool? ?? false,
always: json['always'] as bool? ?? false,
allowedValues: (json['allowedValues'] as List?)?.cast<String>(),
driverOverrides: Map.unmodifiable(
overridesJson.map(
(driver, raw) => MapEntry(
driver,
ColumnDriverOverride.fromJson((raw as Map).cast<String, Object?>()),
),
),
),
);
}