diff options
author | James Moger <james.moger@gmail.com> | 2012-10-15 12:17:02 -0400 |
---|---|---|
committer | James Moger <james.moger@gmail.com> | 2012-10-15 12:17:02 -0400 |
commit | 6d3704b7bad4732a289c0be68e8f18a1fdf8abac (patch) | |
tree | fd4e7153189aba4af06859d1d31dce5cb31f3c93 /src/com/iciql/IciqlException.java | |
parent | ef95be59dbd124ee07d195ef3706e1daaa25f768 (diff) | |
download | iciql-6d3704b7bad4732a289c0be68e8f18a1fdf8abac.tar.gz iciql-6d3704b7bad4732a289c0be68e8f18a1fdf8abac.zip |
Added drop reference table test (fails on H2)
Unfortunately, it looks like H2 1.3.168 has a bug which allows you to
drop a table even though there are active constraints referencing it.
HSQL, Derby, MySQL, and PostgreSQL all throw a constraint violation
exception, as expected, but H2 does not.
Diffstat (limited to 'src/com/iciql/IciqlException.java')
-rw-r--r-- | src/com/iciql/IciqlException.java | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/com/iciql/IciqlException.java b/src/com/iciql/IciqlException.java index 320604d..38c8fac 100644 --- a/src/com/iciql/IciqlException.java +++ b/src/com/iciql/IciqlException.java @@ -29,6 +29,7 @@ public class IciqlException extends RuntimeException { public static final int CODE_DUPLICATE_KEY = 2;
public static final int CODE_OBJECT_NOT_FOUND = 3;
public static final int CODE_OBJECT_ALREADY_EXISTS = 4;
+ public static final int CODE_CONSTRAINT_VIOLATION = 5;
private static final String TOKEN_UNMAPPED_FIELD = "\\? (=|\\>|\\<|\\<\\>|!=|\\>=|\\<=|LIKE|BETWEEN) \\?";
@@ -97,6 +98,9 @@ public class IciqlException extends RuntimeException { if ("23000".equals(state)) {
// MySQL duplicate primary key on insert
iciqlCode = CODE_DUPLICATE_KEY;
+ if (s.getErrorCode() == 1217) {
+ iciqlCode = CODE_CONSTRAINT_VIOLATION;
+ }
} else if ("23505".equals(state)) {
// Derby duplicate primary key on insert
iciqlCode = CODE_DUPLICATE_KEY;
@@ -139,6 +143,15 @@ public class IciqlException extends RuntimeException { } else if ("42504".equals(state)) {
// HSQL index already exists
iciqlCode = CODE_OBJECT_ALREADY_EXISTS;
+ } else if ("2BP01".equals(state)) {
+ // PostgreSQL constraint violation
+ iciqlCode = CODE_CONSTRAINT_VIOLATION;
+ } else if ("42533".equals(state)) {
+ // HSQL constraint violation
+ iciqlCode = CODE_CONSTRAINT_VIOLATION;
+ } else if ("X0Y25".equals(state)) {
+ // Derby constraint violation
+ iciqlCode = CODE_CONSTRAINT_VIOLATION;
}
}
}
|