Skip to content

Use shorthand - for negating expressions in ShipQL#403

Merged
noe-charmet merged 1 commit intomainfrom
use_negative_shorthand
Feb 10, 2026
Merged

Use shorthand - for negating expressions in ShipQL#403
noe-charmet merged 1 commit intomainfrom
use_negative_shorthand

Conversation

@noe-charmet
Copy link
Contributor

@noe-charmet noe-charmet commented Feb 10, 2026

Summary by CodeRabbit

  • New Features
    • Added shorthand negation syntax in ShipQL: use - prefix to negate expressions instead of the NOT keyword (e.g., -status:error).

@coderabbitai
Copy link

coderabbitai bot commented Feb 10, 2026

Walkthrough

This pull request introduces shorthand negation syntax in ShipQL, changing from the "NOT" keyword to a "-" prefix for simple negated expressions. The stringify function is updated to emit "-" for simple terms and "NOT (expr)" for compound expressions, with corresponding test expectations adjusted accordingly.

Changes

Cohort / File(s) Summary
Changeset Documentation
.changeset/chilly-tires-run.md
New changeset entry documenting the patch release for @shipfox/shipql-parser with the new dash negation shorthand syntax feature.
Stringify Implementation & Tests
libs/common/shipql-parser/src/stringify.ts, libs/common/shipql-parser/src/stringify.test.ts
Updated NOT expression handling to emit "-" prefix for simple terms (e.g., -status:error) and "NOT (expr)" for compound AND/OR expressions. Test expectations updated to reflect dash-based output instead of keyword form.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • dvxam
  • kylengn
  • EnzalRad

Poem

🐰 A dash, not NOT, the rabbit cheers with glee,
Shorthand syntax dancing wild and free,
From verbose words to symbols brief and bright,
The parser hops toward elegance—what a sight! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: introducing shorthand - notation for negating expressions in ShipQL instead of the NOT keyword.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch use_negative_shorthand

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
libs/common/shipql-parser/src/stringify.ts (1)

53-68: Remove unreachable 'not' handling from stringifyChild.

The stringifyChild function includes a 'not' case (lines 62–65), but stringifyChild is never called with parentType: 'not'. The case 'not' in stringify (lines 33–39) directly calls stringify() instead of stringifyChild(), making lines 62–65 dead code.

♻️ Proposed cleanup
-/** Stringify a child node, wrapping in parentheses when precedence requires it. */
-function stringifyChild(child: AstNode, parentType: 'and' | 'or' | 'not'): string {
+/** Stringify a child node, wrapping in parentheses when precedence requires it. */
+function stringifyChild(child: AstNode, parentType: 'and' | 'or'): string {
   const s = stringify(child);
 
   // OR inside AND needs parens: a:1 (b:2 OR c:3)
   if (parentType === 'and' && child.type === 'or') {
     return `(${s})`;
   }
 
-  // AND or OR inside NOT needs parens: NOT (a:1 b:2)
-  if (parentType === 'not' && (child.type === 'and' || child.type === 'or')) {
-    return `(${s})`;
-  }
-
   return s;
 }

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@vercel
Copy link

vercel bot commented Feb 10, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
react-ui Ready Ready Preview, Comment Feb 10, 2026 3:15pm

Request Review

@noe-charmet noe-charmet merged commit 03a6127 into main Feb 10, 2026
4 checks passed
@noe-charmet noe-charmet deleted the use_negative_shorthand branch February 10, 2026 16:31
@coderabbitai coderabbitai bot mentioned this pull request Feb 12, 2026
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.

2 participants

Comments