Update a value in field from another value in query

I want to copy value from existing field to new field in migration file but field type is different.
names type is{:array, :string}
name type is string

query = from t in "tags", update: [set: [name: ^get_name(t.names)]]
Repo.update_all(query)

def get_name(names), do: Enum.at(names, 0)

As I expected, it won’t work

variable "t" does not exist and is being expanded to "t()"

How can I do this correctly?

I could do this using fragment

query = from t in "tags", update: [set: [name: fragment("?[1]", t.names)]]
Repo.update_all(query)

Hi,

sorry, you can’t achieve this with some “external” [to the query] Elixir code, the only way is a fragment like above - at least, in a single query (else it will require a select first)