Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 30, 2025

Thank you for the time you are putting into AlaSQL!

Problem

alasql.parse() then AST.toString() loses square brackets on column names that require them (spaces, periods, special chars).

const ast = alasql.parse('SELECT [Foo Bar] FROM tbl');
console.log(ast.toString()); // "SELECT Foo Bar FROM tbl" ❌

Fix

Modified Column.toString() in src/50expression.js to handle column IDs stored as {val, wrap} objects by the parser.

  • When columnid is an object with val and wrap properties, reconstruct the original bracketed/backticked notation
  • Extracted duplicated condition check into a variable for maintainability

Test Coverage

Added test/test1740.js with 6 test cases:

  • [Foo Bar] - space in column name
  • [Foo.Bar] - period in column name
  • FooBar - regular column (no brackets added)
  • Multiple bracketed columns in same query
  • Special characters in column name
  • Backtick syntax (`Foo Bar`)
const ast = alasql.parse('SELECT [Foo Bar] FROM tbl');
console.log(ast.toString()); // "SELECT [Foo Bar] FROM tbl" ✓

💡 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 self-assigned this Nov 30, 2025
Copilot AI changed the title [WIP] Add test file for issue #1740 to verify fix Fix Parse() then AST.toString() to restore square brackets on column names Nov 30, 2025
Copilot AI requested a review from mathiasrw November 30, 2025 15:21
@mathiasrw mathiasrw marked this pull request as ready for review November 30, 2025 22:07
@mathiasrw mathiasrw merged commit 81d7712 into cohelp/akashyadav24/1782 Nov 30, 2025
2 checks passed
@mathiasrw mathiasrw deleted the copilot/sub-pr-2287 branch November 30, 2025 22:07
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