fix: EXPOSED-983 Support reading JSONB columns outside transaction by using ResultRow.database instead of current transaction when checking dialect#2748
Open
bystam wants to merge 1 commit intoJetBrains:mainfrom
Conversation
27e6b70 to
049a8e7
Compare
bystam
commented
Mar 3, 2026
Contributor
Author
There was a problem hiding this comment.
From what I could tell, currentDialect is SQLiteDialect was double-checked both here and inside needsBinaryFormatCast, but only one of them should be required?
At least from what I could tell from the callers of both functions
049a8e7 to
70700fa
Compare
bystam
commented
Mar 3, 2026
Contributor
Author
There was a problem hiding this comment.
This is the fix that actually avoids the crash - by using database?.dialect and avoiding checking the current transaction
Contributor
Author
There was a problem hiding this comment.
I couldn't find a way to inject the "current database" as easily from from 2 other places where isJsonBColumnForCasting is called:
Alias.ktTable.kt
Maybe it's OK to have them simply use the thread-local?
bystam
commented
Mar 3, 2026
Contributor
Author
There was a problem hiding this comment.
This last line crashes without the fix upstairs
70700fa to
1a8801d
Compare
… using ResultRow.database instead of current transaction when checking dialect
1a8801d to
8b0597d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
A recent change in how JSONB is treated in SQLite has caused an unexpected behavior when reading JSONB columns outside the transaction.
For us it's a common pattern to return entities from a transaction and then perform read-only operations on them (such as writing to some kind of JSON endpoint output), and when bumping to 1.0.0 we started seeing crashes, because the change linked upstairs pokes at
currentDialectwhen parsing the json column.By checking the stack trace, I noticed that the specific codepath that crashes has access to the database use to retrieve the
ResultRow, and therefore we can avoid the crash by reading the dialect from there instead of from the thread-local.Type of Change
Please mark the relevant options with an "X":
Updates/remove existing public API methods:
Affected databases:
Note: I'm not sure if this change can be considered to affect any of these databases specifically
Checklist
Related Issues
https://youtrack.jetbrains.com/issue/EXPOSED-983/JSONB-columns-cannot-be-read-outside-of-transaction