Skip to content

feat: computed expressions and expression-based updates#31

Merged
flyon merged 6 commits intodevfrom
flyon/006
Mar 12, 2026
Merged

feat: computed expressions and expression-based updates#31
flyon merged 6 commits intodevfrom
flyon/006

Conversation

@flyon
Copy link
Member

@flyon flyon commented Mar 12, 2026

Summary

Properties in select() and update() now support expressions — you can compute values dynamically instead of just reading or writing raw fields.

  • Computed fields in queries — chain methods like .strlen(), .times(), .ucase(), .year() on properties inside select() to derive new values on the fly
  • Expression-based WHERE filters — filter using computed conditions (p.name.strlen().gt(5)), not just equality. Works on queries, updates, and deletes
  • Computed updates — calculate new values from existing ones in update queries (p.age.plus(1)) instead of providing static values
  • Expr module — standalone expressions that don't start from a property: Expr.now(), Expr.ifThen(), Expr.firstDefined()
// Compute derived fields
await Person.select(p => ({ name: p.name, nameLen: p.name.strlen(), ageMonths: p.age.times(12) }));

// Filter on computed values
await Person.select(p => p.name).where(p => p.age.gt(18));

// Update with expressions
await Person.update(p => ({ age: p.age.plus(1) })).for(entity);
await Person.update({ lastSeen: Expr.now() }).for(entity);

Also removes stale changesets already processed on dev, and extracts a shared createTraversalResolver factory from 4 duplicated traversal implementations.

Test plan

  • 821 tests passing, 0 failures
  • ExpressionNode unit tests (~65 cases), Expr module tests (~64), type tests (14)
  • Golden SPARQL tests for expression SELECT, WHERE, and mutations
  • TypeScript compiles clean

🤖 Generated with Claude Code

René Verheij and others added 6 commits March 11, 2026 17:02
…regate group filtering. The new docs outline the implementation of computed query fields, fluent datatype-aware property methods, and introduce a separate design for aggregate group filtering with HAVING semantics.
Add fluent expression methods on property proxies (.plus(), .strlen(), .gt(),
etc.) for computed SELECT projections and expression-based WHERE filters.
Add Expr module for standalone expressions (Expr.now(), Expr.ifThen(),
Expr.firstDefined()). Add expression-based mutations via callback form.

Includes shared createTraversalResolver factory, README documentation,
comprehensive test coverage (821 tests passing), and cleanup of stale
changesets already processed on dev.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Rewrite expression sections for clarity — lead with what users can do,
move method reference to a table, drop SPARQL jargon. Update shape
examples to use schema.Person dot notation instead of schema('Person')
function calls. Add schema.org ontology file.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace fake schema.org ontology with honest example using
createNameSpace('https://example.org/') and an ex object pattern.
Delete src/ontologies/schema.ts — the library doesn't ship schema.org.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@flyon flyon merged commit ff78b8d into dev Mar 12, 2026
3 checks passed
@flyon flyon deleted the flyon/006 branch March 12, 2026 04:17
flyon added a commit that referenced this pull request Mar 12, 2026
Properties in select() and update() now support expressions — you can compute values dynamically instead of just reading or writing raw fields.

    Computed fields in queries — chain methods like .strlen(), .times(), .ucase(), .year() on properties inside select() to derive new values on the fly
    Expression-based WHERE filters — filter using computed conditions (p.name.strlen().gt(5)), not just equality. Works on queries, updates, and deletes
    Computed updates — calculate new values from existing ones in update queries (p.age.plus(1)) instead of providing static values
    Expr module — standalone expressions that don't start from a property: Expr.now(), Expr.ifThen(), Expr.firstDefined()
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