aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/iciql/TableDefinition.java
diff options
context:
space:
mode:
authorJames Moger <james.moger@gmail.com>2012-10-15 10:55:47 -0400
committerJames Moger <james.moger@gmail.com>2012-10-15 10:55:47 -0400
commit75b3c1c1cf2203940634168e5a618b3d276fc325 (patch)
treec2f6e4d21feb504dcd88e56366dd636b86d2e29f /src/com/iciql/TableDefinition.java
parent913ac2ce21edba56cc4b620e194f4bddce4b3cb2 (diff)
downloadiciql-75b3c1c1cf2203940634168e5a618b3d276fc325.tar.gz
iciql-75b3c1c1cf2203940634168e5a618b3d276fc325.zip
Fix name collissions on indexes, unique keys, and foreign keys
Diffstat (limited to 'src/com/iciql/TableDefinition.java')
-rw-r--r--src/com/iciql/TableDefinition.java14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/com/iciql/TableDefinition.java b/src/com/iciql/TableDefinition.java
index a2b4f36..1ecf394 100644
--- a/src/com/iciql/TableDefinition.java
+++ b/src/com/iciql/TableDefinition.java
@@ -294,7 +294,7 @@ public class TableDefinition<T> {
private void addIndex(String name, IndexType type, List<String> columnNames) {
IndexDefinition index = new IndexDefinition();
if (StringUtils.isNullOrEmpty(name)) {
- index.indexName = tableName + "_" + indexes.size();
+ index.indexName = tableName + "_idx_" + indexes.size();
} else {
index.indexName = name;
}
@@ -325,7 +325,7 @@ public class TableDefinition<T> {
private void addConstraintUnique(String name, List<String> columnNames) {
ConstraintUniqueDefinition constraint = new ConstraintUniqueDefinition();
if (StringUtils.isNullOrEmpty(name)) {
- constraint.constraintName = tableName + "_" + constraintsUnique.size();
+ constraint.constraintName = tableName + "_unique_" + constraintsUnique.size();
} else {
constraint.constraintName = name;
}
@@ -886,8 +886,8 @@ public class TableDefinition<T> {
try {
stat.executeUpdate();
} catch (IciqlException e) {
- // maybe we should check more error codes
- if (e.getIciqlCode() != IciqlException.CODE_OBJECT_ALREADY_EXISTS) {
+ if (e.getIciqlCode() != IciqlException.CODE_OBJECT_ALREADY_EXISTS
+ && e.getIciqlCode() != IciqlException.CODE_DUPLICATE_KEY) {
throw e;
}
}
@@ -901,8 +901,8 @@ public class TableDefinition<T> {
try {
stat.executeUpdate();
} catch (IciqlException e) {
- // maybe we should check more error codes
- if (e.getIciqlCode() != IciqlException.CODE_OBJECT_ALREADY_EXISTS) {
+ if (e.getIciqlCode() != IciqlException.CODE_OBJECT_ALREADY_EXISTS
+ && e.getIciqlCode() != IciqlException.CODE_DUPLICATE_KEY) {
throw e;
}
}
@@ -1090,7 +1090,7 @@ public class TableDefinition<T> {
ConstraintUpdateType updateType, ConstraintDeferrabilityType deferrabilityType) {
ConstraintForeignKeyDefinition constraint = new ConstraintForeignKeyDefinition();
if (StringUtils.isNullOrEmpty(name)) {
- constraint.constraintName = tableName + "_" + constraintsForeignKey.size();
+ constraint.constraintName = tableName + "_fkey_" + constraintsForeignKey.size();
} else {
constraint.constraintName = name;
}