Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for advanced expressions #49

Merged
merged 1 commit into from
Feb 5, 2025
Merged

Added support for advanced expressions #49

merged 1 commit into from
Feb 5, 2025

Conversation

colodenn
Copy link
Member

@colodenn colodenn commented Feb 5, 2025

This PR introduces support for advanced expressions such as:

number().defaultValue(() => op(5, '-', 3)),
string().check((fields) => op('Hello', '=', fields.stringConcat)),
string().defaultValue(() => sql("UPPER('test')")),
string().computedAs((fields) => ({
  kind: 'VIRTUAL',
  value: op(fields.numberAdd2, '||', fields.numberSubtract),
})),

However, there are still some missing type hints. We want to discourage expressions like:

number().defaultValue(() => op(5, '-', 3))

where database-level expressions are used inside default values. Instead, users should use:

number().defaultValue(() => 5 - 3)

so that the value is evaluated at runtime rather than by the database. This change ensures clearer separation between client-side evaluation and database-generated expressions, improving both type safety and overall code maintainability.

This was landed in ronin-co/syntax#39 and in ronin-co/syntax#32.

Furthermore we ensure inferred fields are marked as null in ronin-co/syntax#38.

@colodenn colodenn requested a review from leo February 5, 2025 14:14
@colodenn colodenn self-assigned this Feb 5, 2025
Copy link

github-actions bot commented Feb 5, 2025

Released an experimental package:

bun add ronin@corny-ron-1099-experimental-68

This package will be removed after the pull request has been merged.

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

@colodenn colodenn marked this pull request as ready for review February 5, 2025 14:15
@colodenn colodenn merged commit f62a516 into main Feb 5, 2025
5 checks passed
@colodenn colodenn deleted the corny/ron-1099 branch February 5, 2025 14:17
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.

3 participants