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
4464 fix generated default column value using in PostgreSQL and Oracle for char/clob data types #5202
4464 fix generated default column value using in PostgreSQL and Oracle for char/clob data types #5202
Conversation
…ttps://github.com/LonwoLonwo/liquibase into LonwoLonwo-4464-fix-generated-default-column-value-using-in-PG
liquibase-standard/src/main/java/liquibase/snapshot/jvm/ColumnSnapshotGenerator.java
Outdated
Show resolved
Hide resolved
liquibase-integration-tests/src/test/java/liquibase/dbtest/pgsql/PostgreSQLIntegrationTest.java
Show resolved
Hide resolved
…mn-value-using-in-PG
…ttps://github.com/LonwoLonwo/liquibase into LonwoLonwo-4464-fix-generated-default-column-value-using-in-PG
liquibase-standard/src/main/java/liquibase/snapshot/jvm/ColumnSnapshotGenerator.java
Outdated
Show resolved
Hide resolved
liquibase-integration-tests/src/test/java/liquibase/dbtest/pgsql/PostgreSQLIntegrationTest.java
Show resolved
Hide resolved
…ttps://github.com/LonwoLonwo/liquibase into LonwoLonwo-4464-fix-generated-default-column-value-using-in-PG
@@ -225,7 +225,7 @@ public void testChangeLogGenerationForTableWithGeneratedColumn() throws Exceptio | |||
String textToTest = "GENERATED ALWAYS AS (QTY * PRICE)"; | |||
|
|||
Scope.getCurrentScope().getSingleton(ExecutorService.class).getExecutor("jdbc", getDatabase()).execute(new RawSqlStatement( | |||
String.format("CREATE TABLE GENERATED_COLUMN_TEST(QTY INT, PRICE INT, TOTALVALUE INT %s);", textToTest))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost there :)
The assertion failed as it is not able to find our sql fragment. The generated SQL below is:
<column defaultValueComputed="GENERATED ALWAYS AS ("QTY"*"PRICE")" name="TOTALVALUE" type="NUMBER(*, 0)"/>
So in my next commit I'm removing "
from virtColumnDef
variable... and seems it works. I wonder if this is the best solution @LonwoLonwo @MalloD12 , but at least it is working now :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved.
Thanks @LonwoLonwo for this PR, for applying the required changes, and for your patience. Code changes look good to me. Build and all tests have been successfully executed.
It would be good if we can test running the Oracle test added in some different version than the one use for OracleIntegrationTest
suite (oracle-xe:18-slim
). @rberezen could you please do that when you review this PR? This test I'm talking about was failing on the mentioned version, but using the generated SQL and executing it in a newer version was successfully executed, so I would like to make sure that now it pass on version 18 it also works in newer versions.
Impact
TypeBug
- bug fixesDescription
So, I'm trying to fix the case from #4464
The first part of this PR - is avoiding duplication of the
GENERATED ALWAYS AS
part.And second - an attempt to not add quotes around the function
GENERATED ALWAYS AS
for character/clob columns.I understand that this is a terrible solution - trying to guess by the string beginning - if this default value is a function or not.
But I do not see other good options.
I tried to add to the ClobType#objectToSql, but it is not general enough.
So, I am open for discussion.
Things to be aware of
I'm not sure about the test part, also.
Things to worry about
Can users use the "GENERATED ALWAYS AS" syntax just for default values? I really do not know.