Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 16, 2025

Issue #2218 requested limiting the impact of SOURCE as a reserved keyword, similar to PR #2203's handling of VALUE/VALUES.

Finding

SOURCE is already in the NonReserved production rule (alasqlparser.jison lines 3171, 3178), enabling Jison's error recovery to accept it as an identifier while preserving keyword functionality.

Changes

  • Added test/test2218.js - 7 test cases demonstrating SOURCE works as:
    • Table names, column names, JSON properties
    • Table aliases, WHERE clauses, UNIQUE constraints
    • SOURCE "file.sql" commands (keyword context)
    • MERGE ... BY SOURCE clauses (keyword context)

Example

// All of these work without grammar changes:
alasql('CREATE TABLE source(id INT)');
alasql('SELECT source FROM table WHERE source = "value"');
alasql('CREATE INDEX idx ON table(data->source)');

// Keyword contexts preserved:
alasql('SOURCE "script.sql"');
alasql('MERGE t USING s ON ... WHEN NOT MATCHED BY SOURCE ...');

No grammar modifications required.

Original prompt

This section details on the original issue you should resolve

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

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.

Co-authored-by: mathiasrw <1063454+mathiasrw@users.noreply.github.com>
Copilot AI changed the title [WIP] Limit the impact of using the keyword 'Source' Add test coverage for SOURCE keyword - no grammar changes needed Dec 16, 2025
Copilot AI requested a review from mathiasrw December 16, 2025 22:58
@mathiasrw mathiasrw marked this pull request as ready for review December 17, 2025 13:41
@mathiasrw mathiasrw merged commit 3ec8dfa into develop Dec 17, 2025
20 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: Source

2 participants