fix: Handle various table and attribute names better#25
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces utility functions and tests to ensure valid TypeScript identifiers and safe property keys are generated from database table and attribute names. Specifically, it extracts and enhances safeKey to quote keys that are invalid identifiers (such as those starting with digits or containing special characters) and updates toIdentifier to convert arbitrary names into valid identifiers. The review feedback highlights a potential syntax issue in safeKey when property names contain single quotes or backslashes, suggesting escaping these characters and adding corresponding test cases.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
I don’t remember if we let these into table or attribute names, but it’s worth protecting, I suppose.
|
I went a bit overboard on the checks |
| .replace(/[^a-zA-Z0-9_$]/g, '_'); | ||
| // an identifier cannot start with a digit | ||
| if (/^[0-9]/.test(identifier)) { | ||
| identifier = `_${identifier}`; |
fixes issue #7