fix(sql): fix to recognise view names in quotes#6771
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughAdds token unquoting to three table/view lookup sites in SqlParser to properly resolve quoted identifiers. Includes new tests validating that views can be compiled and queried when their names are quoted using single or double quotes. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
[PR Coverage check]😍 pass : 3 / 3 (100.00%) file detail
|
|
@CodeRabbit what's the latest, did you review? |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain
🏁 Script executed: Length of output: 7287 🏁 Script executed: Length of output: 12250 🏁 Script executed: Length of output: 22431 🏁 Script executed: Length of output: 1206 🏁 Script executed: Length of output: 5134 🏁 Script executed: Length of output: 2905 🏁 Script executed: Length of output: 3781
✅ Core Fix is CorrectThe PR correctly adds
This properly strips quotes so the view lookup succeeds. Test coverage at 100% confirms the fix works for the stated issue.
|
Summary
When a view name is quoted (single or double quotes),
SqlParserpasses the quoted token directly togetTableTokenIfExists(), which fails to find the view. This affects three code paths:SELECT ... FROM 'my_view'—parseFromClauseSELECT ... JOIN 'my_view' ON ...—parseJoinCOMPILE VIEW 'my_view'—parseCompileViewThe fix adds
unquote()to all threegetTableTokenIfExists()calls so the view is recognized regardless of quoting.Test plan
testQueryViewInQuotes— SELECT FROM with single-quoted and double-quoted view nametestQueryViewInQuotesJoin— JOIN with single-quoted and double-quoted view nametestCompileViewInQuotes— COMPILE VIEW with single-quoted and double-quoted view name