Skip to content

[OPENJPA-3028] Fix SUBSTRING without length beyond the string on SQL Server - #284

Merged
solomax merged 1 commit into
masterfrom
OPENJPA-3028-mssql-substring
Nov 8, 2026
Merged

solomax merged 1 commit into
masterfrom
OPENJPA-3028-mssql-substring

Conversation

@rzo1

@rzo1 rzo1 commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

SUBSTRING(s, start) computed its length as LEN(s) - (start - 1), which is negative for a start beyond the string ("Invalid length parameter passed to the LEFT or SUBSTRING function"). It now uses DATALENGTH(s), which also keeps trailing blanks.

Fixes TestEJBQLFunction.testSubstringBeyondString on SQL Server, reported in #283.

…Server

SUBSTRING(s, start) used LEN(s) - (start - 1) as length, which is negative
when start is beyond the string and fails on SQL Server. Use DATALENGTH(s),
which also keeps trailing blanks.
@solomax
solomax merged commit ac9bbc7 into master Nov 8, 2026
4 checks passed
@solomax
solomax deleted the OPENJPA-3028-mssql-substring branch November 8, 2026 04:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants