Skip to content

fix: Handle various table and attribute names better#25

Open
dawsontoth wants to merge 2 commits into
mainfrom
number-name-handling
Open

fix: Handle various table and attribute names better#25
dawsontoth wants to merge 2 commits into
mainfrom
number-name-handling

Conversation

@dawsontoth

Copy link
Copy Markdown
Contributor

fixes issue #7

@dawsontoth dawsontoth requested a review from a team as a code owner June 15, 2026 17:22

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread utils/safeKey.js Outdated
Comment thread utils/safeKey.test.js
I don’t remember if we let these into table or attribute names, but it’s worth protecting, I suppose.
@dawsontoth dawsontoth requested a review from cb1kenobi June 15, 2026 17:36
@dawsontoth

Copy link
Copy Markdown
Contributor Author

I went a bit overboard on the checks

Comment thread utils/toIdentifier.js
.replace(/[^a-zA-Z0-9_$]/g, '_');
// an identifier cannot start with a digit
if (/^[0-9]/.test(identifier)) {
identifier = `_${identifier}`;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That'll work!

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