Commit bff8718
committed
Driver tests for full
So it turns out that while bearing some relation to `lib/pq` through
various pieces that sqlc pulls in, the `riverdatabasesql` driver didn't
actually work when used with `lib/pq`. When testing it, we'd open a
`sql.DB` pool _via_ Pgx, so Pgx was doing all the heavy lifting.
Here, add an alternate driver test strategy to test `riverdatabasesql`
with a `lib/pq` pool, thereby ensuring that the full range of operations
works even with no Pgx in the mix at all.
Things were broken, so we get those fixed up. There we two main
problems:
* As described in #545, `lib/pq` doesn't handle intervals correctly, and
reads them in as ints, which is a big problem because they're in
nanoseconds. We work around this by injecting intervals (like leader
TTLs) an second floats instead, which really doesn't feel that much
worse.
* The custom bits class for `unique_states` didn't work. To fix this I
move to an alternate strategy of inserts `unique_states` as an
integer, a technique that I've been using in SQLite because there's no
`bits` type. I could make a strong argument that the use of an integer
over `bits` would've been a better design from the get go anyway,
because it makes all the bit-wise arithmetic much simpler as you use
C-style conventions like `states & (1 << 3)` that are very widespread
and well understood. Either way though, things work reasonably well if
we insert as an integer, then transition to storage in bits.
Fixes #545 and #566. Supersedes #882.lib/pq connection + necessary fixes1 parent 5114d52 commit bff8718
16 files changed
Lines changed: 166 additions & 106 deletions
File tree
- internal/riverinternaltest/riverdrivertest
- riverdbtest
- riverdriver
- riverdatabasesql
- internal
- dbsqlc
- pgtypealias
- riverpgxv5
- internal/dbsqlc
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
14 | 18 | | |
15 | 19 | | |
16 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
25 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
26 | 58 | | |
27 | 59 | | |
28 | 60 | | |
| |||
Lines changed: 20 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
2708 | 2709 | | |
2709 | 2710 | | |
2710 | 2711 | | |
2711 | | - | |
| 2712 | + | |
| 2713 | + | |
2712 | 2714 | | |
2713 | 2715 | | |
2714 | 2716 | | |
| |||
3387 | 3389 | | |
3388 | 3390 | | |
3389 | 3391 | | |
3390 | | - | |
3391 | | - | |
3392 | | - | |
3393 | 3392 | | |
3394 | 3393 | | |
3395 | | - | |
3396 | | - | |
3397 | | - | |
| 3394 | + | |
| 3395 | + | |
| 3396 | + | |
| 3397 | + | |
| 3398 | + | |
| 3399 | + | |
| 3400 | + | |
| 3401 | + | |
| 3402 | + | |
3398 | 3403 | | |
| 3404 | + | |
| 3405 | + | |
3399 | 3406 | | |
3400 | 3407 | | |
3401 | 3408 | | |
3402 | 3409 | | |
3403 | 3410 | | |
3404 | 3411 | | |
3405 | | - | |
3406 | | - | |
3407 | | - | |
| 3412 | + | |
| 3413 | + | |
| 3414 | + | |
| 3415 | + | |
| 3416 | + | |
| 3417 | + | |
3408 | 3418 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
399 | 399 | | |
400 | 400 | | |
401 | 401 | | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
402 | 407 | | |
403 | 408 | | |
404 | 409 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
52 | 61 | | |
53 | 62 | | |
54 | 63 | | |
| |||
60 | 69 | | |
61 | 70 | | |
62 | 71 | | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
Lines changed: 0 additions & 9 deletions
This file was deleted.
0 commit comments