Skip to content

feat(ql): add DELETE/UPDATE/SELECT statements with ANTLR grammar#739

Open
abalam666 wants to merge 7 commits intomainfrom
ql/crud
Open

feat(ql): add DELETE/UPDATE/SELECT statements with ANTLR grammar#739
abalam666 wants to merge 7 commits intomainfrom
ql/crud

Conversation

@abalam666
Copy link
Copy Markdown
Collaborator

@abalam666 abalam666 commented Mar 17, 2026

Summary

  • Add DELETE, UPDATE, and SELECT statement support to WebdaQL, fully defined in the ANTLR grammar (.g4) and parsed via generated visitor methods
  • Make all keywords case-insensitive natively in the lexer using fragment-per-letter approach (e.g. delete, Delete, DELETE all work)
  • Add allowedFields validation for SELECT field lists and UPDATE SET assignment targets
  • Add ql-ts-plugin package for lightweight field extraction in IDE contexts

Details

  • Grammar: WebdaQLLexer.g4 defines case-insensitive tokens; WebdaQLParser.g4 adds deleteStatement, updateStatement, selectStatement rules with assignmentList and fieldList
  • Runtime: ExpressionBuilder visitor handles all statement types — no hand-written string parsing needed. The parse() function passes the full query to ANTLR
  • Breaking: implicit SELECT (bare field list without SELECT keyword) is removed — SELECT keyword is now required
  • Repositories: MemoryRepository.query() passes getAllowedFields() to parse() for field validation

Syntax

-- DELETE
DELETE WHERE status = 'inactive' LIMIT 100

-- UPDATE
UPDATE SET status = 'active', age = 30 WHERE name = 'John'

-- SELECT
SELECT name, age WHERE status = 'active' ORDER BY name ASC LIMIT 10 OFFSET 'token'

-- Plain filter (unchanged)
status = 'active' AND age > 18

@abalam666 abalam666 changed the title feat: enhance WebdaQL with DELETE and UPDATE support, add allowed fie… feat(ql): add DELETE, UPDATE, SELECT statements and field validation Mar 17, 2026
@abalam666 abalam666 force-pushed the ql/crud branch 2 times, most recently from 82659a0 to 49c2583 Compare March 17, 2026 14:30
@loopingz
Copy link
Copy Markdown
Owner

Grammar should be updated instead of manual parsing

- Updated the import statements in WebdaQLParserVisitor.ts for better readability by importing each context individually.
- Added missing visit methods for various contexts in WebdaQLParserVisitor interface.
- Modified the visitWebdaql method in ExpressionBuilder to handle both statement and filterQuery contexts.
- Enhanced visitFilterQuery method to correctly process child nodes and handle empty filters.
- Updated the WebdaQLParserParser to remove unnecessary literal names and improve parsing efficiency.
- Enhanced query tests to validate case insensitivity for keywords such as DELETE, UPDATE, SELECT, and boolean values.
- Modified the ExpressionBuilder to ensure that order directions and boolean literals are evaluated in a case-insensitive manner.
- Removed the uppercaseKeywords function as it is no longer needed, simplifying the query parsing process.
- Adjusted the parse function to directly use the original query string without normalization.
@abalam666 abalam666 requested a review from loopingz March 31, 2026 21:23
@abalam666 abalam666 changed the title feat(ql): add DELETE, UPDATE, SELECT statements and field validation feat(ql): add DELETE/UPDATE/SELECT statements with ANTLR grammar Mar 31, 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