| 1 | // vtest build: present_sqlite3? && !sanitize-memory-clang |
| 2 | import db.sqlite |
| 3 | |
| 4 | struct ComplexWhere { |
| 5 | pub mut: |
| 6 | id int |
| 7 | name string |
| 8 | rank f32 |
| 9 | } |
| 10 | |
| 11 | fn test_create_without_id_field() { |
| 12 | db := sqlite.connect(':memory:')! |
| 13 | |
| 14 | sql db { |
| 15 | create table ComplexWhere |
| 16 | }! |
| 17 | |
| 18 | datas := [ |
| 19 | ComplexWhere{ |
| 20 | id: 0 |
| 21 | name: 'test1' |
| 22 | rank: 1.5 |
| 23 | }, |
| 24 | ComplexWhere{ |
| 25 | id: 1 |
| 26 | name: 'test2' |
| 27 | rank: 2.5 |
| 28 | }, |
| 29 | ComplexWhere{ |
| 30 | id: 2 |
| 31 | name: 'test3' |
| 32 | rank: 3.5 |
| 33 | }, |
| 34 | ] |
| 35 | |
| 36 | for data in datas { |
| 37 | sql db { |
| 38 | insert data into ComplexWhere |
| 39 | }! |
| 40 | } |
| 41 | |
| 42 | res := sql db { |
| 43 | select from ComplexWhere where name == 'a' && (id > 1 || (rank > 2.5 && rank < 3.33)) |
| 44 | } or { assert false, err.msg() } |
| 45 | } |
| 46 | |