fix: Add 'DEFAULT' to column definition when creating columns with a defaultValue - #438
fix: Add 'DEFAULT' to column definition when creating columns with a defaultValue#438pvlov wants to merge 1 commit into
defaultValue#438Conversation
📝 WalkthroughWalkthroughBigQueryCreateTableGenerator now appends a DEFAULT clause when emitting SQL for columns with non-auto-increment types and default values. A corresponding test method verifies this behavior with a STRING column containing a default value. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/test/java/liquibase/ext/bigquery/sqlgenerator/BigQueryCreateTableGeneratorTest.java (1)
3-4: Consider removing unused imports.The imports
DatabaseDataType,LiquibaseSerializable, andDataTypedon't appear to be used in the test class. Consider removing them to keep the imports clean.Apply this diff to remove unused imports:
-import liquibase.datatype.DatabaseDataType; import liquibase.ext.bigquery.database.BigQueryDatabase; -import liquibase.serializer.LiquibaseSerializable; import liquibase.sql.Sql; import liquibase.statement.core.CreateTableStatement; -import liquibase.structure.core.DataType;Also applies to: 6-6, 9-9
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Jira integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
src/main/java/liquibase/ext/bigquery/sqlgenerator/BigQueryCreateTableGenerator.java(1 hunks)src/test/java/liquibase/ext/bigquery/sqlgenerator/BigQueryCreateTableGeneratorTest.java(2 hunks)
🔇 Additional comments (2)
src/main/java/liquibase/ext/bigquery/sqlgenerator/BigQueryCreateTableGenerator.java (1)
61-70: LGTM! The DEFAULT keyword is correctly added.The change properly adds the
DEFAULTkeyword with appropriate spacing before the default value. The logic correctly handles bothDatabaseFunctionand literal defaults, and the condition guards ensure thatDEFAULTis only emitted for non-auto-increment columns that have a default value.src/test/java/liquibase/ext/bigquery/sqlgenerator/BigQueryCreateTableGeneratorTest.java (1)
36-43: LGTM! Test validates the DEFAULT clause fix.The test correctly verifies that the generated SQL includes the
DEFAULTkeyword for a column with a default value. The assertion confirms the expected format:CREATE TABLE schema.table (name STRING DEFAULT 'default_name').
…REATE TABLE' statement to avoid invalid SQL being generated
|



When creating tables with columns which use
defaultValue, thesqlgeneratordoes not add theDEFAULTkeyword and some whitespace leading to syntactically wrong SQL being generated and then executed. See [1] for more details on default values in big query.So, for a changelog like this:
The generator will end up generating something like this:
[1] https://docs.cloud.google.com/bigquery/docs/default-values