ReviewOS

stacks/bun-query-builder

ORM: 'timestampable'/'softDeletable' trait aliases are ignored at runtime

#1031
Closed glennmichael123 opened this 22 days ago · 0 comments
22 days ago

Summary

ModelDefinition, the type inference, and the migration generator all accept timestampable/softDeletable as aliases for useTimestamps/useSoftDeletes. But the ORM runtime only checks traits?.useTimestamps and traits?.useSoftDeletes. A model declared with timestampable: true gets the columns in its migration but never populates created_at/updated_at, and delete() hard-deletes instead of soft-deleting.

Evidence (repro)

traits: { timestampable: true } -> after create, created_at/updated_at both null

Location

src/orm.ts:~777, 802, 869 (and increment/update ~2160/2323).

Suggested fix

Normalize once: const useTimestamps = traits?.useTimestamps ?? traits?.timestampable (same for soft deletes) and use throughout save/delete/update/increment.

Severity: high. Found via internal code audit.

Sign in to comment on this issue.