Skip to content

Commit

Permalink
Fixes halt on new column addition being too strict (#3161)
Browse files Browse the repository at this point in the history
  • Loading branch information
alishakawaguchi authored Jan 18, 2025
1 parent 8b6ea3e commit 4d1e222
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,7 @@ func TestShouldHaltOnSchemaAddition(t *testing.T) {
{Schema: "public", Table: "users", Column: "created_by"},
},
)
require.True(t, ok, "job mappings are missing database schema mappings")
require.ElementsMatch(t, []string{"neosync_api.accounts.id", "neosync_api.accounts.name"}, newCols)
require.False(t, ok, "valid subset of job mappings")

newCols, ok = shouldHaltOnSchemaAddition(
map[string]map[string]*sqlmanager_shared.DatabaseSchemaRow{
Expand Down
6 changes: 5 additions & 1 deletion internal/benthos/benthos-builder/builders/sql-util.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ func shouldHaltOnSchemaAddition(
tableColMappings := getUniqueColMappingsMap(mappings)
newColumns := []string{}
for table, cols := range groupedSchemas {
mappingCols := tableColMappings[table]
mappingCols, exists := tableColMappings[table]
if !exists {
// table not mapped in job mappings, skip
continue
}
for col := range cols {
if _, exists := mappingCols[col]; !exists {
newColumns = append(newColumns, fmt.Sprintf("%s.%s", table, col))
Expand Down

0 comments on commit 4d1e222

Please sign in to comment.