Exemplo n.º 1
0
 @Override
 public boolean isFunction(final String string) {
   if (string.endsWith("()")) {
     return true;
   }
   for (DatabaseFunction function : getDateFunctions()) {
     if (function.toString().equalsIgnoreCase(string)) {
       return true;
     }
   }
   return false;
 }
Exemplo n.º 2
0
  @Override
  public String generateDatabaseFunctionValue(DatabaseFunction databaseFunction) {
    if (databaseFunction != null
        && databaseFunction.toString().equalsIgnoreCase("current_timestamp")) {
      return databaseFunction.toString();
    }
    if (databaseFunction instanceof SequenceNextValueFunction
        || databaseFunction instanceof SequenceCurrentValueFunction) {
      String quotedSeq = super.generateDatabaseFunctionValue(databaseFunction);
      // replace "myschema.my_seq".nextval with "myschema"."my_seq".nextval
      return quotedSeq.replaceFirst("\"([^\\.\"]*)\\.([^\\.\"]*)\"", "\"$1\".\"$2\"");
    }

    return super.generateDatabaseFunctionValue(databaseFunction);
  }
Exemplo n.º 3
0
  @Override
  public String generateDatabaseFunctionValue(final DatabaseFunction databaseFunction) {
    if (databaseFunction.getValue() == null) {
      return null;
    }
    if (isCurrentTimeFunction(databaseFunction.getValue().toLowerCase())) {
      return getCurrentDateTimeFunction();
    } else if (databaseFunction instanceof SequenceNextValueFunction) {
      if (sequenceNextValueFunction == null) {
        throw new RuntimeException(
            String.format(
                "next value function for a sequence is not configured for database %s",
                getDefaultDatabaseProductName()));
      }
      String sequenceName = databaseFunction.getValue();
      if (!sequenceNextValueFunction.contains("'")) {
        sequenceName = escapeObjectName(sequenceName, Sequence.class);
      }
      return String.format(sequenceNextValueFunction, sequenceName);
    } else if (databaseFunction instanceof SequenceCurrentValueFunction) {
      if (sequenceCurrentValueFunction == null) {
        throw new RuntimeException(
            String.format(
                "current value function for a sequence is not configured for database %s",
                getDefaultDatabaseProductName()));
      }

      String sequenceName = databaseFunction.getValue();
      if (!sequenceCurrentValueFunction.contains("'")) {
        sequenceName = escapeObjectName(sequenceName, Sequence.class);
      }
      return String.format(sequenceCurrentValueFunction, sequenceName);
    } else {
      return databaseFunction.getValue();
    }
  }