generate-dac 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "generate-dac",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/DAC_Utils.ts CHANGED
@@ -314,7 +314,8 @@ export function dac_generate_dataServiceObject(tableName: string, schemas: Colum
314
314
  const classTemplate = text_from_file(`${TEMPLATE_DIR}/templates/DataServiceObjects_Class_Template.cs`);
315
315
 
316
316
  const strProperties = schemas.map((e, i) => {
317
- return `public ${get_SqlDbType(e.type).codeType} ${e.col_name.replace(/[ _]+/g, '')} { get; set; }`;
317
+ // Use enum if enum is defined
318
+ return `public ${e.enum || get_SqlDbType(e.type).codeType} ${e.col_name.replace(/[ _]+/g, '')} { get; set; }`;
318
319
  }).join('\n' + repeat("\t", 2));
319
320
 
320
321
  let created_by_user = '';
@@ -374,7 +375,7 @@ export function dac_generate_conversions(tableName: string, schemas: ColumnSchem
374
375
  const methodTemplate = text_from_file(`${TEMPLATE_DIR}/templates/MakeDSO_Template_Method.cs`);
375
376
 
376
377
  const dsoFields = schemas.map((e, i) => {
377
- return `ds${className}.${e.colName} = db${className}.${e.col_name};`;
378
+ return `ds${className}.${e.colName} =${e.enum ? `(${e.enum})` : ''} db${className}.${e.col_name};`;
378
379
  }).join('\n' + repeat("\t", 3));
379
380
 
380
381
  const dbFields = schemas.map((e, i) => {
@@ -387,7 +388,7 @@ export function dac_generate_conversions(tableName: string, schemas: ColumnSchem
387
388
  return `db${className}.${e.col_name} = DateTimeHelper.MakeDBDefaultValue(ds${className}.${e.colName});`;
388
389
  }
389
390
 
390
- return `db${className}.${e.col_name} = ds${className}.${e.colName};`;
391
+ return `db${className}.${e.col_name} = ds${className}.${e.colName}${e.enum ? `.GetHashCode()` : ''};`;
391
392
  }).join('\n' + repeat("\t", 3));
392
393
 
393
394
  let created_by_user = '';
@@ -709,10 +710,9 @@ export function DAC_Generate_From_XLSX(filePath: string, sheetIndex: number = 0)
709
710
  content: schemas.join("\n\n\n")
710
711
  });
711
712
 
712
- const content = `
713
- ${dropConstrains.join("\n")}
713
+ const content = `${dropConstrains.filter(e => e).join("\nGO\n")}
714
714
 
715
- ${dropTables.join("\n")}`;
715
+ ${dropTables.join("\nGO\n")}`;
716
716
 
717
717
  files.push({
718
718
  name: 'table_schema_reset.sql',
package/src/interface.ts CHANGED
@@ -7,5 +7,6 @@ export interface ColumnSchema {
7
7
  allow_null: 'yes' | 'no',
8
8
  foreign_table?: string,
9
9
  foreign_column?: string,
10
- primary_key?: 'yes' | 'no'
10
+ primary_key?: 'yes' | 'no',
11
+ enum?: string,
11
12
  }