(
fieldName: string,
isDBMLFlow: boolean = false
)
| 129 | }; |
| 130 | |
| 131 | const 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 | |
| 154 | export const exportBaseSQL = ({ |
| 155 | diagram, |
no test coverage detected