You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(types): insert on an untyped schema rejects every primitive field value #52
Schema.get("myapp") and new Schema("myapp", {...}) without a type argument leave T = any, so instance().table("users") is a Table<any>. Table.insert takes DeepPartial<T> | DeepPartial<T>[] (src/staged-query/selection.ts:156), and DeepPartial<any> (src/staged-query/common.ts:13) is a mapped type with no passthrough for primitives. A string, number or boolean field value is therefore not assignable to it, and the documented untyped usage does not compile.
Reproduction (a file in docs/ checked with docs/tsconfig.json, identical on campaign/integration at d4946b0):
error TS2322: Type 'string' is not assignable to type 'DeepPartial<any> | DeepPartial<unknown>[] | readonly DeepPartial<unknown>[] | undefined'.
The same call with a typed schema compiles: Schema.get<{ users: { _id: string; name: string } }>("myapp")!.
Expected: either an untyped schema accepts any document (DeepPartial<any> resolves to any), or the docs only show typed schemas. docs/2.operations/5.indexes.md, docs/3.results/1.index.md and docs/3.results/2.write_results.md showed the untyped form; the docs now type the schema, so this issue changes no docs.
Suggested fix: make DeepPartial<T> return T for primitives and any (for example 0 extends 1 & T ? any : ...), then add a type test for insert and update on a Table<any>.
Fixed by #59 (typed write documents), on main in 1cf8db2 (#71). DeepPartial<any> now resolves through DeepPartialValue in src/staged-query/common.ts. Checked: tsc on main accepts Schema.get("myapp")!.instance().table("users").insert({ name: "John Doe" }) on an untyped schema.
Activity
Upd4ting commentedon Nov 4, 2026
Fixed by #59 (typed write documents), on main in 1cf8db2 (#71).
DeepPartial<any>now resolves throughDeepPartialValuein src/staged-query/common.ts. Checked: tsc on main acceptsSchema.get("myapp")!.instance().table("users").insert({ name: "John Doe" })on an untyped schema.