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

Default Value Issues and Suggestions #888

Open
wants to merge 4 commits into
base: feature/default-value
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions internal/reports/report_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,17 @@
}

if p.severity == warning {
for _, colName := range colNames {
colId, _ := internal.GetColIdFromSpName(conv.SpSchema[tableId].ColDefs, colName)
if srcSchema.ColDefs[colId].DefaultValue.IsPresent && !spSchema.ColDefs[colId].DefaultValue.IsPresent {

Check failure on line 117 in internal/reports/report_helpers.go

View workflow job for this annotation

GitHub Actions / integration-tests

srcSchema.ColDefs[colId].DefaultValue undefined (type schema.Column has no field or method DefaultValue)

Check failure on line 117 in internal/reports/report_helpers.go

View workflow job for this annotation

GitHub Actions / integration-tests

spSchema.ColDefs[colId].DefaultValue undefined (type ddl.ColumnDef has no field or method DefaultValue)

Check failure on line 117 in internal/reports/report_helpers.go

View workflow job for this annotation

GitHub Actions / lint

srcSchema.ColDefs[colId].DefaultValue undefined (type schema.Column has no field or method DefaultValue)

Check failure on line 117 in internal/reports/report_helpers.go

View workflow job for this annotation

GitHub Actions / lint

spSchema.ColDefs[colId].DefaultValue undefined (type ddl.ColumnDef has no field or method DefaultValue)

Check failure on line 117 in internal/reports/report_helpers.go

View workflow job for this annotation

GitHub Actions / coverage

srcSchema.ColDefs[colId].DefaultValue undefined (type schema.Column has no field or method DefaultValue)

Check failure on line 117 in internal/reports/report_helpers.go

View workflow job for this annotation

GitHub Actions / coverage

spSchema.ColDefs[colId].DefaultValue undefined (type ddl.ColumnDef has no field or method DefaultValue)
issue := internal.DefaultValue
toAppend := Issue{
Category: IssueDB[issue].Category,
Description: fmt.Sprintf("%s for table '%s' e.g. column '%s'", IssueDB[issue].Brief, conv.SpSchema[tableId].Name, colName),
}
l = append(l, toAppend)
}
}
flag := false
for _, spFk := range conv.SpSchema[tableId].ForeignKeys {
srcFk, err := internal.GetSrcFkFromId(conv.SrcSchema[tableId].ForeignKeys, spFk.Id)
Expand Down Expand Up @@ -213,12 +224,6 @@
// on case of srcType.
spColType = strings.ToLower(spColType)
switch i {
case internal.DefaultValue:
toAppend := Issue{
Category: IssueDB[i].Category,
Description: fmt.Sprintf("%s for table '%s' e.g. column '%s'", IssueDB[i].Brief, conv.SpSchema[tableId].Name, spColName),
}
l = append(l, toAppend)
case internal.ForeignKey:
toAppend := Issue{
Category: IssueDB[i].Category,
Expand Down Expand Up @@ -514,7 +519,7 @@
Category string // Standarized issue type
CategoryDescription string
}{
internal.DefaultValue: {Brief: "Some columns have default values which Spanner migration tool does not migrate. Please add the default constraints manually after the migration is complete", Severity: note, batch: true, Category: "MISSING_DEFAULT_VALUE_CONSTRAINTS"},
internal.DefaultValue: {Brief: "Some columns have default values which Spanner migration tool does not migrate. Please add the default constraints manually after the migration is complete", Severity: warning, batch: true, Category: "MISSING_DEFAULT_VALUE_CONSTRAINTS"},
internal.ForeignKey: {Brief: "Spanner does not support foreign keys", Severity: warning, Category: "FOREIGN_KEY_USES"},
internal.MultiDimensionalArray: {Brief: "Spanner doesn't support multi-dimensional arrays", Severity: warning, Category: "MULTI_DIMENSIONAL_ARRAY_USES"},
internal.NoGoodType: {Brief: "No appropriate Spanner type. The column will be made nullable in Spanner", Severity: warning, Category: "INAPPROPRIATE_TYPE",
Expand Down
3 changes: 0 additions & 3 deletions sources/common/toddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,6 @@ func (ss *SchemaToSpannerImpl) SchemaToSpannerDDLHelper(conv *internal.Conv, tod
if isChanged && (srcCol.Name != colName) {
issues = append(issues, internal.IllegalName)
}
if srcCol.Ignored.Default {
issues = append(issues, internal.DefaultValue)
}
if srcCol.Ignored.AutoIncrement { //TODO(adibh) - check why this is not there in postgres
issues = append(issues, internal.AutoIncrement)
}
Expand Down
Loading