fixWithBrackets static method

String fixWithBrackets(
  1. String name
)

Check the columnName and fix it if necessary.

@param name the name to check. @return the fixed name.

Implementation

static String fixWithBrackets(String name) {
  if (name[0] == '[') {
    // already fixed
    return name;
  }
  double? num = double.tryParse(name.substring(0, 1));

  if (num != null ||
      name.contains("-") ||
      name.contains(",") ||
      name.contains(RegExp(r'\s+'))) {
    return "[" + name + "]";
  }
  return name;
}