You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when I try to update a table contains a binary column, the result is comparing uncomparable type []uint8
this issue is similar as issues/361, but when I read code, I found that update will check unique key, it will compare the new value and the old value, and that cause the error
// Update the given row from the table.
func (t *tableEditor) Update(ctx *sql.Context, oldRow sql.Row, newRow sql.Row) error {
...
// Throw a unique key error if any unique indexes are defined
for _, cols := range t.uniqueIdxCols {
if hasNullForAnyCols(newRow, cols) {
continue
}
existing, found, err := t.ea.GetByCols(newRow, cols) // this
if err != nil {
return err
}
if found {
return sql.NewUniqueKeyErr(formatRow(newRow, cols), false, existing)
}
}
in GetByCols
func columnsMatch(colIndexes []int, row sql.Row, row2 sql.Row) bool {
for _, i := range colIndexes {
if row[i] != row2[i] {
return false
}
}
return true
}
Please help to confirm the problem~
The text was updated successfully, but these errors were encountered:
Hey @yuhangm000, thanks for reporting an issue. I tried to repro this with SQL commands directly against go-mysql-server, but I wasn't able to repro it that way. If you can share some simple repro code, we'll be happy to dig in and see what we can help figure out.
CREATE TABLE `zt_test`(
`id` BIGINT unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
`instance_id` VARBINARY(20) NOT NULL,
UNIQUE KEY `uniq_instance` (`instance_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='test';
type TestStruct struct {
ID uint64 `gorm:"column:id"`
InstanceID string `gorm:"column:instance_id"`
}
and execute create before update
Hey @yuhangm000, thanks for reporting an issue. I tried to repro this with SQL commands directly against go-mysql-server, but I wasn't able to repro it that way. If you can share some simple repro code, we'll be happy to dig in and see what we can help figure out.
when I try to update a table contains a binary column, the result is
comparing uncomparable type []uint8
this issue is similar as issues/361, but when I read code, I found that update will check unique key, it will compare the new value and the old value, and that cause the error
in GetByCols
Please help to confirm the problem~
The text was updated successfully, but these errors were encountered: