Ejemplo n.º 1
0
 /**
  * For any column name, generate an alias that is unique to that column name, and also 10
  * characters or less in length.
  */
 public String getAlias(Dialect dialect) {
   String alias = name;
   String unique = Integer.toString(uniqueInteger) + '_';
   int lastLetter = StringHelper.lastIndexOfLetter(name);
   if (lastLetter == -1) {
     alias = "column";
   } else if (lastLetter < name.length() - 1) {
     alias = name.substring(0, lastLetter + 1);
   }
   if (alias.length() > dialect.getMaxAliasLength()) {
     alias = alias.substring(0, dialect.getMaxAliasLength() - unique.length());
   }
   boolean useRawName = name.equals(alias) && !quoted && !name.toLowerCase().equals("rowid");
   if (useRawName) {
     return alias;
   } else {
     return alias + unique;
   }
 }