Commit 23a1b7d
authored
Fix CDC read error (#96)
CDCEvent reads the _id field into a string. By default, the Mongo client v2 will not convert the ObjectID to a string, so we get an error at read time. To fix this, we now set BSONOptions on the collection to allow this deserialization. This wasn't caught in the previous tests because the test code explicitly set the _id field to a string when creating test events, so the test events deserialized without error. I've also updated the TestWriteSuccess test to use a Mongo generated _id which reproduces the error.
Alternatively I considered changing CDCEvent.ID to a bson.ObjectID type, but since this struct is used in the REST client library I do not want to leak that Mongo type and dependency into the client. I also considered creating an internal cdcEvent struct identical to CDCEvent but with the bson.ObjectID type, then have the server deserialize into that struct and copy to the CDCEvent struct, but that seemed heavy and unnecessary.1 parent 4d8eb11 commit 23a1b7d
3 files changed
+25
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
116 | 119 | | |
117 | | - | |
118 | 120 | | |
119 | 121 | | |
120 | 122 | | |
| |||
140 | 142 | | |
141 | 143 | | |
142 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
143 | 158 | | |
144 | 159 | | |
145 | 160 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
67 | | - | |
| 68 | + | |
| 69 | + | |
68 | 70 | | |
69 | 71 | | |
70 | 72 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
28 | 33 | | |
29 | 34 | | |
30 | 35 | | |
0 commit comments