Arithmetic expression support - #13
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements
ArithmeticExpression(CoreModel 2.11.0) as native SQL, replacing the previousinvalidPredicaterejection.Translation
(a <op> b) <operator> constantcompiles to a parenthesized SQL expression with positional bindings, recursively for nested operands. SQLite's native operators match CoreModel's in-memory engine where it matters:/truncates when both operands areINTEGER(7 / 2is3) and promotes toREALwhen either is floating pointNULL, which fails every comparison — the same observable outcome as the engine'snilDeliberate divergence handling
.moduluswith a statically-known non-integer operand is rejected (invalidPredicate) rather than translated: SQLite's%casts operands toINTEGER, but CoreModel defines remainder for integers only, and a silently cast result would differ between backends. Operand types are resolved from the entity description (composite element columns included); unknown types (e.g. a custom function's result) pass through, whereNULLpropagation makes a wrong guess harmless.Int64: the in-memory engine wraps, SQLite promotes an overflowingINTEGERresult to aREALapproximation. Documented in the source.Testing
10 new tests against real SQLite files: integer add/divide/modulus, truncation, division-by-zero across three operators, float promotion, float-modulus rejection, nested expressions, compound predicates — plus a sweep asserting SQL and in-memory evaluation return identical row sets for the same inputs. All 127 tests pass.