use of ch.ehi.sqlgen.repository.DbColId in project ili2db by claeis.
the class GeneratorMsSql method visitColumn.
@Override
public void visitColumn(DbTable dbTab, DbColumn column) throws IOException {
String type = "";
if (column instanceof DbColBoolean) {
type = "BIT";
} else if (column instanceof DbColDateTime) {
type = "DATETIME";
} else if (column instanceof DbColDate) {
type = "DATE";
} else if (column instanceof DbColTime) {
type = "TIME";
} else if (column instanceof DbColDecimal) {
DbColDecimal col = (DbColDecimal) column;
type = "DECIMAL(" + Integer.toString(col.getSize()) + "," + Integer.toString(col.getPrecision()) + ")";
} else if (column instanceof DbColGeometry) {
type = "GEOMETRY";
} else if (column instanceof DbColId) {
type = "BIGINT";
} else if (column instanceof DbColUuid) {
type = "VARCHAR(36)";
} else if (column instanceof DbColNumber) {
DbColNumber col = (DbColNumber) column;
type = "NUMERIC(" + Integer.toString(col.getSize()) + ")";
} else if (column instanceof DbColVarchar) {
int colsize = ((DbColVarchar) column).getSize();
if (colsize != DbColVarchar.UNLIMITED)
type = "VARCHAR(" + Integer.toString(colsize) + ")";
else
type = "VARCHAR(MAX)";
} else {
type = "VARCHAR(MAX)";
}
String isNull = column.isNotNull() ? "NOT NULL" : "NULL";
if (column.isPrimaryKey()) {
isNull = "PRIMARY KEY";
}
String sep = " ";
String defaultValue = "";
if (column.getDefaultValue() != null) {
defaultValue = sep + "DEFAULT (" + column.getDefaultValue() + ")";
sep = " ";
}
String name = column.getName();
out.write(getIndent() + colSep + "[" + name + "] " + type + " " + isNull + defaultValue + newline());
colSep = ",";
}
use of ch.ehi.sqlgen.repository.DbColId in project ili2db by claeis.
the class AbstractRecordConverter method addKeyCol.
public DbColId addKeyCol(DbTable table) {
DbColId dbColId = new DbColId();
dbColId.setName(colT_ID);
dbColId.setNotNull(true);
dbColId.setPrimaryKey(true);
if (table.isRequiresSequence()) {
dbColId.setDefaultValue(idGen.getDefaultValueSql());
}
table.addColumn(dbColId);
return dbColId;
}
Aggregations