Hi so I have a usecase in which a user can create a secondary index on any table by calling an API. And I’m recording these indexes in a common table using map<text, frozen> where indexes is a User Defined Type:
CREATE TYPE indexes (
local BOOLEAN,
index_name TEXT,
table_name TEXT,
columns SET<TEXT>
);
When the API is called the secondary index is created. This part is working fine. But updating the row in the common tables is not. All the data in the UDT is stored as null:
{'table_table1_20e24b85_d425_11e_int13_idx': {local: null, name: null, table_name: null, columns: null}}
Here’s my gocqlx code:
selectedTable.Indexes[indexName] = models.IndexModel{
Local: reqBody.Local,
Name: indexName,
TableName: selectedTable.InternalName,
Columns: reqBody.Columns,
}
stmt, names = qb.Update("tables").Set("indexes").
Where(qb.Eq("internal_name"), qb.Eq("name"), qb.Eq("description")).ToCql()
if err := config.GetScylla().Query(stmt, names).BindStruct(&selectedTable).ExecRelease(); err != nil {
utils.HandleErrorResponse(c, err)
return
}
I hope the code is self-explanatory enough but all I’m doing is creating a map of string->indexes(UDT) to put in the common table and updating the common table with it.
Side note: why is the documentation on gocqlx so bad?