/** * The upper bound, such that ROW_NUMBER() <= getUpperRownum() */ final Field<Integer> getUpperRownum() { return offsetOrZero.add(numberOfRowsOrMax); }
/** * The upper bound, such that ROW_NUMBER() <= getUpperRownum() */ final Field<Integer> getUpperRownum() { return offsetOrZero.add(numberOfRows); }
/** * Add an interval to a date. * <p> * This translates into any dialect * * @see Field#add(Field) */ @Support public static Field<LocalDate> localDateAdd(Field<LocalDate> date, Field<? extends Number> interval) { return nullSafe(date).add(interval); }
/** * Add an interval to a date. * <p> * This translates into any dialect * * @see Field#add(Field) */ @Support public static Field<Date> dateAdd(Field<Date> date, Field<? extends Number> interval) { return nullSafe(date).add(interval); }
/** * Add an interval to a timestamp. * <p> * This translates into any dialect * * @see Field#add(Field) */ @Support public static Field<Timestamp> timestampAdd(Field<Timestamp> timestamp, Field<? extends Number> interval) { return nullSafe(timestamp).add(interval); }
/** * Add an interval to a timestamp. * <p> * This translates into any dialect * * @see Field#add(Field) */ @Support public static Field<LocalDateTime> localDateTimeAdd(Field<LocalDateTime> timestamp, Field<? extends Number> interval) { return nullSafe(timestamp).add(interval); }
public LinkedHashMap<Field<?>, Object> getIncrements(ReflectedTable table, boolean primaryTable, Record record, Params params) { LinkedHashMap<Field<?>, Object> columns = new LinkedHashMap<>(); Set<String> cols = columns(table, primaryTable, params); for (String key : cols) { if (record.containsKey(key)) { Field<Object> field = table.get(key); Object value = record.get(key); if (value instanceof Number) { columns.put(field, field.add((Number) value)); } } } return columns; }
/** * Add an interval to a timestamp. * <p> * This translates into any dialect * * @see Field#add(Field) */ @Support @Transition( name = "TIMESTAMP_ADD", args = { "Field", "Field" }, to = "DateFunction" ) public static Field<Timestamp> timestampAdd(Field<Timestamp> timestamp, Field<? extends Number> interval) { return nullSafe(timestamp).add(interval); }
private static final FieldOrRow parseSum(ParserContext ctx, Type type) { FieldOrRow r = parseFactor(ctx, type); if (N.is(type) && r instanceof Field) for (;;) if (parseIf(ctx, '+')) r = ((Field) r).add((Field) parseFactor(ctx, type)); else if (parseIf(ctx, '-')) r = ((Field) r).sub((Field) parseFactor(ctx, type)); else break; return r; }
private final QueryPart delegate(Configuration configuration) { switch (configuration.dialect().family()) { case CUBRID: /* [pro] xx xxxx xxxxxxx xx [/pro] */ // There is a bug in CUBRID preventing reuse of "level" in the // predicate http://jira.cubrid.org/browse/ENGINE-119 Field<Integer> level = from.add(level()).sub(one()); return table("({select} {0} {as} {1} {from} {2} {connect by} {level} <= {3})", level, name("generate_series"), new Dual(), to.add(one()).sub(from)); case POSTGRES: default: return table("{generate_series}({0}, {1})", from, to); } }
@Override final Field<T> getFunction0(Configuration configuration) { switch (configuration.dialect().family()) { // evaluate "ceil" if unavailable case SQLITE: return DSL.round(argument.add(0.499999999999999)); case H2: return DSL.field("{ceiling}({0})", getDataType(), argument); default: return DSL.field("{ceil}({0})", getDataType(), argument); } } }
/** * Get the hyperbolic cotangent function: coth(field). * <p> * This is not supported by any RDBMS, but emulated using exp exp: * <code><pre>(exp([field] * 2) + 1) / (exp([field] * 2) - 1)</pre></code> */ @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) public static Field<BigDecimal> coth(Field<? extends Number> field) { field = nullSafe(field); return exp(field.mul(2)).add(1).div(exp(field.mul(2)).sub(1)); }
@Override final Field<T> getFunction0(Configuration configuration) { switch (configuration.dialect().family()) { /* [pro] xx xxxx xxxxxxx xxxxxx xxxxxxxxxxxxxxxxxxx x xxxx x xxxxxxxxx x xxxxx xxxxxxxxxxxxxx xxxxxxxxxx xx [/pro] */ // evaluate "ceil" if unavailable case SQLITE: return DSL.round(argument.add(0.499999999999999)); /* [pro] xx xxxx xxxx xxxx xxxxxxxxxx xx [/pro] */ case H2: return field("{ceiling}({0})", getDataType(), argument); default: return field("{ceil}({0})", getDataType(), argument); } } }
/** * Get the hyperbolic cotangent function: coth(field). * <p> * This is not supported by any RDBMS, but simulated using exp exp: * <code><pre>(exp([field] * 2) + 1) / (exp([field] * 2) - 1)</pre></code> */ @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) @Transition( name = "COTH", args = "Field", to = "MathFunction" ) public static Field<BigDecimal> coth(Field<? extends Number> field) { field = nullSafe(field); return exp(field.mul(2)).add(1).div(exp(field.mul(2)).sub(1)); }
switch (configuration.family()) { case DERBY: return DSL.substring(field, field.length().add(one()).sub(length));
@SuppressWarnings({ "unchecked" }) @Override public void accept(Context<?> ctx) { switch (ctx.family()) { case POSTGRES: ctx.visit(DSL.field("{width_bucket}({0}, {1}, {2}, {3})", getType(), field, low, high, buckets)); break; default: ctx.visit( DSL.when(field.lt(low), zero()) .when(field.ge(high), buckets.add(one())) .otherwise((Field<Integer>) DSL.floor(field.sub(low).mul(buckets).div(high.sub(low))).add(one())) ); break; } }
@Override final Field<BigDecimal> getFunction0(Configuration configuration) { switch (configuration.family()) { case CUBRID: case HSQLDB: case MARIADB: case MYSQL: case POSTGRES: return DSL.exp(argument.mul(two())).add(one()).div(DSL.exp(argument).mul(two())); default: return function("cosh", SQLDataType.NUMERIC, argument); } } }
return DSL.position(DSL.substring(in, startIndex), search).add(startIndex).sub(one());
@Override final Field<BigDecimal> getFunction0(Configuration configuration) { switch (configuration.family()) { case CUBRID: case HSQLDB: case MARIADB: case MYSQL: case POSTGRES: return DSL.exp(argument.mul(two())).sub(one()).div(DSL.exp(argument.mul(two())).add(one())); default: return function("tanh", SQLDataType.NUMERIC, argument); } } }
@Override final Field<BigDecimal> getFunction0(Configuration configuration) { switch (configuration.dialect().family()) { /* [pro] xx xxxx xxxxxxx xxxx xxxx xxxx xxxxxxx xxxx xxxxxxxxxx xxxx xxxxxxx xx [/pro] */ case CUBRID: case HSQLDB: case MARIADB: case MYSQL: case POSTGRES: return DSL.exp(argument.mul(two())).add(one()).div(DSL.exp(argument).mul(two())); default: return function("cosh", SQLDataType.NUMERIC, argument); } } }