Compare commits

...

1 Commits

Author SHA1 Message Date
Tom Moor b77f5b9fb2 fix: withoutState scope should include state as fallback 2025-05-07 08:52:59 -04:00
+10 -1
View File
@@ -15,6 +15,7 @@ import {
FindOptions,
WhereOptions,
EmptyResultError,
Sequelize,
} from "sequelize";
import {
ForeignKey,
@@ -104,10 +105,18 @@ type AdditionalFindOptions = {
exclude: ["state"],
},
}))
// @ts-expect-error Type 'Literal' is not assignable to type 'string | ProjectionAlias'.
@Scopes(() => ({
withoutState: {
attributes: {
exclude: ["state"],
include: [
Sequelize.literal(
// If content (JSON) is null then we still need to return the state column (BINARY)
// as it's used as a fallback for content deserialization for older documents.
// This can be removed if content is 100% backfilled.
`CASE WHEN document.content IS NULL THEN document.state ELSE NULL END AS state`
),
],
},
},
withCollection: {