@itrocks/schema-to-mysql 0.1.0 → 0.1.2

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.
@@ -59,6 +59,10 @@ class SchemaToMysql {
59
59
  const name = type.name;
60
60
  let typeSql;
61
61
  switch (name) {
62
+ case 'boolean':
63
+ typeSql = 'tinyint';
64
+ type.signed = false;
65
+ break;
62
66
  case 'decimal':
63
67
  typeSql = 'decimal(' + type.length + ',' + type.precision + ')';
64
68
  break;
@@ -66,16 +70,16 @@ class SchemaToMysql {
66
70
  const maxValue = type.maxValue;
67
71
  if (maxValue !== undefined) {
68
72
  if (type.signed) {
69
- typeSql = (maxValue > 2_147_483_647) ? 'bigint'
70
- : (maxValue > 8_388_607) ? 'int'
71
- : (maxValue > 32_767) ? 'mediumint'
73
+ typeSql = (maxValue > 2147483647) ? 'bigint'
74
+ : (maxValue > 8388607) ? 'int'
75
+ : (maxValue > 32767) ? 'mediumint'
72
76
  : (maxValue > 127) ? 'smallint'
73
77
  : 'tinyint';
74
78
  }
75
79
  else {
76
- typeSql = (maxValue > 4_294_967_295) ? 'bigint'
77
- : (maxValue > 16_777_215) ? 'int'
78
- : (maxValue > 65_535) ? 'mediumint'
80
+ typeSql = (maxValue > 4294967295) ? 'bigint'
81
+ : (maxValue > 16777215) ? 'int'
82
+ : (maxValue > 65535) ? 'mediumint'
79
83
  : (maxValue > 255) ? 'smallint'
80
84
  : 'tinyint';
81
85
  }
@@ -91,8 +95,8 @@ class SchemaToMysql {
91
95
  break;
92
96
  case 'string':
93
97
  typeSql = (length === undefined) ? 'longtext'
94
- : (length > 16_777_215) ? 'longtext'
95
- : (length > 65_535) ? 'mediumtext'
98
+ : (length > 16777215) ? 'longtext'
99
+ : (length > 65535) ? 'mediumtext'
96
100
  : (length > 255) ? 'text'
97
101
  : ((type.variableLength ? 'var' : '') + 'char(' + length + ')');
98
102
  break;
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  },
9
9
  "description": "Converts a table schema into MySQL statements for table creation",
10
10
  "devDependencies": {
11
- "typescript": "^6.0"
11
+ "typescript": "^7.0"
12
12
  },
13
13
  "engines": {
14
14
  "node": ">=24"
@@ -50,5 +50,5 @@
50
50
  "scripts": {
51
51
  "build": "tsc"
52
52
  },
53
- "version": "0.1.0"
53
+ "version": "0.1.2"
54
54
  }