Commit 6b9847f
committed
fix(drizzle): sort by join field on versioned collection with custom text id
When the list view is sorted by a `join` field on a collection that has both
`versions` enabled and a custom text id (e.g. nanoid), the query crashes with:
operator does not exist: integer = character varying
`getTableColumnFromPath` builds the join condition using the versions table's
`id` column. On a versions table, `id` is the versions row PK (always integer),
not the parent document id. The joined `_rels` / target table column references
the parent document id, which is `varchar` for custom text ids, so the types
do not match.
Use the versions table's `parent` column (mapped from the `parent_id` db
column, which is the actual reference to the parent document id) instead of
`id` whenever the source table is a versions table. Fixes both branches of
`case 'join'` (single-segment `on` with `hasMany`, and the non-`hasMany` path).
Made-with: Cursor1 parent 0ceba02 commit 6b9847f
1 file changed
Lines changed: 13 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
393 | 393 | | |
394 | 394 | | |
395 | 395 | | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
396 | 400 | | |
397 | 401 | | |
398 | 402 | | |
399 | | - | |
| 403 | + | |
400 | 404 | | |
401 | 405 | | |
402 | 406 | | |
| |||
490 | 494 | | |
491 | 495 | | |
492 | 496 | | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
493 | 503 | | |
494 | | - | |
495 | 504 | | |
496 | 505 | | |
497 | 506 | | |
498 | 507 | | |
499 | 508 | | |
500 | 509 | | |
501 | | - | |
502 | | - | |
503 | | - | |
504 | | - | |
| 510 | + | |
505 | 511 | | |
506 | 512 | | |
507 | 513 | | |
| |||
516 | 522 | | |
517 | 523 | | |
518 | 524 | | |
519 | | - | |
520 | | - | |
521 | | - | |
522 | | - | |
| 525 | + | |
523 | 526 | | |
524 | 527 | | |
525 | 528 | | |
| |||
0 commit comments