MCPcopy Index your code
hub / github.com/chartdb/chartdb / getQuotedFieldName

Function getQuotedFieldName

src/lib/data/sql-export/export-sql-script.ts:131–152  ·  view source on GitHub ↗
(
    fieldName: string,
    isDBMLFlow: boolean = false
)

Source from the content-addressed store, hash-verified

129};
130
131const getQuotedFieldName = (
132 fieldName: string,
133 isDBMLFlow: boolean = false
134): string => {
135 // Check if a name is already quoted
136 const isAlreadyQuoted = (name: string) => {
137 return (
138 (name.startsWith('"') && name.endsWith('"')) ||
139 (name.startsWith('`') && name.endsWith('`')) ||
140 (name.startsWith('[') && name.endsWith(']'))
141 );
142 };
143
144 if (isAlreadyQuoted(fieldName)) {
145 return fieldName;
146 }
147
148 // For DBML flow, always quote field names
149 // Otherwise, only quote if it contains special characters
150 const needsQuoting = /[^a-zA-Z0-9_]/.test(fieldName) || isDBMLFlow;
151 return needsQuoting ? `"${fieldName}"` : fieldName;
152};
153
154export const exportBaseSQL = ({
155 diagram,

Callers 1

exportBaseSQLFunction · 0.85

Calls 1

isAlreadyQuotedFunction · 0.85

Tested by

no test coverage detected