[#629] Add support for the Teradata database (WIP)
This commit is contained in:
parent
1075887293
commit
affd66328c
@ -678,7 +678,7 @@ term =
|
||||
| 'REGR_SYY'
|
||||
| 'REGR_SXY'
|
||||
) '(' sum ',' sum ')'
|
||||
| 'REPLACE' '(' field ',' field [ ',' field ] ')'
|
||||
| ( 'REPLACE' | 'OREPLACE' ) '(' field ',' field [ ',' field ] ')'
|
||||
| 'REPEAT' '(' field ',' field ')'
|
||||
| 'REVERSE' '(' field ')'
|
||||
| 'RPAD' '(' field ',' field [ ',' field ] ')'
|
||||
@ -692,10 +692,8 @@ term =
|
||||
| 'ROW' '(' fields ')'
|
||||
| ( 'SUBSTR' | 'SUBSTRING' ) '(' field ',' sum [ ',' sum ] ')'
|
||||
| 'SECOND' '(' field ')'
|
||||
| 'SHIFTLEFT' '(' field ',' field ')'
|
||||
| 'SHIFTRIGHT' '(' field ',' field ')'
|
||||
| 'SHL' '(' field ',' field ')'
|
||||
| 'SHR' '(' field ',' field ')'
|
||||
| ( 'SHL' | 'SHIFTLEFT' ) '(' field ',' field ')'
|
||||
| ( 'SHR' | 'SHIFTRIGHT' ) '(' field ',' field ')'
|
||||
| 'SIGN' '(' field ')'
|
||||
| ( 'SQR' | 'SQRT' ) '(' sum ')'
|
||||
| 'SIN' '(' sum ')'
|
||||
@ -703,6 +701,7 @@ term =
|
||||
| 'SPACE' '(' field ')'
|
||||
| 'STDDEV_POP' '(' field ')' [ over ]
|
||||
| 'STDDEV_SAMP' '(' field ')' [ over ]
|
||||
| 'STR_REPLACE' '(' field ',' field ',' field ')'
|
||||
| 'SUBSTRING' '(' field 'FROM' sum [ 'FOR' sum ] ')'
|
||||
| 'SUM' '(' [ 'DISTINCT' | 'ALL' ] field ')' [ keep | filter ]
|
||||
| 'TAN' '(' sum ')'
|
||||
@ -713,7 +712,7 @@ term =
|
||||
| 'TO_DATE' '(' field ',' field ')'
|
||||
| 'TO_NUMBER' '(' field ')'
|
||||
| 'TO_TIMESTAMP' '(' field ',' field ')'
|
||||
| 'TRANSLATE' '(' field ',' field ',' field ')'
|
||||
| ( 'TRANSLATE' | 'OTRANSLATE' ) '(' field ',' field ',' field ')'
|
||||
| 'TRIM' '(' field ')'
|
||||
| 'TRUNC' '(' field ',' stringLiteral ')'
|
||||
| 'TRUNC' '(' sum ',' sum ')'
|
||||
|
||||
@ -632,6 +632,7 @@ public enum SQLDialect {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
case CUBRID: return "org.hibernate.dialect.CUBRIDDialect";
|
||||
|
||||
@ -49,6 +49,7 @@ import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
|
||||
@ -52,6 +52,7 @@ import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
|
||||
/**
|
||||
* This type is used for the window function DSL API.
|
||||
|
||||
@ -49,6 +49,7 @@ import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
|
||||
@ -45,6 +45,7 @@ import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
|
||||
/**
|
||||
* This type is used for the window function DSL API.
|
||||
|
||||
@ -46,6 +46,7 @@ import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
|
||||
/**
|
||||
* This type is used for the window function DSL API.
|
||||
|
||||
@ -49,6 +49,7 @@ import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
|
||||
@ -49,6 +49,7 @@ import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
|
||||
@ -46,6 +46,7 @@ import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
|
||||
/**
|
||||
* An intermediate step in the construction of a {@link WindowSpecification}.
|
||||
|
||||
@ -46,6 +46,7 @@ import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
|
||||
/**
|
||||
* An intermediate step in the construction of a {@link WindowSpecification}.
|
||||
|
||||
@ -39,6 +39,7 @@ package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.DSL.function;
|
||||
import static org.jooq.impl.DSL.inline;
|
||||
import static org.jooq.impl.SQLDataType.VARCHAR;
|
||||
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.Field;
|
||||
@ -54,7 +55,7 @@ final class CurrentSchema extends AbstractFunction<String> {
|
||||
private static final long serialVersionUID = -7273879239726265322L;
|
||||
|
||||
CurrentSchema() {
|
||||
super("current_schema", SQLDataType.VARCHAR);
|
||||
super("current_schema", VARCHAR);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -74,26 +75,29 @@ final class CurrentSchema extends AbstractFunction<String> {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
case CUBRID:
|
||||
case FIREBIRD:
|
||||
case SQLITE:
|
||||
return inline("");
|
||||
|
||||
case DERBY:
|
||||
return DSL.field("{current schema}", String.class);
|
||||
return DSL.field("{current schema}", VARCHAR);
|
||||
|
||||
case H2:
|
||||
return DSL.field("{schema}()", String.class);
|
||||
return DSL.field("{schema}()", VARCHAR);
|
||||
|
||||
case MARIADB:
|
||||
case MYSQL:
|
||||
return DSL.field("{database}()", String.class);
|
||||
return DSL.field("{database}()", VARCHAR);
|
||||
|
||||
case HSQLDB:
|
||||
case POSTGRES:
|
||||
return DSL.field("{current_schema}", String.class);
|
||||
return DSL.field("{current_schema}", VARCHAR);
|
||||
}
|
||||
|
||||
return function("current_schema", String.class);
|
||||
return function("current_schema", VARCHAR);
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,6 +37,8 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.SQLDataType.VARCHAR;
|
||||
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.Field;
|
||||
|
||||
@ -51,7 +53,7 @@ final class CurrentUser extends AbstractFunction<String> {
|
||||
private static final long serialVersionUID = -7273879239726265322L;
|
||||
|
||||
CurrentUser() {
|
||||
super("current_user", SQLDataType.VARCHAR);
|
||||
super("current_user", VARCHAR);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -73,16 +75,17 @@ final class CurrentUser extends AbstractFunction<String> {
|
||||
|
||||
|
||||
|
||||
|
||||
case DERBY:
|
||||
case FIREBIRD:
|
||||
case HSQLDB:
|
||||
case POSTGRES:
|
||||
return DSL.field("{current_user}", String.class);
|
||||
return DSL.field("{current_user}", VARCHAR);
|
||||
|
||||
case SQLITE:
|
||||
return DSL.inline("");
|
||||
}
|
||||
|
||||
return DSL.function("current_user", SQLDataType.VARCHAR);
|
||||
return DSL.function("current_user", VARCHAR);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3169,6 +3169,23 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
|
||||
@Override
|
||||
final String get0(BindingGetResultSetContext<U> ctx) throws SQLException {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return ctx.resultSet().getString(ctx.index());
|
||||
}
|
||||
|
||||
|
||||
@ -55,6 +55,7 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.impl.DSL.condition;
|
||||
import static org.jooq.impl.DSL.exists;
|
||||
import static org.jooq.impl.DSL.notExists;
|
||||
|
||||
@ -75,6 +75,10 @@ final class Position extends AbstractFunction<Integer> {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
default:
|
||||
return DSL.position(DSL.substring(in, startIndex), search).add(startIndex).sub(one());
|
||||
}
|
||||
|
||||
@ -37,6 +37,8 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.SQLDataType.DECIMAL;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import org.jooq.Context;
|
||||
@ -54,7 +56,7 @@ final class RatioToReport extends Function<BigDecimal> {
|
||||
private final Field<? extends Number> field;
|
||||
|
||||
RatioToReport(Field<? extends Number> field) {
|
||||
super("ratio_to_report", SQLDataType.DECIMAL, field);
|
||||
super("ratio_to_report", DECIMAL, field);
|
||||
|
||||
this.field = field;
|
||||
}
|
||||
@ -69,8 +71,15 @@ final class RatioToReport extends Function<BigDecimal> {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
default:
|
||||
ctx.visit(field.cast(SQLDataType.DECIMAL))
|
||||
ctx.visit(field.cast(DECIMAL))
|
||||
.sql(" / ")
|
||||
.visit(DSL.sum(field));
|
||||
toSQLOverClause(ctx);
|
||||
|
||||
@ -88,6 +88,7 @@ enum Term {
|
||||
|
||||
|
||||
|
||||
|
||||
case DERBY:
|
||||
case SQLITE:
|
||||
return "8 * length";
|
||||
@ -111,6 +112,7 @@ enum Term {
|
||||
|
||||
|
||||
|
||||
|
||||
case DERBY:
|
||||
case SQLITE:
|
||||
return "length";
|
||||
@ -182,6 +184,7 @@ enum Term {
|
||||
|
||||
|
||||
|
||||
|
||||
case DERBY:
|
||||
case SQLITE:
|
||||
return "length";
|
||||
|
||||
@ -106,19 +106,19 @@ final class Values<R extends Record> extends AbstractTable<R> {
|
||||
|
||||
|
||||
|
||||
|
||||
case FIREBIRD:
|
||||
case MARIADB:
|
||||
case MYSQL: {
|
||||
Select<Record> selects = null;
|
||||
for (Row row : rows) {
|
||||
Select<Record> select = create().select(row.fields());
|
||||
|
||||
if (selects == null) {
|
||||
for (Row row : rows) {
|
||||
Select<Record> select = DSL.select(row.fields());
|
||||
|
||||
if (selects == null)
|
||||
selects = select;
|
||||
}
|
||||
else {
|
||||
else
|
||||
selects = selects.unionAll(select);
|
||||
}
|
||||
}
|
||||
|
||||
ctx.formatIndentStart()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user