Commit e9ffedf
committed
fix(api): correctly serialize nested objects for db insertion
When creating new headlines or sources, the API was failing with a
database error because it tried to insert nested `source`, `category`,
and `headquarters` objects directly into the database. The database
schema expects flattened foreign key columns (`source_id`, `category_id`,
`headquarters_country_id`).
This fix updates the `toJson` functions provided during the setup of
the `headlineRepository` and `sourceRepository` in `AppDependencies`.
These custom functions now correctly flatten the nested objects into
their respective ID fields before the data is sent to the database
client, resolving the "column does not exist" error.1 parent 4322a0e commit e9ffedf
1 file changed
+24
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
118 | | - | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
119 | 133 | | |
120 | 134 | | |
121 | 135 | | |
| |||
147 | 161 | | |
148 | 162 | | |
149 | 163 | | |
150 | | - | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
151 | 173 | | |
152 | 174 | | |
153 | 175 | | |
| |||
0 commit comments