Skip to content

Commit

Permalink
PHOENIX-5668: Add Full table name to the error message for constraint…
Browse files Browse the repository at this point in the history
… violation exceptions

Signed-off-by: Xinyi Yan <xyan@salesforce.com>
  • Loading branch information
nsgupta-1 authored and yanxinyi committed Jan 10, 2020
1 parent d06806c commit ef82f6c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ public void testDefaultMiddlePrimaryKey() throws Exception {
fail();
} catch (SQLException e) {
assertEquals(SQLExceptionCode.CONSTRAINT_VIOLATION.getErrorCode(), e.getErrorCode());
assertTrue(e.getMessage().contains(table));
}

dml = "UPSERT INTO " + table + " VALUES (1, 2)";
Expand All @@ -401,6 +402,7 @@ public void testDefaultMiddlePrimaryKey() throws Exception {
fail();
} catch (SQLException e) {
assertEquals(SQLExceptionCode.CONSTRAINT_VIOLATION.getErrorCode(), e.getErrorCode());
assertTrue(e.getMessage().contains(table));
}

dml = "UPSERT INTO " + table + " VALUES (1, 2, 3)";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,8 @@ public MutationPlan compile(UpsertStatement upsert) throws SQLException {
for (i = posOffset; i < table.getColumns().size(); i++) {
PColumn column = table.getColumns().get(i);
if (!columnsBeingSet.get(i) && !column.isNullable() && column.getExpressionStr() == null) {
throw new ConstraintViolationException(SchemaUtil.getColumnDisplayName(column) + " may not be null");
throw new ConstraintViolationException(table.getName().getString() + "."
+ SchemaUtil.getColumnDisplayName(column) + " may not be null");
}
}
}
Expand Down Expand Up @@ -621,7 +622,8 @@ public MutationPlan compile(UpsertStatement upsert) throws SQLException {
for (int i = posOffset + nValuesToSet; i < table.getColumns().size(); i++) {
PColumn column = table.getColumns().get(i);
if (!column.isNullable() && column.getExpressionStr() == null) {
throw new ConstraintViolationException(SchemaUtil.getColumnDisplayName(column) + " may not be null");
throw new ConstraintViolationException(table.getName().getString() + "."
+ SchemaUtil.getColumnDisplayName(column) + " may not be null");
}
}
}
Expand Down

0 comments on commit ef82f6c

Please sign in to comment.