v2 / vlib / v / tests / orm_or_test.v
24 lines · 20 sloc · 356 bytes · 0056d557b686cf37054832714858edb7197c8347
Raw
1import db.sqlite
2import math
3
4struct Counter {
5 id int @[primary; sql: serial]
6 f f64
7}
8
9fn test_orm_or_block() {
10 db := sqlite.connect(':memory:') or { panic(err) }
11
12 sql db {
13 drop table Counter
14 } or { println(math.e) } // this should compile
15
16 x := sql db {
17 select from Counter
18 } or {
19 [Counter{
20 f: math.pi
21 }]
22 }
23 assert x[0].f == math.pi
24}
25