private void addIndex(String name, IndexType type, List<String> columnNames) {\r
IndexDefinition index = new IndexDefinition();\r
if (StringUtils.isNullOrEmpty(name)) {\r
- index.indexName = tableName + "_" + indexes.size();\r
+ index.indexName = tableName + "_idx_" + indexes.size();\r
} else {\r
index.indexName = name;\r
}\r
private void addConstraintUnique(String name, List<String> columnNames) {\r
ConstraintUniqueDefinition constraint = new ConstraintUniqueDefinition();\r
if (StringUtils.isNullOrEmpty(name)) {\r
- constraint.constraintName = tableName + "_" + constraintsUnique.size();\r
+ constraint.constraintName = tableName + "_unique_" + constraintsUnique.size();\r
} else {\r
constraint.constraintName = name;\r
}\r
try {\r
stat.executeUpdate();\r
} catch (IciqlException e) {\r
- // maybe we should check more error codes\r
- if (e.getIciqlCode() != IciqlException.CODE_OBJECT_ALREADY_EXISTS) {\r
+ if (e.getIciqlCode() != IciqlException.CODE_OBJECT_ALREADY_EXISTS\r
+ && e.getIciqlCode() != IciqlException.CODE_DUPLICATE_KEY) {\r
throw e;\r
}\r
}\r
try {\r
stat.executeUpdate();\r
} catch (IciqlException e) {\r
- // maybe we should check more error codes\r
- if (e.getIciqlCode() != IciqlException.CODE_OBJECT_ALREADY_EXISTS) {\r
+ if (e.getIciqlCode() != IciqlException.CODE_OBJECT_ALREADY_EXISTS\r
+ && e.getIciqlCode() != IciqlException.CODE_DUPLICATE_KEY) {\r
throw e;\r
}\r
}\r
ConstraintUpdateType updateType, ConstraintDeferrabilityType deferrabilityType) {\r
ConstraintForeignKeyDefinition constraint = new ConstraintForeignKeyDefinition();\r
if (StringUtils.isNullOrEmpty(name)) {\r
- constraint.constraintName = tableName + "_" + constraintsForeignKey.size();\r
+ constraint.constraintName = tableName + "_fkey_" + constraintsForeignKey.size();\r
} else {\r
constraint.constraintName = name;\r
}\r
String index = rs.getString("INDEX_NAME");
list.add((col + ":" + index).toLowerCase());
}
- assertTrue(list.contains("name:annotatedproduct_0"));
- assertTrue(list.contains("cat:annotatedproduct_0"));
+ assertTrue(list.contains("name:annotatedproduct_idx_0"));
+ assertTrue(list.contains("cat:annotatedproduct_idx_0"));
assertTrue(list.contains("name:nameidx"));
}
// a poor test, but a start
String dbName = IciqlSuite.getDatabaseEngineName(db);
if (dbName.equals("H2")) {
- assertEquals(1579, models.get(0).length());
+ assertEquals(1587, models.get(0).length());
} else if (dbName.startsWith("HSQL")) {
// HSQL uses Double instead of Float
- assertEquals(1583, models.get(0).length());
+ assertEquals(1591, models.get(0).length());
} else if (dbName.equals("Apache Derby")) {
// Derby uses java.sql.Timestamp not java.util.Date
// Derby uses username as schema name
- assertEquals(1593, models.get(0).length());
+ assertEquals(1601, models.get(0).length());
} else if (dbName.equals("PostgreSQL")) {
- assertEquals(1635, models.get(0).length());
+ assertEquals(1643, models.get(0).length());
} else if (dbName.equals("MySQL")) {
// MySQL uses timestamp default values like
// 0000-00-00 00:00:00 and CURRENT_TIMESTAMP
- assertEquals(1665, models.get(0).length());
+ assertEquals(1673, models.get(0).length());
} else {
// unknown database
assertEquals(0, models.get(0).length());