# CRUD update tests

FEATURE: CRUD update
background:
  type Flight struct {id int unique, wid int optional }  end
  type Flight2 struct {id int unique, wid int }  end
thenType: struct

---
title: update returns number of updated rows
thenType: int
expectDVal:false
when:
  insert Flight {id: 55, wid: 20 }
  update Flight[55] {wid: 22}
then:
1

---
title: update returns number of updated rows-2
thenType: int
expectDVal:false
when:
  insert Flight {id: 55, wid: 20 }
  insert Flight {id: 56, wid: 20 }
  update Flight {wid: 22}
then:
2

---
title: update
when:
  insert Flight {id: 55, wid: 20 }
  update Flight {wid: 22}
  let x = Flight[55]
then:
value:a:Flight {
 vid:55
 vwid:22
}

---
title: update-optional
when:
  insert Flight {id: 55, wid: 20 }
  update Flight {}
  let x = Flight[55]
then:
value:a:Flight {
 vid:55
 vwid:20
}

---
title: update-mandatory-missing
when:
  insert Flight2 {id: 55, wid: 20 }
  update Flight2 {}
  let x = Flight2[55]
then:
value:a:Flight2 {
 vid:55
 vwid:20
}

---
title: update-unknown-class
when:
  insert Flight {id: 55, wid: 20 }
  update NoSuchName { wid: 22}
then:
ERROR: type.not.found

---
title: update-using-var
when:
  let y int = 22
  insert Flight {id: 55, wid: 20 }
  update Flight {wid: y}
  let x = Flight[55]
then:
value:a:Flight {
 vid:55
 vwid:22
}

---
SKIP: update-no-field-names -TODO: implement this
when:
  insert Flight {id: 55, wid: 20 }
  update Flight {22}
  let x = Flight[55]
then:
value:a:Flight {
 vid:55
 vwid:22
}

