Skip to content

feat(ql): add DELETE, UPDATE, SELECT statements and field validation#739

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

feat(ql): add DELETE, UPDATE, SELECT statements and field validation#739
abalam666 wants to merge 2 commits intomainfrom
ql/crud

Conversation

@abalam666
Copy link
Collaborator

@abalam666 abalam666 commented Mar 17, 2026

Summary

  • DELETE / UPDATE / SELECT statements: WebdaQL now supports DELETE WHERE ..., UPDATE SET ... WHERE ..., and SELECT field1, field2 WHERE ... (with implicit detection — no SELECT keyword required for comma-separated field lists)
  • Case-insensitive statement keywords: DELETE, UPDATE, SET, SELECT, WHERE, TRUE, FALSE can be written in any case (delete where ..., Update Set ..., etc.)
  • Runtime field validation: parse(query, allowedFields?) validates SELECT fields and UPDATE SET targets against an allowed field list. Also available standalone via validateQueryFields(query, allowedFields)
  • Repository integration: AbstractRepository.getAllowedFields() derives allowed fields from model JSON Schema metadata; MemoryRepository.query() and .iterate() pass them through automatically

Changed files

Package File Change
@webda/ql src/query.ts Pre-parser for statement prefixes, assignment parsing, implicit SELECT detection, field validation
@webda/ql src/query.spec.ts 5 new test methods (delete, update, select, allowedFields, caseInsensitiveKeywords)
@webda/ql README.md Full rewrite with new syntax documentation
@webda/models repositories/abstract.ts getAllowedFields() method
@webda/models repositories/memory.ts Pass allowed fields to WebdaQL.parse()
@webda/test package.json Fix workspace dependency resolution

Design decision

Statement-level syntax (DELETE/UPDATE/SELECT/WHERE) is handled by a TypeScript pre-parser rather than extending the ANTLR grammar. This avoids making these words reserved tokens (which would break queries using them as field names) and keeps generated files unchanged.

Test plan

  • All 19 tests pass (pnpm run test in packages/ql)
  • Verify field validation works end-to-end with a real model/repository
  • Test with downstream consumers (e.g. @webda/core stores)

@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
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.

1 participant