本文整理汇总了Java中liquibase.datatype.DataTypeFactory类的典型用法代码示例。如果您正苦于以下问题:Java DataTypeFactory类的具体用法?Java DataTypeFactory怎么用?Java DataTypeFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataTypeFactory类属于liquibase.datatype包,在下文中一共展示了DataTypeFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: generateSql
import liquibase.datatype.DataTypeFactory; //导入依赖的package包/类
@Override
public Sql[] generateSql(CreateDatabaseChangeLogTableStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
String TypeNameChar = "STRING";
CreateTableStatement createTableStatement = new CreateTableStatement(database.getLiquibaseCatalogName(), database.getLiquibaseSchemaName(), database.getDatabaseChangeLogTableName())
.setTablespace(database.getLiquibaseTablespaceName())
.addColumn("ID", DataTypeFactory.getInstance().fromDescription(TypeNameChar, database))
.addColumn("AUTHOR", DataTypeFactory.getInstance().fromDescription(TypeNameChar, database))
.addColumn("FILENAME", DataTypeFactory.getInstance().fromDescription(TypeNameChar, database))
.addColumn("DATEEXECUTED", DataTypeFactory.getInstance().fromDescription("TIMESTAMP", database))
.addColumn("ORDEREXECUTED", DataTypeFactory.getInstance().fromDescription("INT", database))
.addColumn("EXECTYPE", DataTypeFactory.getInstance().fromDescription(TypeNameChar, database))
.addColumn("MD5SUM", DataTypeFactory.getInstance().fromDescription(TypeNameChar, database))
.addColumn("DESCRIPTION", DataTypeFactory.getInstance().fromDescription(TypeNameChar, database))
.addColumn("COMMENTS", DataTypeFactory.getInstance().fromDescription(TypeNameChar, database))
.addColumn("TAG", DataTypeFactory.getInstance().fromDescription(TypeNameChar, database))
.addColumn("LIQUIBASE", DataTypeFactory.getInstance().fromDescription(TypeNameChar, database))
.addColumn("CONTEXTS", DataTypeFactory.getInstance().fromDescription(TypeNameChar, database))
.addColumn("LABELS", DataTypeFactory.getInstance().fromDescription(TypeNameChar, database))
.addColumn("DEPLOYMENT_ID", DataTypeFactory.getInstance().fromDescription(TypeNameChar, database));
return CustomSqlGenerator.generateSql(database, UserSessionSettings.syncDdlStart(), createTableStatement, UserSessionSettings.syncDdlStop());
}
开发者ID:eselyavka,项目名称:liquibase-impala,代码行数:24,代码来源:MetastoreCreateDatabaseChangeLogTableGenerator.java
示例2: generateAlterStatement
import liquibase.datatype.DataTypeFactory; //导入依赖的package包/类
@Override
public String generateAlterStatement(Database database) {
StringBuilder alter = new StringBuilder();
alter.append("MODIFY ");
String columnName = database.escapeColumnName(getCatalogName(), getSchemaName(), getTableName(), getColumnName());
alter.append(columnName);
alter.append(' ');
if (getNewDataType() != null) {
String dataType = String.valueOf(DataTypeFactory.getInstance().fromDescription(getNewDataType(), database).toDatabaseDataType(database));
alter.append(dataType);
}
return alter.toString();
}
开发者ID:adangel,项目名称:liquibase-percona,代码行数:17,代码来源:PerconaModifyDataTypeChange.java
示例3: validate
import liquibase.datatype.DataTypeFactory; //导入依赖的package包/类
@Override
public ValidationErrors validate(final AddColumnStatement statement,
final Database database, final SqlGeneratorChain sqlGeneratorChain) {
final ValidationErrors errors = new ValidationErrors();
final LiquibaseDataType dataType = DataTypeFactory.getInstance()
.fromDescription(statement.getColumnType(), database);
// Ensure that the SRID parameter is provided.
if (dataType instanceof GeometryType) {
final GeometryType geometryType = (GeometryType) dataType;
if (geometryType.getSRID() == null) {
errors.addError("The SRID parameter is required on the geometry type");
}
}
final ValidationErrors chainErrors = sqlGeneratorChain.validate(
statement, database);
if (chainErrors != null) {
errors.addAll(chainErrors);
}
return errors;
}
开发者ID:lonnyj,项目名称:liquibase-spatial,代码行数:22,代码来源:AddGeometryColumnGeneratorGeoDB.java
示例4: generateSql
import liquibase.datatype.DataTypeFactory; //导入依赖的package包/类
@Override
public Sql[] generateSql(ModifyDataTypeStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
String alterTable = "ALTER TABLE " + database.escapeTableName(statement.getCatalogName(), statement.getSchemaName(), statement.getTableName());
// add "MODIFY"
alterTable += " ADD ";
// add column name
alterTable += database.escapeColumnName(statement.getCatalogName(), statement.getSchemaName(), statement.getTableName(), statement.getColumnName());
// alterTable += getPreDataTypeString(database); // adds a space if nothing else
// add column type
alterTable += " "+ DataTypeFactory.getInstance().fromDescription(statement.getNewDataType(), database).toDatabaseDataType(database).toSql();
return new Sql[]{new UnparsedSql(alterTable)};
}
开发者ID:liquibase,项目名称:liquibase-teradata,代码行数:18,代码来源:ModifyDataTypeGeneratorTeradata.java
示例5: generateSql
import liquibase.datatype.DataTypeFactory; //导入依赖的package包/类
@Override
public Sql[] generateSql(AddDefaultValueStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
if (!supports(statement, database)) {
return sqlGeneratorChain.generateSql(statement, database);
}
Object defaultValue = statement.getDefaultValue();
return new Sql[]{
new UnparsedSql("ALTER TABLE " + database.escapeTableName(statement.getCatalogName(), statement.getSchemaName(), statement.getTableName()) +
" ALTER (" + database.escapeColumnName(statement.getCatalogName(), statement.getSchemaName(), statement.getTableName(), statement.getColumnName()) +
" " + DataTypeFactory.getInstance().fromDescription(statement.getColumnDataType(), database).toDatabaseDataType(database) +
" DEFAULT " + DataTypeFactory.getInstance().fromObject(defaultValue, database).objectToSql(defaultValue, database) +
")",
getAffectedColumn(statement))
};
}
开发者ID:lbitonti,项目名称:liquibase-hana,代码行数:17,代码来源:AddDefaultValueGeneratorHanaDB.java
示例6: testWithColumnUniqueConstraint
import liquibase.datatype.DataTypeFactory; //导入依赖的package包/类
@Test
public void testWithColumnUniqueConstraint() {
Database database = new HanaDBDatabase();
CreateTableStatement statement = new CreateTableStatement(null, null, "TABLE_NAME");
UniqueConstraint uniqueConstraint = new UniqueConstraint();
uniqueConstraint.setConstraintName("COLUMN1_UNIQUE");
uniqueConstraint.addColumns("COLUMN1_NAME");
statement.addColumn("COLUMN1_NAME",
DataTypeFactory.getInstance().fromDescription("int",database));
statement.addColumnConstraint(uniqueConstraint);
assertEquals("CREATE TABLE \"TABLE_NAME\" (\"COLUMN1_NAME\" INTEGER, UNIQUE (\"COLUMN1_NAME\"))",
this.generatorUnderTest.generateSql(statement, database, null)[0].toSql());
}
开发者ID:lbitonti,项目名称:liquibase-hana,代码行数:18,代码来源:CreateTableGeneratorHanaDBTest.java
示例7: testWith2ColumnsUniqueConstraint
import liquibase.datatype.DataTypeFactory; //导入依赖的package包/类
@Test
public void testWith2ColumnsUniqueConstraint() {
Database database = new HanaDBDatabase();
CreateTableStatement statement = new CreateTableStatement(null, null, "TABLE_NAME");
UniqueConstraint uniqueConstraint = new UniqueConstraint();
uniqueConstraint.setConstraintName("COLUMN1_UNIQUE");
uniqueConstraint.addColumns("COLUMN1_NAME", "COLUMN2_NAME");
statement.addColumn("COLUMN1_NAME",
DataTypeFactory.getInstance().fromDescription("int",database));
statement.addColumn("COLUMN2_NAME",
DataTypeFactory.getInstance().fromDescription("varchar(100)",database));
statement.addColumnConstraint(uniqueConstraint);
assertEquals("CREATE TABLE \"TABLE_NAME\" (\"COLUMN1_NAME\" INTEGER, \"COLUMN2_NAME\" NVARCHAR(100), UNIQUE (\"COLUMN1_NAME\", \"COLUMN2_NAME\"))",
this.generatorUnderTest.generateSql(statement, database, null)[0].toSql());
}
开发者ID:lbitonti,项目名称:liquibase-hana,代码行数:20,代码来源:CreateTableGeneratorHanaDBTest.java
示例8: runUpdateOnOldChangelogTableFormat
import liquibase.datatype.DataTypeFactory; //导入依赖的package包/类
@Test
public void runUpdateOnOldChangelogTableFormat() throws Exception {
if (database == null) {
return;
}
Liquibase liquibase = createLiquibase(completeChangeLog);
clearDatabase(liquibase);
((JdbcConnection) database.getConnection()).getUnderlyingConnection().createStatement().execute("CREATE TABLE DATABASECHANGELOG (id varchar(150) NOT NULL, " +
"author varchar(150) NOT NULL, " +
"filename varchar(255) NOT NULL, " +
"dateExecuted "+ DataTypeFactory.getInstance().fromDescription("datetime", database).toDatabaseDataType(database) +" NOT NULL, " +
"md5sum varchar(32), " +
"description varchar(255), " +
"comments varchar(255), " +
"tag varchar(255), " +
"liquibase varchar(10), " +
"PRIMARY KEY(id, author, filename))");
liquibase = createLiquibase(completeChangeLog);
liquibase.update(this.contexts);
}
开发者ID:lbitonti,项目名称:liquibase-hana,代码行数:25,代码来源:AbstractIntegrationTest.java
示例9: generateValues
import liquibase.datatype.DataTypeFactory; //导入依赖的package包/类
private void generateValues(StringBuilder sql, HiveInsertStatement statement, Database database) {
sql.append("(");
for (Object newValue : statement.getColumnValues()) {
if (newValue == null || newValue.toString().equalsIgnoreCase("NULL")) {
sql.append("NULL");
} else if (newValue instanceof String && !looksLikeFunctionCall(((String) newValue), database)) {
sql.append(DataTypeFactory.getInstance().fromObject(newValue, database).objectToSql(newValue, database));
} else if (newValue instanceof Date) {
sql.append(database.getDateLiteral(((Date) newValue)));
} else if (newValue instanceof Boolean) {
if (((Boolean) newValue)) {
sql.append(DataTypeFactory.getInstance().getTrueBooleanValue(database));
} else {
sql.append(DataTypeFactory.getInstance().getFalseBooleanValue(database));
}
} else if (newValue instanceof DatabaseFunction) {
sql.append(database.generateDatabaseFunctionValue((DatabaseFunction) newValue));
} else {
sql.append(newValue);
}
sql.append(", ");
}
sql.deleteCharAt(sql.lastIndexOf(" "));
int lastComma = sql.lastIndexOf(",");
if (lastComma >= 0) {
sql.deleteCharAt(lastComma);
}
sql.append(")");
}
开发者ID:eselyavka,项目名称:liquibase-impala,代码行数:33,代码来源:HiveInsertGenerator.java
示例10: generateSql
import liquibase.datatype.DataTypeFactory; //导入依赖的package包/类
@Override
public Sql[] generateSql(CreateDatabaseChangeLogLockTableStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
CreateTableStatement createTableStatement = new CreateTableStatement(database.getLiquibaseCatalogName(), database.getLiquibaseSchemaName(), database.getDatabaseChangeLogLockTableName())
.addColumn("ID", DataTypeFactory.getInstance().fromDescription("INT", database))
.addColumn("LOCKED", DataTypeFactory.getInstance().fromDescription("BOOLEAN", database))
.addColumn("LOCKGRANTED", DataTypeFactory.getInstance().fromDescription("TIMESTAMP", database))
.addColumn("LOCKEDBY", DataTypeFactory.getInstance().fromDescription("STRING", database));
return CustomSqlGenerator.generateSql(database, UserSessionSettings.syncDdlStart(), createTableStatement, UserSessionSettings.syncDdlStop());
}
开发者ID:eselyavka,项目名称:liquibase-impala,代码行数:11,代码来源:MetastoreCreateDatabaseChangeLogLockTableGenerator.java
示例11: timestampAliases
import liquibase.datatype.DataTypeFactory; //导入依赖的package包/类
@Test
public void timestampAliases() throws Exception {
LiquibaseDataType liquibaseDataType = DataTypeFactory.getInstance().fromDescription("datetime", snowflakeDatabase);
String[] aliases = liquibaseDataType.getAliases();
assertEquals(2, aliases.length);
assertThat(aliases, hasItemInArray("datetime"));
assertThat(aliases, hasItemInArray("java.sql.Types.DATETIME"));
}
开发者ID:CDKGlobal,项目名称:liquibase-snowflake,代码行数:9,代码来源:TimestampNTZTypeTest.java
示例12: generateSql
import liquibase.datatype.DataTypeFactory; //导入依赖的package包/类
public Sql[] generateSql(LockDatabaseChangeLogStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
String liquibaseCatalog = database.getLiquibaseCatalogName();
String liquibaseSchema = database.getLiquibaseSchemaName();
UpdateStatement updateStatement = new UpdateStatement(liquibaseCatalog, liquibaseSchema, database.getDatabaseChangeLogLockTableName());
updateStatement.addNewColumnValue("locked", true);
updateStatement.addNewColumnValue("lockgranted", new Timestamp(new java.util.Date().getTime()));
updateStatement.addNewColumnValue("lockedby", "Google Cloud SQL");
updateStatement.setWhereClause(database.escapeColumnName(liquibaseCatalog, liquibaseSchema, database.getDatabaseChangeLogTableName(), "ID") + " = 1 AND " + database.escapeColumnName(liquibaseCatalog, liquibaseSchema, database.getDatabaseChangeLogTableName(), "LOCKED") + " = "+ DataTypeFactory.getInstance().fromDescription("boolean", database).objectToSql(false, database));
return SqlGeneratorFactory.getInstance().generateSql(updateStatement, database);
}
开发者ID:ManyDesigns,项目名称:Portofino,代码行数:14,代码来源:GoogleCloudSQLLockDatabaseChangeLogGenerator.java
示例13: convertColumnToSql
import liquibase.datatype.DataTypeFactory; //导入依赖的package包/类
String convertColumnToSql(AddColumnConfig column, Database database) {
String nullable = "";
ConstraintsConfig constraintsConfig = column.getConstraints();
if (constraintsConfig != null && !constraintsConfig.isNullable()) {
nullable = " NOT NULL";
} else {
nullable = " NULL";
}
String defaultValue = "";
if (column.getDefaultValueObject() != null) {
defaultValue = " DEFAULT " + DataTypeFactory.getInstance().fromObject(column.getDefaultValueObject(), database).objectToSql(column.getDefaultValueObject(), database);
}
String comment = "";
if (StringUtil.isNotEmpty(column.getRemarks())) {
comment += " COMMENT '" + column.getRemarks() + "'";
}
String after = "";
if (StringUtil.isNotEmpty(column.getAfterColumn())) {
after += " AFTER " + database.escapeColumnName(null, null, null, column.getAfterColumn());
}
String constraints = "";
constraints += addForeignKeyConstraint(column, database);
constraints += addUniqueKeyConstraint(column, database);
return "ADD COLUMN " + database.escapeColumnName(null, null, null, column.getName())
+ " " + DataTypeFactory.getInstance().fromDescription(column.getType(), database).toDatabaseDataType(database)
+ nullable
+ defaultValue
+ comment
+ after
+ constraints;
}
开发者ID:adangel,项目名称:liquibase-percona,代码行数:34,代码来源:PerconaAddColumnChange.java
示例14: generateSql
import liquibase.datatype.DataTypeFactory; //导入依赖的package包/类
/**
* @see liquibase.sqlgenerator.core.AddDefaultValueGenerator#generateSql(liquibase.statement.core.AddDefaultValueStatement, liquibase.database.Database, liquibase.sqlgenerator.SqlGeneratorChain)
*/
@Override
public Sql[] generateSql(AddDefaultValueStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
Object defaultValue = statement.getDefaultValue();
LiquibaseDataType defaultValueType = DataTypeFactory.getInstance().fromObject(defaultValue, database);
return new Sql[]{
new UnparsedSql("ALTER TABLE " + database.escapeTableName(statement.getCatalogName(), statement.getSchemaName(), statement.getTableName())
+ " ADD "
+ database.escapeColumnName(statement.getCatalogName(), statement.getSchemaName(), statement.getTableName(), statement.getColumnName())
+ " DEFAULT "
+ (defaultValueType instanceof DateTimeType ?" TIMESTAMP ":(defaultValueType instanceof DateType ?" DATE ":(defaultValueType instanceof TimeType ?" TIME ":"")))
+ defaultValueType.objectToSql(defaultValue, database),
new Column().setRelation(new Table().setName(statement.getTableName()).setSchema(new Schema(statement.getCatalogName(), statement.getSchemaName())).setName(statement.getColumnName())))
};
}
开发者ID:liquibase,项目名称:liquibase-teradata,代码行数:18,代码来源:AddDefaultValueGeneratorTeradata.java
示例15: generateSql
import liquibase.datatype.DataTypeFactory; //导入依赖的package包/类
@Override
public Sql[] generateSql(DropDefaultValueStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
if (!supports(statement, database)) {
return sqlGeneratorChain.generateSql(statement, database);
}
String tableName = statement.getTableName();
String columnName = statement.getColumnName();
String catalogName = statement.getCatalogName();
String schemaToUse = statement.getSchemaName();
if (schemaToUse == null) {
schemaToUse = database.getDefaultSchemaName();
}
String columnDataType = statement.getColumnDataType();
if (columnDataType == null) {
columnDataType = SqlGeneratorHelperHanaDB.getColumnDataDefinition((HanaDBDatabase) database, catalogName, schemaToUse, tableName, columnName);
}
String sql = "ALTER TABLE " + database.escapeTableName(catalogName, schemaToUse, tableName) +
" ALTER (" + database.escapeColumnName(catalogName, schemaToUse, tableName, columnName) +
" " + DataTypeFactory.getInstance().fromDescription(columnDataType, database).toDatabaseDataType(database) +
" DEFAULT NULL)";
return new Sql[]{
new UnparsedSql(sql,
getAffectedColumn(statement))
};
}
开发者ID:lbitonti,项目名称:liquibase-hana,代码行数:29,代码来源:DropDefaultValueGeneratorHanaDB.java
示例16: getDefaultClause
import liquibase.datatype.DataTypeFactory; //导入依赖的package包/类
private String getDefaultClause(AddColumnStatement statement, Database database) {
String clause = "";
Object defaultValue = statement.getDefaultValue();
if (defaultValue != null) {
clause += " DEFAULT " + DataTypeFactory.getInstance().fromObject(defaultValue, database).objectToSql(defaultValue, database);
}
return clause;
}
开发者ID:lbitonti,项目名称:liquibase-hana,代码行数:9,代码来源:AddColumnGeneratorHanaDB.java
示例17: createSampleSqlStatement
import liquibase.datatype.DataTypeFactory; //导入依赖的package包/类
@Override
protected CreateTableStatement createSampleSqlStatement() {
Database database = new HanaDBDatabase();
CreateTableStatement createTableStatement = new CreateTableStatement(null, null, "table_name");
createTableStatement.addColumn("id",
DataTypeFactory.getInstance().fromDescription("int(11) unsigned",database));
return createTableStatement;
}
开发者ID:lbitonti,项目名称:liquibase-hana,代码行数:9,代码来源:CreateTableGeneratorHanaDBTest.java
示例18: testWithColumnWithDefaultValue
import liquibase.datatype.DataTypeFactory; //导入依赖的package包/类
@Test
public void testWithColumnWithDefaultValue() {
Database database = new HanaDBDatabase();
CreateTableStatement statement = new CreateTableStatement(null, null, "TABLE_NAME");
statement.addColumn("COLUMN1_NAME",
DataTypeFactory.getInstance().fromDescription("java.sql.Types.TIMESTAMP",database),
// TypeConverterFactory.getInstance().findTypeConverter(database).getDataType("java.sql.Types.TIMESTAMP", false),
new ColumnConfig().setDefaultValue("null").getDefaultValueObject());
assertEquals("CREATE TABLE \"TABLE_NAME\" (\"COLUMN1_NAME\" TIMESTAMP DEFAULT null)",
this.generatorUnderTest.generateSql(statement, database, null)[0].toSql());
}
开发者ID:lbitonti,项目名称:liquibase-hana,代码行数:14,代码来源:CreateTableGeneratorHanaDBTest.java
示例19: testWithColumnSpecificIntType
import liquibase.datatype.DataTypeFactory; //导入依赖的package包/类
@Test
public void testWithColumnSpecificIntType() {
Database database = new HanaDBDatabase();
CreateTableStatement statement = new CreateTableStatement(null, null, "TABLE_NAME");
statement.addColumn("COLUMN1_NAME",
DataTypeFactory.getInstance().fromDescription("int",database));
assertEquals("CREATE TABLE \"TABLE_NAME\" (\"COLUMN1_NAME\" INTEGER)",
this.generatorUnderTest.generateSql(statement, database, null)[0].toSql());
}
开发者ID:lbitonti,项目名称:liquibase-hana,代码行数:12,代码来源:CreateTableGeneratorHanaDBTest.java
示例20: testCreateMultiColumnPrimary
import liquibase.datatype.DataTypeFactory; //导入依赖的package包/类
@Test
public void testCreateMultiColumnPrimary() throws Exception {
// super.isValid();
Database database = new HanaDBDatabase();
CreateTableStatement createTableStatement = new CreateTableStatement(null, null, "table_name");
createTableStatement.addColumn("id",
DataTypeFactory.getInstance().fromDescription("VARCHAR(150)",database),
new ColumnConfig().setDefaultValue("NULL").getDefaultValueObject());
createTableStatement.addColumn("author",
DataTypeFactory.getInstance().fromDescription("VARCHAR(150)",database),
new ColumnConfig().setDefaultValue("NULL").getDefaultValueObject());
createTableStatement.addColumn("dateExecuted",
DataTypeFactory.getInstance().fromDescription("java.sql.Types.TIMESTAMP",database),
new ColumnConfig().setDefaultValue("NULL").getDefaultValueObject());
createTableStatement.addColumn("description",
DataTypeFactory.getInstance().fromDescription("VARCHAR(255)",database));
createTableStatement.addColumn("revision",
DataTypeFactory.getInstance().fromDescription("int",database));
Database hanadb = new HanaDBDatabase();
SqlGeneratorChain sqlGeneratorChain = new MockSqlGeneratorChain();
assertFalse(generatorUnderTest.validate(createTableStatement, hanadb, new MockSqlGeneratorChain()).hasErrors());
Sql[] generatedSql = generatorUnderTest.generateSql(createTableStatement, hanadb, sqlGeneratorChain);
assertTrue(generatedSql.length == 1);
assertEquals("CREATE TABLE \"table_name\" (\"id\" NVARCHAR(150) DEFAULT null, \"author\" NVARCHAR(150) DEFAULT null, " +
"\"dateExecuted\" TIMESTAMP DEFAULT null, \"description\" NVARCHAR(255), \"revision\" INTEGER)",
generatedSql[0].toSql());
}
开发者ID:lbitonti,项目名称:liquibase-hana,代码行数:31,代码来源:CreateTableGeneratorHanaDBTest.java
注:本文中的liquibase.datatype.DataTypeFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论