GENERATED colunm as part of PK: handling UPDATE scenario

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
This commit is contained in:
Shlomi Noach 2021-07-06 08:56:06 +03:00
parent 28f7f19e08
commit faededefcd
2 changed files with 3 additions and 1 deletions

View File

@ -188,7 +188,7 @@ func GetTableColumns(db *gosql.DB, databaseName, tableName string) (*sql.ColumnL
err := sqlutils.QueryRowsMap(db, query, func(rowMap sqlutils.RowMap) error {
columnName := rowMap.GetString("Field")
columnNames = append(columnNames, columnName)
if strings.Contains(rowMap.GetString("Extra"), " GENERATED") {
if strings.Contains(rowMap.GetString("Extra"), "GENERATED") || strings.Contains(rowMap.GetString("Extra"), "VIRTUAL") {
log.Debugf("%s is a generated column", columnName)
virtualColumnNames = append(virtualColumnNames, columnName)
}

View File

@ -27,4 +27,6 @@ begin
insert into gh_ost_test (id, jsonobj) values (null, '{"_id":19}');
insert into gh_ost_test (id, jsonobj) values (null, '{"_id":23}');
insert into gh_ost_test (id, jsonobj) values (null, '{"_id":27}');
update gh_ost_test set jsonobj=JSON_OBJECT('_id', 27, 'name', 'carrot') where id>0 and idb=27;
end ;;