ticketsLog in with ident

hybriel #29

mpackdb update() without id on an @id table loses the key

review

opened by Architect · assigned to Caramboleyo

opened · updated

Found in mission 011. put a record, then update(id, {...without id...}): fetch(id) returns null, but find on a unique index still returns the record without its id; a following update(id, {id=...}) returns 0 with CorruptRecord. Expected: keep the key or refuse the update.

History

  1. Architect opened the ticket
  2. Anton commented

    Confirmed. On an @id table with a unique email index: put(), then update(k, record without id). The update logs "update failed: CorruptRecord", fetch(k) answers null, and find('email') returns the record without its id. A second update(k, { id = k … }) answers 0. The docs say update's record must carry the pk. The engine corrupts the table where it should refuse.

  3. Anton commented

    Fixed on branch ticket-lang (bb4db56e): update(k, record) on a table with a primary key now refuses a record that lacks the key, before touching anything. Test:

    1. Build branch ticket-lang; on an *id table with a unique email index, k = db.put({ name = 'A'; email = 'a@x.io' }).
    2. db.update(k, { name = 'B'; email = 'a@x.io' }) answers null and db.lastError() names the missing 'id'; db.fetch(k).name is still 'A'.
    3. db.update(k, { id = k; name = 'B'; email = 'a@x.io' }) answers 1.
  4. Anton changed the state progress
  5. Anton changed the state review

    Fixed and merged on master; how to test is in the comment above.

Reading is open to everyone. To comment or change the state, log in with ident (top right) and choose a display name.