Skip to content

Commit

Permalink
fix Update constraint params
Browse files Browse the repository at this point in the history
  • Loading branch information
Mythicaeda committed Mar 3, 2025
1 parent af48f40 commit 6ecb0cf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void updateConstraintParameterSchema(final long constraintId, final long
updateConstraintAction.update(constraintId, revision, schema);
}
} catch (final SQLException ex) {
throw new DatabaseException("Failed to get scheduling specification revision data", ex);
throw new DatabaseException("Failed to get constraint revision data", ex);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@
public class UpdateConstraintParametersAction implements AutoCloseable {
private static final @Language("SQL") String sql = """
update merlin.constraint_definition
set parameter_schema=?
where (constraint_id, revision)= (?,?)
returning constraint_id
set parameter_schema=?::jsonb
where (constraint_id, revision)= (?,?);
""";

private final PreparedStatement statement;
Expand All @@ -28,10 +27,10 @@ public void update(final long constraintId, final long revision, final ValueSche
this.statement.setString(1, new ValueSchemaJsonParser().unparse(schema).toString());
this.statement.setLong(2, constraintId);
this.statement.setLong(3, revision);
this.statement.executeUpdate();
final var rowsUpdated = this.statement.executeUpdate();

try (final var results = statement.executeQuery()) {
if (!results.next()) throw new FailedUpdateException("merlin.constraint_definition");
if (rowsUpdated != 1) {
throw new FailedUpdateException("merlin.constraint_definition");
}
}

Expand Down

0 comments on commit 6ecb0cf

Please sign in to comment.