| 1 | // vtest build: present_sqlite3? |
| 2 | import db.sqlite |
| 3 | |
| 4 | struct VieterDb { |
| 5 | conn sqlite.DB |
| 6 | } |
| 7 | |
| 8 | pub struct GitRepoArch { |
| 9 | pub: |
| 10 | id int @[primary; sql: serial] |
| 11 | repo_id int @[nonull] |
| 12 | // repo string |
| 13 | value string @[nonull] |
| 14 | } |
| 15 | |
| 16 | pub struct GitRepo { |
| 17 | pub mut: |
| 18 | id int @[optional; primary; sql: serial] |
| 19 | repo string @[nonull] |
| 20 | arch []GitRepoArch @[fkey: 'repo_id'] |
| 21 | } |
| 22 | |
| 23 | pub fn (db &VieterDb) get_git_repos() ![]GitRepo { |
| 24 | // NB: the query here, uses the `repo` field on GitRepo, |
| 25 | // while GitRepo is joined to GitRepoArch, |
| 26 | // which does *not* have a `repo` field. |
| 27 | // When this test was added, the checker used `GitRepoArch` |
| 28 | // to check for `repo`'s presence (which is wrong), because of |
| 29 | // a lingering c.cur_orm_ts state. The fix was to save/restore c.cur_orm_ts . |
| 30 | res := sql db.conn { |
| 31 | select from GitRepo where repo == 'something' order by id |
| 32 | }! |
| 33 | return res |
| 34 | } |
| 35 | |
| 36 | fn test_compiles() { |
| 37 | assert true |
| 38 | } |
| 39 | |