Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 16, 2025

COMPLETED - Limit the impact of using the keyword: DELETED

Summary

Successfully limited the impact of the DELETED keyword. It can now be used as:

  • ✅ Table names
  • ✅ Column names
  • ✅ Table aliases
  • ✅ Column aliases
  • ✅ In WHERE, ORDER BY, GROUP BY clauses

OUTPUT clause functionality with DELETED.* and INSERTED.* is fully preserved.

Recent Fix

Fixed test2223 failures by restoring ORDER keyword to NonReserved grammar rule. During code reformatting, ORDER was accidentally removed from the grammar rule while it remained in the JavaScript array, causing parser error recovery to fail.

Changes Made

Grammar Changes (src/alasqlparser.jison)

  1. Added DELETED and INSERTED to NonReserved list: Both in the grammar rule and the JavaScript array. This allows the parser's error recovery mechanism to treat these keywords as regular identifiers when appropriate.

  2. Added standalone Column rules with detailed comments:

    • Lines 1246-1251: DELETED DOT Literal patterns for OUTPUT pseudo-table (uppercase 'DELETED' tableid)
    • Lines 1258-1266: Standalone DELETED/INSERTED patterns for regular identifiers (lowercase columnid)
    • Comments explain rule ordering, casing rationale, and SQL case-insensitive behavior
  3. Preserved existing OUTPUT clause functionality: No changes to existing DELETED DOT Literal patterns

Test Coverage (test/test2360.js)

Created comprehensive test file with 15 test cases - all passing ✓

  • DELETED as table name
  • DELETED as column name
  • DELETED in OUTPUT clauses (existing functionality)
  • DELETED as table and column aliases
  • DELETED in WHERE, ORDER BY, GROUP BY clauses
  • Combined usage scenarios

Verification

  • ✅ All 15 DELETED keyword tests pass
  • ✅ All 8 ORDER keyword tests pass (test2223)
  • ✅ All 23 existing OUTPUT clause tests still pass
  • ✅ No regressions in other test files

Known Limitation

Qualified column references like deleted.column when "deleted" is a user-defined table name (not the OUTPUT pseudo-table) may create ambiguity. Workaround: use table aliases or unqualified references.

Original prompt

This section details on the original issue you should resolve

<issue_title>Limit the impact of using the keyword: DELETED</issue_title>
<issue_description>Limit the impact of using the keyword: DELETED

Just like in #2203 we want to limit the impact of having keywords. Preferably by making them keywords only in the context needed so the string/word can be used for things like table names and column names i the data - if possible. It might be too much of a hassle to make the impact less, but lets investigate what is possible - still sticking to the SQL-99 specs.

Start by making a test file named test0000.js where 0000 is the issue ID of this ticket. Replicate the use and mimic what usecases could make sense to test, like as a table name, as a column name, as a graph search. Things lke that.

The grammar can be updated in alasqlgrammar.jison. Focus on small precise changes. After updating it we need to run yarn jison && yarn test

Always run yarn format before committing.

</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Limit the impact of using the keyword: DELETED Allow DELETED and INSERTED keywords as identifiers outside OUTPUT clauses Dec 16, 2025
Copilot AI requested a review from mathiasrw December 16, 2025 23:06
@mathiasrw mathiasrw force-pushed the copilot/limit-deleted-keyword-impact branch from 56b5c03 to e75294a Compare December 17, 2025 13:39
@mathiasrw
Copy link
Member

@copilot

.............!

782 passing (2s)
30 pending
1 failing

  1. Test 2223 - ORDER as context-aware keyword
    B) ORDER as a column name:
    Error: Parsing halted while starting to recover from another error.
    at Parser.parse (dist/alasql.fs.js:2289:27)
    at alasql.parse (dist/alasql.fs.js:4713:22)
    at alasql.dexec (dist/alasql.fs.js:4974:16)
    at alasql.exec (dist/alasql.fs.js:4928:17)
    at alasql (dist/alasql.fs.js:137:17)
    at Context. (test/test2223.js:37:3)
    at process.processImmediate (node:internal/timers:485:21)

Copy link
Contributor Author

Copilot AI commented Dec 17, 2025

@copilot

...

Fixed in commit 80045dc. The ORDER keyword was accidentally removed from the NonReserved grammar rule during code reformatting. All test2223 tests now pass.

Copilot AI and others added 6 commits December 18, 2025 01:00
Co-authored-by: mathiasrw <1063454+mathiasrw@users.noreply.github.com>
Co-authored-by: mathiasrw <1063454+mathiasrw@users.noreply.github.com>
Co-authored-by: mathiasrw <1063454+mathiasrw@users.noreply.github.com>
Co-authored-by: mathiasrw <1063454+mathiasrw@users.noreply.github.com>
@mathiasrw mathiasrw force-pushed the copilot/limit-deleted-keyword-impact branch from 80045dc to e3c5746 Compare December 17, 2025 14:00
@mathiasrw mathiasrw marked this pull request as ready for review December 21, 2025 04:52
@mathiasrw mathiasrw merged commit 5fd3639 into develop Dec 21, 2025
10 checks passed
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.

Limit the impact of using the keyword: DELETED

2 participants