toSqliteAddColumnString function

String toSqliteAddColumnString(
  1. SqfEntityFieldType field
)

Implementation

String toSqliteAddColumnString(SqfEntityFieldType field) {
  String _dbType;
  switch (field.dbType) {
    case DbType.bool:
      _dbType = 'numeric';
      break;
    default:
      _dbType = field.dbType.toString().replaceAll('DbType.', '');
  }
  final StringBuffer retVal = StringBuffer('${field.fieldName} $_dbType')
    ..write(field.isNotNull ?? false ? ' NOT NULL' : '')
    ..write(field.isUnique ?? false ? ' UNIQUE' : '')
    ..write(field.collate != null ? ' COLLATE ${field.collate.toString().replaceAll('Collate.', '')}' : '')
    ..write(field.checkCondition != null && field.checkCondition!.isNotEmpty ? ' CHECK(${field.checkCondition!.replaceAll('(this)', field.fieldName!)})' : '')
    ..write(field.defaultValue != null ? ' DEFAULT ${getDefaultValue(field)}' : '');
  return retVal.toString();
}