Commit d5ac5c6
fix: scope entity queries by project_id in upsert_entity method
Replace direct select(Entity) calls with self.select() to ensure proper
project filtering in the upsert_entity method. This prevents "multiple rows"
errors when similar permalinks exist across different projects.
Fixes issue where:
- File sync fails with "Multiple rows were found when one or none was required"
- Similar permalinks across projects (e.g., "foo" and "foo-complete") cause conflicts
- Queries were not properly scoped by project_id constraint
Changed in EntityRepository.upsert_entity():
- Query after entity update (lines 144-148)
- Query after entity insert (lines 164-168)
- Query after race condition update (lines 205-210)
- Query after permalink conflict resolution (lines 245-249)
Co-authored-by: Drew Cain <groksrc@users.noreply.github.com>1 parent a52ce1c commit d5ac5c6
1 file changed
Lines changed: 4 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
145 | | - | |
| 145 | + | |
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
165 | | - | |
| 165 | + | |
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
| |||
203 | 203 | | |
204 | 204 | | |
205 | 205 | | |
206 | | - | |
| 206 | + | |
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
| |||
243 | 243 | | |
244 | 244 | | |
245 | 245 | | |
246 | | - | |
| 246 | + | |
247 | 247 | | |
248 | 248 | | |
249 | 249 | | |
| |||
0 commit comments