-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(mermaid): fixed mermaid ER Diagram
- fixed mermaid ER Diagram syntax error when using TypeORM-only types that contain spaces
- Loading branch information
Showing
9 changed files
with
67 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -117,3 +117,4 @@ template2/ | |
erdiadb.json | ||
**/.DS_Store | ||
.npmrc | ||
git-short.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
const mermaidScript = `<script src="https://cdnjs.cloudflare.com/ajax/libs/mermaid/10.3.1/mermaid.min.js"></script> | ||
const mermaidScript = `<script src="https://cdnjs.cloudflare.com/ajax/libs/mermaid/10.9.0/mermaid.min.js"></script> | ||
<script>mermaid.initialize({ startOnLoad: true });</script>`; | ||
|
||
export default mermaidScript; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 22 additions & 17 deletions
39
src/typeorm/columns/__tests__/expects/expect.getColumnRecord-pass.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,31 @@ | ||
import getIsNullable from '#/typeorm/columns/getIsNullable'; | ||
import { isTrue } from 'my-easy-fp'; | ||
import type { ColumnMetadata } from 'typeorm/metadata/ColumnMetadata'; | ||
|
||
export default function getColumnType( | ||
columnMetadata: Pick<ColumnMetadata, 'type' | 'length'>, | ||
columnMetadata: Pick<ColumnMetadata, 'type' | 'length' | 'isNullable' | 'isPrimary'>, | ||
includeLength?: boolean, | ||
) { | ||
const nullable = getIsNullable(columnMetadata); | ||
if (typeof columnMetadata.type === 'function') { | ||
if (isTrue(includeLength ?? false) && columnMetadata.length !== '') { | ||
return `${columnMetadata.type.name.toString().toLowerCase()}(${columnMetadata.length})`; | ||
const name = columnMetadata.type.name.toString().toLowerCase().replace(/\s/g, '-'); | ||
const withNullable = nullable === 'nullable' ? name : `*${name}`; | ||
return `${withNullable}(${columnMetadata.length})`; | ||
} | ||
|
||
return columnMetadata.type.name.toString().toLowerCase(); | ||
const name = columnMetadata.type.name.toString().toLowerCase().replace(/\s/g, '-'); | ||
const withNullable = nullable === 'nullable' ? name : `*${name}`; | ||
return withNullable; | ||
} | ||
|
||
if (isTrue(includeLength ?? false) && columnMetadata.length !== '') { | ||
return `${columnMetadata.type.toString()}(${columnMetadata.length})`; | ||
const name = columnMetadata.type.toString().replace(/\s/g, '-'); | ||
const withNullable = nullable === 'nullable' ? name : `*${name}`; | ||
return `${withNullable}(${columnMetadata.length})`; | ||
} | ||
|
||
return columnMetadata.type.toString(); | ||
const name = columnMetadata.type.toString().replace(/\s/g, '-'); | ||
const withNullable = nullable === 'nullable' ? name : `*${name}`; | ||
return withNullable; | ||
} |