sqlmorpheus 0.2.2 → 0.2.3

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/dist/index.js CHANGED
@@ -82,10 +82,12 @@ var TableObj = class _TableObj {
82
82
  if (value instanceof Date) {
83
83
  dataType = "date";
84
84
  break;
85
- } else {
85
+ } else if (value !== null) {
86
86
  Logger.warn(`${key} was skipped because its type (${typeof value}) is not supported`);
87
87
  return null;
88
88
  }
89
+ dataType = "string";
90
+ break;
89
91
  case "undefined":
90
92
  case "symbol":
91
93
  Logger.warn(`${key} was skipped because its type (${typeof value}) is not supported`);
@@ -124,7 +126,7 @@ var TableObj = class _TableObj {
124
126
  return this;
125
127
  }
126
128
  dataType(column, type) {
127
- this.tableStructure.columns[column.toString()].type = type;
129
+ this.tableStructure.columns[column.toString()].inputType = type;
128
130
  return this;
129
131
  }
130
132
  maxCharacterLength(column, max) {
@@ -178,17 +180,19 @@ var TableStructureGenerator = class {
178
180
  generateTableStructure() {
179
181
  const tables = {};
180
182
  for (const table of this.dbInstructions.tables) {
183
+ let structure;
181
184
  if (TableObj.isTableObj(table)) {
185
+ structure = table.tableStructure;
182
186
  tables[table.tableName] = table.tableStructure;
183
187
  } else {
184
188
  const classTable = table;
185
- const structure = getTableStructure(classTable);
186
- tables[classTable.name] = structure;
187
- for (const key in structure.columns) {
188
- const entry = structure.columns[key];
189
- entry.defaultValue = entry.defaultValue === null ? this.dialect.types.null : this.dialect.formatValueToSql(entry.inputDefaultValue, entry.inputType);
190
- entry.type = this.dialect.getSqlType(entry.inputType, entry);
191
- }
189
+ structure = getTableStructure(classTable);
190
+ tables[classTable.name] = getTableStructure(classTable);
191
+ }
192
+ for (const key in structure.columns) {
193
+ const entry = structure.columns[key];
194
+ entry.defaultValue = entry.inputDefaultValue === null ? this.dialect.types.null : this.dialect.formatValueToSql(entry.inputDefaultValue, entry.inputType);
195
+ entry.type = this.dialect.getSqlType(entry.inputType, entry);
192
196
  }
193
197
  }
194
198
  return tables;
package/dist/index.mjs CHANGED
@@ -48,10 +48,12 @@ var TableObj = class _TableObj {
48
48
  if (value instanceof Date) {
49
49
  dataType = "date";
50
50
  break;
51
- } else {
51
+ } else if (value !== null) {
52
52
  Logger.warn(`${key} was skipped because its type (${typeof value}) is not supported`);
53
53
  return null;
54
54
  }
55
+ dataType = "string";
56
+ break;
55
57
  case "undefined":
56
58
  case "symbol":
57
59
  Logger.warn(`${key} was skipped because its type (${typeof value}) is not supported`);
@@ -90,7 +92,7 @@ var TableObj = class _TableObj {
90
92
  return this;
91
93
  }
92
94
  dataType(column, type) {
93
- this.tableStructure.columns[column.toString()].type = type;
95
+ this.tableStructure.columns[column.toString()].inputType = type;
94
96
  return this;
95
97
  }
96
98
  maxCharacterLength(column, max) {
@@ -144,17 +146,19 @@ var TableStructureGenerator = class {
144
146
  generateTableStructure() {
145
147
  const tables = {};
146
148
  for (const table of this.dbInstructions.tables) {
149
+ let structure;
147
150
  if (TableObj.isTableObj(table)) {
151
+ structure = table.tableStructure;
148
152
  tables[table.tableName] = table.tableStructure;
149
153
  } else {
150
154
  const classTable = table;
151
- const structure = getTableStructure(classTable);
152
- tables[classTable.name] = structure;
153
- for (const key in structure.columns) {
154
- const entry = structure.columns[key];
155
- entry.defaultValue = entry.defaultValue === null ? this.dialect.types.null : this.dialect.formatValueToSql(entry.inputDefaultValue, entry.inputType);
156
- entry.type = this.dialect.getSqlType(entry.inputType, entry);
157
- }
155
+ structure = getTableStructure(classTable);
156
+ tables[classTable.name] = getTableStructure(classTable);
157
+ }
158
+ for (const key in structure.columns) {
159
+ const entry = structure.columns[key];
160
+ entry.defaultValue = entry.inputDefaultValue === null ? this.dialect.types.null : this.dialect.formatValueToSql(entry.inputDefaultValue, entry.inputType);
161
+ entry.type = this.dialect.getSqlType(entry.inputType, entry);
158
162
  }
159
163
  }
160
164
  return tables;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sqlmorpheus",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "author": "JodliDev",
5
5
  "keywords": [],
6
6
  "license": "MIT",