# Can't update UDT using gocqlx

**URL:** https://forum.scylladb.com/t/cant-update-udt-using-gocqlx/1336
**Category:** ScyllaDB
**Tags:** go-driver
**Created:** [February 25, 2024, 10:02pm UTC](https://forum.scylladb.com/t/cant-update-udt-using-gocqlx/1336 "2024-02-25T22:02:34Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Hammad\_Ul\_Haq](https://avatars.discourse-cdn.com/v4/letter/h/ed8c4c/32.png) [@Hammad\_Ul\_Haq](https://forum.scylladb.com/u/Hammad_Ul_Haq)
#### Post date: [February 25, 2024, 10:02pm UTC](https://forum.scylladb.com/t/cant-update-udt-using-gocqlx/1336/1 "2024-02-25T22:02:34Z")

</div>

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:

```auto
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** :

```auto
 {'table_table1_20e24b85_d425_11e_int13_idx': {local: null, name: null, table_name: null, columns: null}}

```

Here’s my gocqlx code:

```auto
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?**

---

<div class="post-metadata">

### Author: ![sylwiaszunejko](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.scylladb.com/sylwiaszunejko/32/714_2.png) [@sylwiaszunejko](https://forum.scylladb.com/u/sylwiaszunejko)
#### Post date: [March 19, 2024, 7:03am UTC](https://forum.scylladb.com/t/cant-update-udt-using-gocqlx/1336/2 "2024-03-19T07:03:50Z")

</div>

Hi,  
this question was answered in this github issue: [Can’t update UDT using gocqlx · Issue #264 · scylladb/gocqlx · GitHub](https://github.com/scylladb/gocqlx/issues/264).  
In short you have to add `cql:` struct tags to map specify the CQL field name to be mapped to a struct field.  
Information about it can be found in gocql documentation: [gocql/doc.go at 34fdeebefcbf183ed7f916f931aa0586fdaa1b40 · gocql/gocql · GitHub](https://github.com/gocql/gocql/blob/34fdeebefcbf183ed7f916f931aa0586fdaa1b40/doc.go#L336).
