Skip to content

javascript: a model made by an ORM factory carries its schema's statics - #1824

Merged
swapnilpaliwal-sd merged 2 commits into
apps/integration-0.1.9from
apps/javascript/orm-model-factory-result-untyped
Sep 30, 2026
Merged

swapnilpaliwal-sd merged 2 commits into
apps/integration-0.1.9from
apps/javascript/orm-model-factory-result-untyped

Conversation

@swapnilpaliwal-sd

Copy link
Copy Markdown
Contributor

connection.model(name, schema) builds its model class at runtime, so this.Doc.findLive() on the result had an untyped receiver and matched only by name, with same-named methods on unrelated classes as equal candidates.

  • The factory call is recognised by its schema argument: a new Schema(...) reached through an import of the ORM package (named, default, namespace, require, or a local destructure; the package need not be installed).
  • Whatever schema.statics holds (member writes, static('n', f), static({...}), the statics option) is a member of the model; schema.methods are members of new Model(...); this in a static is the model.
  • The package's own members (find, create) stay receiver_untyped, as before.
  • New case 74-orm-model-factory, with controls: a schema from a package that isn't modelled, a project registry.model(name, obj), and a same-named method on an unrelated class. None of them change.

Checked: JS engine suite 88/88 (with the compiler oracle), query cases 268/268. On the product graph, 19 sites go from ambiguous_unknown to known_edge and nothing is removed. Probes 56/70 before and after, and the two target probes are now [resolved]. Index time 42 s → 45 s.

`connection.model(name, schema)` builds the model class at runtime, so a call
such as `this.Doc.findLive()` on it had an untyped receiver and was only
matched by name, with same-named methods elsewhere as equal candidates.

The schema argument now gives the call a value: a `new Schema(...)` reached
through an import of the ORM package (named, default, namespace, require, or a
local destructure) is tracked, and whatever its `statics` holds (member
writes, `static('n', f)`, `static({...})`, the `statics` option) is a member
of every model made from it; its `methods` are members of `new Model(...)`.
The package's own members stay receiver_untyped as before.

Co-authored-by: axiomcode-bot[bot] <334110751+axiomcode-bot[bot]@users.noreply.github.com>
@swapnilpaliwal-sd
swapnilpaliwal-sd merged commit 7400340 into apps/integration-0.1.9 Sep 30, 2026
12 checks passed
@swapnilpaliwal-sd
swapnilpaliwal-sd deleted the apps/javascript/orm-model-factory-result-untyped branch September 30, 2026 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant