@Override
  public final void accept(Context<?> ctx) {

    // If this is already a subquery, proceed
    if (ctx.subquery()) {
      ctx.keyword(quantifier.toSQL())
          .sql(" (")
          .formatIndentStart()
          .formatNewLine()
          .visit(delegate(ctx.configuration()))
          .formatIndentEnd()
          .formatNewLine()
          .sql(")");
    } else {
      ctx.keyword(quantifier.toSQL())
          .sql(" (")
          .subquery(true)
          .formatIndentStart()
          .formatNewLine()
          .visit(delegate(ctx.configuration()))
          .formatIndentEnd()
          .formatNewLine()
          .subquery(false)
          .sql(")");
    }
  }
Exemple #2
0
 @Override
 public final Clause[] clauses(Context<?> ctx) {
   if (ctx.declareFields() || ctx.declareTables()) {
     if (wrapped instanceof Table) return CLAUSES_TABLE_ALIAS;
     else return CLAUSES_FIELD_ALIAS;
   } else {
     if (wrapped instanceof Table) return CLAUSES_TABLE_REFERENCE;
     else return CLAUSES_FIELD_REFERENCE;
   }
 }
Exemple #3
0
  @Override
  public final void accept(Context<?> ctx) {
    SQLDialect family = ctx.configuration().dialect().family();

    if (operator == BIT_NOT && asList(H2, HSQLDB).contains(family)) {
      ctx.sql("(0 - ").visit(field).sql(" - 1)");
    } else if (operator == BIT_NOT && family == FIREBIRD) {
      ctx.keyword("bin_not(").visit(field).sql(')');
    } else {
      ctx.sql(operator.toSQL()).sql('(').visit(field).sql(')');
    }
  }
  @Override
  public final void accept(Context<?> ctx) {
    if (conditions.isEmpty()) {
      ctx.visit(trueCondition());
    } else if (conditions.size() == 1) {
      ctx.visit(conditions.get(0));
    } else {
      ctx.sql("(").formatIndentStart().formatNewLine();

      String operatorName = operator.name().toLowerCase() + " ";
      String separator = "";

      for (int i = 0; i < conditions.size(); i++) {
        if (i > 0) {
          ctx.formatSeparator();
        }

        ctx.keyword(separator);
        ctx.visit(conditions.get(i));
        separator = operatorName;
      }

      ctx.formatIndentEnd().formatNewLine().sql(")");
    }
  }
Exemple #5
0
  private final void accept0(Context<?> ctx, boolean asStringLiterals) {
    Schema mappedSchema = Utils.getMappedSchema(ctx.configuration(), schema);

    if (mappedSchema != null && ctx.family() != CUBRID) {
      if (asStringLiterals) {
        ctx.visit(inline(mappedSchema.getName())).sql(", ");
      } else {
        ctx.visit(mappedSchema).sql('.');
      }
    }

    if (asStringLiterals) ctx.visit(inline(name));
    else if (nameIsPlainSQL) ctx.sql(name);
    else ctx.literal(name);
  }
Exemple #6
0
  private void accept0(Context<?> ctx) {
    ctx.start(DROP_SEQUENCE_SEQUENCE)
        .keyword("drop")
        .sql(' ')
        .keyword(ctx.family() == CUBRID ? "serial" : "sequence")
        .sql(' ');

    if (ifExists && supportsIfExists(ctx)) ctx.keyword("if exists").sql(' ');

    ctx.visit(sequence);

    if (ctx.family() == DERBY) ctx.sql(' ').keyword("restrict");

    ctx.end(DROP_SEQUENCE_SEQUENCE);
  }
Exemple #7
0
 @Override
 public final void accept(Context<?> ctx) {
   ctx.literal(getName());
 }
Exemple #8
0
 final boolean isInline(Context<?> context) {
   return isInline()
       || (context.paramType() == INLINED)
       || (context.paramType() == NAMED_OR_INLINED && StringUtils.isBlank(paramName));
 }
Exemple #9
0
 private final boolean supportsIfExists(Context<?> ctx) {
   return !asList(DERBY, FIREBIRD).contains(ctx.family());
 }
Exemple #10
0
 @Override
 public final void accept(Context<?> ctx) {
   ctx.visit(alias);
 }
Exemple #11
0
 @Override
 public final void accept(Context<?> ctx) {
   ctx.sql("(").visit(wrapped).sql(")");
 }
Exemple #12
0
 @Override
 public final void accept(Context<?> ctx) {
   ctx.visit(delegate(ctx.configuration()));
 }
 @Override
 public final Clause[] clauses(Context<?> ctx) {
   return delegate(ctx.configuration()).clauses(ctx);
 }