( fullType: string, availableTypes: DataTypeInfo[], )
| 30 | * it is kept intact with no length extraction. |
| 31 | */ |
| 32 | export function parseColumnType( |
| 33 | fullType: string, |
| 34 | availableTypes: DataTypeInfo[], |
| 35 | ): ParsedType { |
| 36 | const upperFull = fullType.toUpperCase().trim(); |
| 37 | const exactMatch = availableTypes.find( |
| 38 | (t) => t.name.toUpperCase() === upperFull, |
| 39 | ); |
| 40 | if (exactMatch) { |
| 41 | return { type: exactMatch.name, length: "" }; |
| 42 | } |
| 43 | const match = fullType.match(/^([a-zA-Z0-9_[\] ]+)(?:\((.+)\))?$/); |
| 44 | if (match) { |
| 45 | return { type: match[1].toUpperCase().trim(), length: match[2] || "" }; |
| 46 | } |
| 47 | return { type: upperFull, length: "" }; |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Build a ColumnDefinition (backend-compatible) from a form data object. |
no outgoing calls
no test coverage detected