MCPcopy Create free account
hub / github.com/TabularisDB/tabularis / parseColumnType

Function parseColumnType

src/utils/columnTypes.ts:32–48  ·  view source on GitHub ↗
(
  fullType: string,
  availableTypes: DataTypeInfo[],
)

Source from the content-addressed store, hash-verified

30 * it is kept intact with no length extraction.
31 */
32export 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.

Callers 3

ModifyColumnModalFunction · 0.90
handleSubmitFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected