oradm-to-gql 34.2.0 → 35.0.0

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": "oradm-to-gql",
3
- "version": "34.2.0",
3
+ "version": "35.0.0",
4
4
  "description": "Oracle Data Modeler CSV Export to Apollo GraphQL Endpoint Generator",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -0,0 +1,20 @@
1
+ const { each } = require("lodash");
2
+
3
+ function defaultBooleans(tableMap) {
4
+ each(tableMap, (tableDef) => {
5
+ if (tableDef.type !== "view") {
6
+ each(tableDef.attributes, (attrDef, attrName) => {
7
+ if (attrDef.dataType === "Boolean") {
8
+ attrDef.nullable = false;
9
+ if (!attrDef.defaultValue) {
10
+ attrDef.defaultValue = false;
11
+ }
12
+ }
13
+ });
14
+ }
15
+ });
16
+
17
+ return tableMap;
18
+ }
19
+
20
+ module.exports = { defaultBooleans };
@@ -7,6 +7,7 @@ const addTimestampColumns = require("./addTimestampColumns");
7
7
  const { addIndexes } = require("./addIndexes");
8
8
  const { processViews } = require("./views");
9
9
  const { mergeCommonTableMap } = require("./mergeCommonTableMap");
10
+ const { defaultBooleans } = require("./defaultBooleans");
10
11
 
11
12
  module.exports = function parseDatamodelCSV(
12
13
  csvPath,
@@ -46,6 +47,7 @@ module.exports = function parseDatamodelCSV(
46
47
  }
47
48
 
48
49
  tableMap = addIndexes(tableMap, opts);
50
+ tableMap = defaultBooleans(tableMap, opts);
49
51
  tableMap = applyNamingRules(tableMap, opts);
50
52
  tableMap = processViews(tableMap, opts);
51
53
  tableMap = populateRelationshipAttributes(tableMap, opts);
@@ -45,10 +45,17 @@ function createTables(db, tableSpecs, opts = {}) {
45
45
  if (colSpec.unique) {
46
46
  table.unique(colSpec.name);
47
47
  }
48
- if (colSpec.defaultValue) {
48
+ if (colSpec.type === "boolean") {
49
+ colSpec.defaultValue = colSpec.defaultValue || false;
50
+ }
51
+ if (colSpec.defaultValue || colSpec.defaultValue === false) {
49
52
  let defaultValue = colSpec.defaultValue;
50
53
  if (colSpec.type === "boolean") {
51
- if (defaultValue === "false" || defaultValue === "0") {
54
+ if (
55
+ defaultValue === "false" ||
56
+ defaultValue === "0" ||
57
+ defaultValue === false
58
+ ) {
52
59
  defaultValue = false;
53
60
  } else {
54
61
  defaultValue = true;