-
Notifications
You must be signed in to change notification settings - Fork 690
Fix double-quoted column aliases to work as identifiers per SQL standard #2306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@copilot Continue |
I've completed the implementation. The fix allows double quotes Changes made:
Result: SELECT col AS "Fancy Name" -- ✅ Now works!
SELECT col AS `Fancy Name` -- ✅ Already worked
SELECT col AS [Fancy Name] -- ✅ Already workedSecurity scan passed with 0 alerts. Commit: 1cf51cc |
|
Run yarn test-format-all |
18fef43 to
b390710
Compare
|
@copilot There was a problem while testing this, but it was before the test runner executed. I investigated. It turns out that some tests have not wrapped the setup code in a beforeall() function, meaning it runs before the test runner is running. For example we got test376.js - please move the setup code into a beforeall. Now, the issue is that its running alasql in the setup and then the rest of the test are blocked because there is a break option. The key is that it is trying to create code like this so the middle I have put int a in 424select.js to help you on the way. Please remove the comment when you are done debugging. |
Fixed the JavaScript code generation bug by adding |
|
@copilot Is there a reason we dont include -- All three quote types now work for aliases with spaces: |
Single quotes
This is a fundamental SQL standard rule that separates data (strings) from database object names (identifiers). Example showing why single quotes don't work for aliases: -- ❌ WRONG: Single quotes are string literals, not identifiers
SELECT SUM(column) AS 'Fancy Name' FROM table;
-- This tries to use the string 'Fancy Name' as an alias, which violates SQL syntax
-- ✅ CORRECT: Use double quotes for identifiers with spaces
SELECT SUM(column) AS "Fancy Name" FROM table;
-- ✅ CORRECT: Or use no quotes if no spaces
SELECT SUM(column) AS FancyName FROM table;AlaSQL extensions (backticks
Single quotes SQL Standard (SQL-92/SQL-99/SQL:2003):
This is why AlaSQL's backticks |
ff0369f to
aa745b6
Compare
aa745b6 to
39e7eeb
Compare
You use single quotes or double quotes on table aliases SELECT col AS "Fancy Name" FROM table -- Double quotes ✓ SELECT col AS 'Fancy Name' FROM table -- Single quotes ✓ SELECT col AS `Fancy Name` FROM table -- Backticks (preexisting) SELECT col AS [Fancy Name] FROM table -- Brackets (preexisting)
"for aliases create identifiers with quotes includedOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.