use of com.wplatform.ddal.value.DataType in project jdbc-shards by wplatform.
the class CreateTableExecutor method generateColumnsFromQuery.
private void generateColumnsFromQuery() {
int columnCount = prepared.getQuery().getColumnCount();
ArrayList<Expression> expressions = prepared.getQuery().getExpressions();
for (int i = 0; i < columnCount; i++) {
Expression expr = expressions.get(i);
int type = expr.getType();
String name = expr.getAlias();
long precision = expr.getPrecision();
int displaySize = expr.getDisplaySize();
DataType dt = DataType.getDataType(type);
if (precision > 0 && (dt.defaultPrecision == 0 || (dt.defaultPrecision > precision && dt.defaultPrecision < Byte.MAX_VALUE))) {
// dont' set precision to MAX_VALUE if this is the default
precision = dt.defaultPrecision;
}
int scale = expr.getScale();
if (scale > 0 && (dt.defaultScale == 0 || (dt.defaultScale > scale && dt.defaultScale < precision))) {
scale = dt.defaultScale;
}
if (scale > precision) {
precision = scale;
}
Column col = new Column(name, type, precision, scale, displaySize);
prepared.addColumn(col);
}
}
Aggregations