# queryfn tests

FEATURE: queryfn-ith
background:
  type Flight struct {id int unique, wid int optional }  end
thenType: struct

---
title: ith 0
given:
  insert Flight {id: 55, wid: 4 }
  insert Flight {id: 56, wid: 3 }
when:
  let x = Flight[true].ith(0)
then:
value:a:Flight {
 vid:55
 vwid:4
}

---
title: ith 1
given:
  insert Flight {id: 55, wid: 4 }
  insert Flight {id: 56, wid: 3 }
when:
  let x = Flight[true].ith(1)
then:
value:a:Flight {
 vid:56
 vwid:3
}
---
title: ith empty
given:
  insert Flight {id: 55, wid: 4 }
  insert Flight {id: 56, wid: 3 }
when:
  let x = Flight[id=100].ith()
then:
null

---
title: ith bad index
given:
  insert Flight {id: 55, wid: 4 }
  insert Flight {id: 56, wid: 3 }
when:
  let x = Flight[true].ith(2)
then:
ERROR: queryfn-ith-bad-index
