Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DB2 - DbJson length, treat length = 4000+ as LOB type for DB2 #3354

Merged
merged 1 commit into from
Mar 7, 2024

Conversation

rPraml
Copy link
Contributor

@rPraml rPraml commented Mar 4, 2024

Hello @rbygrave,

this fixes the

TestJsonMapBasic.whereManyPredicateDb2:76 » Persistence Query threw SQLException:DB2 SQL Error: SQLCODE=-134, SQLSTATE=42907

I've bisected and it was introduced by this commit: 11c9bdf because it changes EBasicJsonMap.content property from @DbJson to

  @DbJson(length = 5000)
  Map<String, Object> content;

The problem is, that a field with value of length 5000 is no longer detected as lob. And lob fields are not allowed in DB2 distinct queries...
We've added a workaround for this some time ago: #2511
Unfortunately, the detection mechanism is not precise enough. So as quick workaround (!) I added to the "isDbLob" a check if the dbLength > 255

I'm not happy with this check, because there is also a "use best type detection" here: #3107 so that lengths > 4000 are mapped to lob instead to varchar.

So from DB2 perspective, it would be better to use dbLength > 4000 as fix ?

I could either refactor the whole "unselectLobs" code to "unselectLobsForDb2". "isDbLob" -> "isDb2Lob" ans so on. So I can use hard coded values.
(All in all, distincts and lobs are very annoying in DB2 and it seems that this is really only needed for DB2 and maybe Oracle? - see comment here)

OR

I find a way to determine the exact DDL type from a BeanProperty, but this is not easily to determine, because it is hidden in "renderDbType" and so on.

in short words, the easiest fix would be to assume that a DbJson is a lob if dbLength > 4000. What do you think about this?

cheers
Roland

@rob-bygrave
Copy link
Contributor

assume that a DbJson is a lob if dbLength > 4000.

That sounds reasonable to me.

rbygrave added a commit that referenced this pull request Mar 7, 2024
- Use 4000 to match the DB2 logic for considering a column a lob (for distinct etc)
- Rename distinctNoLobs -> platformDistinctNoLobs
- Rename  isDbLob() -> isLobForPlatform()
- Rename unselectLobs() -> unselectLobsForPlatform()
@rbygrave rbygrave merged commit a48e96c into ebean-orm:master Mar 7, 2024
1 check passed
@rbygrave rbygrave added this to the 14.0.2 milestone Mar 7, 2024
@rbygrave
Copy link
Member

rbygrave commented Mar 7, 2024

  • Use 4000 to match the DB2 logic for considering a column a lob (for distinct etc)
  • Rename distinctNoLobs -> platformDistinctNoLobs
  • Rename isDbLob() -> isLobForPlatform()
  • Rename unselectLobs() -> unselectLobsForPlatform()

@rob-bygrave rob-bygrave changed the title [Draft] FIX broken test for DB2 DB2 - DbJson length, treat length = 4000+ as LOB type for DB2 Mar 14, 2024
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