MCPcopy
hub / github.com/drawdb-io/drawdb / generateAddExtendedPropertySQL

Function generateAddExtendedPropertySQL

src/utils/exportSQL/mssql.js:11–37  ·  view source on GitHub ↗
(value, level1name, level2name = null)

Source from the content-addressed store, hash-verified

9import { DB } from "../../data/constants";
10
11function generateAddExtendedPropertySQL(value, level1name, level2name = null) {
12 if (!value || value.trim() === "") {
13 return "";
14 }
15 const escapedValue = escapeQuotes(value.replace(/\n/g, " "));
16 const escapedTableName = escapeQuotes(level1name);
17
18 if (level2name) {
19 const escapedColumnName = escapeQuotes(level2name);
20 return `
21EXEC sys.sp_addextendedproperty
22 @name=N'MS_Description', @value=N'${escapedValue}',
23 @level0type=N'SCHEMA',@level0name=N'dbo',
24 @level1type=N'TABLE',@level1name=N'${escapedTableName}',
25 @level2type=N'COLUMN',@level2name=N'${escapedColumnName}';
26GO
27`;
28 } else {
29 return `
30EXEC sys.sp_addextendedproperty
31 @name=N'MS_Description', @value=N'${escapedValue}',
32 @level0type=N'SCHEMA',@level0name=N'dbo',
33 @level1type=N'TABLE',@level1name=N'${escapedTableName}';
34GO
35`;
36 }
37}
38
39export function toMSSQL(diagram) {
40 const tablesSql = diagram.tables

Callers 1

toMSSQLFunction · 0.85

Calls 1

escapeQuotesFunction · 0.90

Tested by

no test coverage detected