triplit icon indicating copy to clipboard operation
triplit copied to clipboard

Can't update set from null to empty

Open jakobrosenberg opened this issue 5 months ago • 1 comments

If a set is undefined, it's not possible to assign an empty set.

Doesn't work. my_set is still null after the update.

triplit.http.update('my_table', row => {
  // row.my_set is null
  row.my_set= new Set()
}

Works. my_set is an empty set after the update.

triplit.http.update('my_table', row => {
  // row.my_set is null
  row.my_field = new Set()
  section.my_set.add('__TRIGGER__')
  section.my_set.delete('__TRIGGER__')
})

jakobrosenberg avatar Jul 10 '25 07:07 jakobrosenberg

can you share the client version you are using, and if you are using local development or a cloud server?

I tried to recreate the issue, but I was seeing expected results

// client = HttpClient
await client.insert('test', {
    id: 'test1',
    name: 'a',
  });

  await client.update('test', 'test1', (entity) => {
    entity.name = 'b';
    entity.items = new Set(['item']);
  });

  const result = await client.fetchById('test', 'test1');
  expect(result).toEqual({
    id: 'test1',
    name: 'b',
    items: new Set(['item']),
  });

wernst avatar Jul 11 '25 16:07 wernst