Skip to content

Commit 978c94a

Browse files
gwennmbellade
authored andcommitted
HHH-19444 SQLiteDialect - Fix ViolatedConstraintNameExtractor
See sqlite/sqlite@f9c8ce3 > Standardize the error messages generated by constraint failures to a format of "$TYPE constraint failed: $DETAIL". Also in case [extended result codes](http://sqlite.org/c3ref/extended_result_codes.html) are activated, we need the `& 0xFF`. And as there seems to be no way to tell `extractUsingTemplate` that there is no `templateEnd`, the linefeed is used... See [original](https://github.com/gwenn/sqlite-dialect/blob/c87223460e3335ff4f041e012bd0d22df99fa2af/src/main/java/org/sqlite/hibernate/dialect/SQLiteDialect.java#L244-L253) code and associated [test](https://github.com/gwenn/sqlite-dialect/blob/c87223460e3335ff4f041e012bd0d22df99fa2af/src/test/java/org/hibernate/tutorial/annotations/AnnotationsIllustrationTest.java#L95-L105) for reference.
1 parent 59d3453 commit 978c94a

File tree

1 file changed

+2
-2
lines changed
  • hibernate-community-dialects/src/main/java/org/hibernate/community/dialect

1 file changed

+2
-2
lines changed

hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SQLiteDialect.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,9 +457,9 @@ public ViolatedConstraintNameExtractor getViolatedConstraintNameExtractor() {
457457

458458
private static final ViolatedConstraintNameExtractor EXTRACTOR =
459459
new TemplatedViolatedConstraintNameExtractor( sqle -> {
460-
final int errorCode = JdbcExceptionHelper.extractErrorCode( sqle );
460+
final int errorCode = JdbcExceptionHelper.extractErrorCode( sqle ) & 0xFF;
461461
if (errorCode == SQLITE_CONSTRAINT) {
462-
return extractUsingTemplate( "constraint ", " failed", sqle.getMessage() );
462+
return extractUsingTemplate( "constraint failed: ", "\n", sqle.getMessage() );
463463
}
464464
return null;
465465
} );

0 commit comments

Comments
 (0)