fix(d1): preserve unary operators in processCol to support leading + and - - #63
Merged
Conversation
Contributor
There was a problem hiding this comment.
📋 Review Summary
This pull request adds support for leading unary operators (such as + and -) in D1.processCol, preventing unary operators from interfering with table prefixing or SQLite JSON path extraction during query ordering. It also introduces unit and integration tests covering unary operator handling. However, the assertions for test case 4 in test/test_order.test.js were accidentally removed during the update and should be restored.
🔍 General Feedback
- Preserving leading unary operators in
processColcleanly enables SQLite idioms like unary+(to suppress index utilisation) and unary-(for inverted sorting). - The defensive
typeof col !== 'string'check added at the beginning ofprocessColis a good addition to prevent runtime type errors if non-string values are passed.
📊 Token Usage & Cost Efficiency
| Metric | Value |
|---|---|
| Input Tokens (uncached) | 52,469 |
| Output Tokens | 479 |
| Total Session Tokens | 64,995 |
| Cost (uncached input) | $0.0394 |
| Cost (output) | $0.0018 |
| Estimated Total Cost | $0.0411 |
Gemini 3.8 Flash: introductory rate $0.75/$3.75 per 1M applied; reverts to $1.5/$7.5 after 2026-12-31.
Gemini 3.8 Flash: standard tier; batch and flex are half again, priority is higher.
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.
Summary
Fixes an issue where column identifiers with leading unary operators (e.g.
+threads.showAtor-threads.score) were mangled byprocessCol()into invalid SQL likejson_extract(threads.+threads, '$.showAt'), causing SQLitenear "+": syntax error.What changed
processCol(), extract any leading unary operator (+or-) before running prefixing and JSON sub-property extraction, then reattach it to the resulting column expression.test/test_order.test.jscovering:+users.nameand(+users.name).processColbehavior with qualified and unqualified unary expressions and JSON paths.