Skip to content
Merged
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
18 changes: 18 additions & 0 deletions enginetest/queries/update_queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,24 @@ t1.oid = t2.pid;`,
},
},
},
{
// https://github.com/dolthub/dolt/issues/10385
Name: "UPDATE JOIN - tables with capitalized names",
Dialect: "mysql",
SetUpScript: []string{
"create table Items(ItemID char(38) NOT NULL primary key, Version int)",
"insert into Items values ('1234', 1)",
"create table Items2(ItemID char(38) NOT NULL primary key, Version int)",
"insert into Items2 values ('1234', 2)",
"UPDATE Items INNER JOIN Items2 ON (Items.ItemID = Items2.ItemID) SET Items.Version = Items2.Version WHERE Items.Version != Items2.Version",
},
Assertions: []ScriptTestAssertion{
{
Query: "select * from Items",
Expected: []sql.Row{{"1234", 2}},
},
},
},
}

var SpatialUpdateTests = []WriteQueryTest{
Expand Down
9 changes: 4 additions & 5 deletions sql/plan/update_join.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,23 +235,22 @@ func SplitRowIntoTableRowMap(row sql.Row, joinSchema sql.Schema) map[string]sql.
return ret
}

currentTable := joinSchema[0].Source
currentTable := strings.ToLower(joinSchema[0].Source)
currentRow := sql.Row{row[0]}

for i := 1; i < len(joinSchema); i++ {
c := joinSchema[i]

if c.Source != currentTable {
newTable := strings.ToLower(c.Source)
if newTable != currentTable {
ret[currentTable] = currentRow
currentTable = c.Source
currentTable = newTable
currentRow = sql.Row{row[i]}
} else {
currentTable = c.Source
currentRow = append(currentRow, row[i])
}
}

currentTable = strings.ToLower(currentTable)
ret[currentTable] = currentRow

return ret
Expand Down
3 changes: 2 additions & 1 deletion sql/rowexec/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ func (u *updateJoinIter) Next(ctx *sql.Context) (sql.Row, error) {
tableToNewRowMap := plan.SplitRowIntoTableRowMap(newJoinRow, u.joinSchema)

for tableName, _ := range u.updaters {
oldTableRow := tableToOldRowMap[strings.ToLower(tableName)]
tableName = strings.ToLower(tableName)
oldTableRow := tableToOldRowMap[tableName]

// Handle the case of row being ignored due to it not being valid in the join row.
if isRightOrLeftJoin(u.joinNode) {
Expand Down