Skip to content

Commit 4608dcb

Browse files
committed
Temporarily moving one check on column lists to DMLUpdateQueryBuilder.BuildQuery()
1 parent 412346e commit 4608dcb

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

go/sql/builder.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -641,9 +641,6 @@ func NewDMLUpdateQueryBuilder(databaseName, tableName string, tableColumns, shar
641641
if !sharedColumns.IsSubsetOf(tableColumns) {
642642
return nil, fmt.Errorf("shared columns is not a subset of table columns in NewDMLUpdateQueryBuilder")
643643
}
644-
if !uniqueKeyColumns.IsSubsetOf(sharedColumns) {
645-
return nil, fmt.Errorf("unique key columns is not a subset of shared columns in NewDMLUpdateQueryBuilder")
646-
}
647644
if sharedColumns.Len() == 0 {
648645
return nil, fmt.Errorf("no shared columns found in NewDMLUpdateQueryBuilder")
649646
}
@@ -682,6 +679,11 @@ func NewDMLUpdateQueryBuilder(databaseName, tableName string, tableColumns, shar
682679
}
683680

684681
func (b *DMLUpdateQueryBuilder) BuildQuery(valueArgs, whereArgs []interface{}) (string, []interface{}, []interface{}, error) {
682+
// TODO: move this check back to `NewDMLUpdateQueryBuilder()`, needs fix on generated columns.
683+
if !b.uniqueKeyColumns.IsSubsetOf(b.sharedColumns) {
684+
return "", nil, nil, fmt.Errorf("unique key columns is not a subset of shared columns in DMLUpdateQueryBuilder")
685+
}
686+
685687
sharedArgs := make([]interface{}, 0, b.sharedColumns.Len())
686688
for _, column := range b.sharedColumns.Columns() {
687689
tableOrdinal := b.tableColumns.Ordinals[column.Name]

0 commit comments

Comments
 (0)