MCPcopy Create free account
hub / github.com/subquery/subql / formatAttributes

Function formatAttributes

packages/node-core/src/db/sequelizeUtil.ts:72–85  ·  view source on GitHub ↗
(
  columnOptions: ModelAttributeColumnOptions,
  schema: string,
  withoutForeignKey: boolean
)

Source from the content-addressed store, hash-verified

70}
71
72export function formatAttributes(
73 columnOptions: ModelAttributeColumnOptions,
74 schema: string,
75 withoutForeignKey: boolean
76): string {
77 const type = formatDataType(columnOptions.type);
78 const allowNull = columnOptions.allowNull === false ? 'NOT NULL' : '';
79 const unique = columnOptions.unique ? 'UNIQUE' : '';
80 const autoIncrement = columnOptions.autoIncrement ? 'AUTO_INCREMENT' : ''; // PostgreSQL
81
82 const references = formatReferences(columnOptions, schema);
83
84 return `${type} ${allowNull} ${unique} ${autoIncrement} ${withoutForeignKey ? '' : references}`.trim();
85}
86
87// TODO this should be using TypeClass.types['dbType'] instead of TypeClass.key
88const sequelizeToPostgresTypeMap = {

Callers 2

generateCreateTableQueryFunction · 0.90
createColumnMethod · 0.90

Calls 2

formatDataTypeFunction · 0.85
formatReferencesFunction · 0.85

Tested by

no test coverage detected