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

chunk long strings on insert for Oracle (DAT-16774) #5566

Merged
merged 1 commit into from Feb 12, 2024
Merged

Conversation

StevenMassaro
Copy link
Contributor

Impact

  • Bug fix (non-breaking change which fixes expected existing functionality)
  • Enhancement/New feature (adds functionality without impacting existing logic)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

Oracle forbids values longer than 4000 characters on an insert statement into a clob type column. This PR introduces a workaround which chunks the long string into 4000 character chunks.

Things to be aware of

Things to worry about

If the string chunking code doesn't handle special characters properly, it is possible that you could end up with a string chunk that is longer than 4000 characters, causing an exception. However, this was also the behavior prior to this fix, so the impact is neutral in this case.

Additional Context

import liquibase.statement.DatabaseFunction;
import liquibase.util.StringUtil;

import java.math.BigInteger;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;

@DataTypeInfo(name="char", aliases = {"java.sql.Types.CHAR", "bpchar", "character"}, minParameters = 0, maxParameters = 1, priority = LiquibaseDataType.PRIORITY_DEFAULT)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue mentions CLOB, but the change is being done to char (and varchar by extension). Should it also be applied to clob or the description could be changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Liquibase treats it like a varchar insert, not a clob, because the Java data type is a string. This line is where Liquibase infers the type to be a CharType, despite the insert going into a clob column: https://github.com/liquibase/liquibase/blob/master/liquibase-standard/src/main/java/liquibase/sqlgenerator/core/InsertGenerator.java#L73

@StevenMassaro StevenMassaro dismissed filipelautert’s stale review February 12, 2024 18:03

Filipe is on PTO and approved this PR via slack message to me

@StevenMassaro StevenMassaro merged commit 76b9373 into master Feb 12, 2024
35 checks passed
@StevenMassaro StevenMassaro deleted the DAT-16774 branch February 12, 2024 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants