Commit 24ecfd5
committed
fix(admin): materialise segment CASE via subquery in getMultiYearGapTrend
The previous workforce/NAF query inlined the CASE expression directly
in SELECT, GROUP BY and ORDER BY. Drizzle re-binds fresh
parameter placeholders (`$1..$6`, `$10..$15`, `$16..$21`) at each
call site, so Postgres sees three textually different expressions and
rejects the query with 'column must appear in the GROUP BY clause'.
Push the CASE into an inner subquery aliased `gap_trend_src.segment`,
then aggregate on the alias in the outer query. Parameters are bound
exactly once, the outer GROUP BY / ORDER BY only references column
names, and the Postgres planner is happy.
No observable behaviour change for consumers. Fixes the 500 the user
was hitting in local dev when selecting 'Segmenter par NAF'.1 parent 0ea140e commit 24ecfd5
2 files changed
Lines changed: 31 additions & 11 deletions
Lines changed: 9 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
306 | 306 | | |
307 | 307 | | |
308 | 308 | | |
309 | | - | |
310 | | - | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
311 | 317 | | |
312 | 318 | | |
313 | 319 | | |
| |||
317 | 323 | | |
318 | 324 | | |
319 | 325 | | |
| 326 | + | |
320 | 327 | | |
321 | 328 | | |
322 | 329 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
237 | 237 | | |
238 | 238 | | |
239 | 239 | | |
240 | | - | |
241 | | - | |
242 | | - | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
243 | 247 | | |
244 | | - | |
| 248 | + | |
245 | 249 | | |
246 | 250 | | |
247 | | - | |
248 | | - | |
249 | | - | |
| 251 | + | |
| 252 | + | |
250 | 253 | | |
251 | 254 | | |
252 | 255 | | |
253 | 256 | | |
254 | | - | |
255 | | - | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
256 | 269 | | |
257 | 270 | | |
258 | 271 | | |
| |||
0 commit comments