mm_mysql 1.6.7 → 1.6.8
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/db.js +8 -1
- package/package.json +1 -1
- package/test.js +110 -104
package/db.js
CHANGED
|
@@ -221,7 +221,14 @@ DB.prototype.setType = function(field, type, value, not_null, auto) {
|
|
|
221
221
|
type += " DEFAULT 0";
|
|
222
222
|
}
|
|
223
223
|
break;
|
|
224
|
+
case "longtext":
|
|
224
225
|
case "text":
|
|
226
|
+
if (type == "text") {
|
|
227
|
+
type = "text NULL"
|
|
228
|
+
}
|
|
229
|
+
else if (type == "longtext") {
|
|
230
|
+
type = "longtext NULL"
|
|
231
|
+
}
|
|
225
232
|
break;
|
|
226
233
|
default:
|
|
227
234
|
if (type.indexOf('var') !== -1) {
|
|
@@ -340,7 +347,7 @@ DB.prototype.field_set = async function(field, type, value, not_null, auto, isKe
|
|
|
340
347
|
|
|
341
348
|
var type = this.setType(field, type, value, not_null, auto);
|
|
342
349
|
if (type.has('text')) {
|
|
343
|
-
type = type.replace('NOT NULL', '');
|
|
350
|
+
type = type.replace('NOT NULL', '').replace("DEFAULT ''", "");
|
|
344
351
|
}
|
|
345
352
|
|
|
346
353
|
if (!new_name) {
|
package/package.json
CHANGED
package/test.js
CHANGED
|
@@ -88,111 +88,117 @@ sql.open();
|
|
|
88
88
|
// }
|
|
89
89
|
// test_tpl_get();
|
|
90
90
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
//
|
|
98
|
-
//
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
//
|
|
105
|
-
//
|
|
106
|
-
//
|
|
107
|
-
//
|
|
108
|
-
//
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
91
|
+
async function addField() {
|
|
92
|
+
var sql = new Mysql();
|
|
93
|
+
sql.open();
|
|
94
|
+
db = sql.db();
|
|
95
|
+
var num = 0;
|
|
96
|
+
db.table = 'test';
|
|
97
|
+
// num = await db.field_del('set6');
|
|
98
|
+
// num = await db.field_add('set6', 'str');
|
|
99
|
+
var bl = await db.addTable('test', 'uid', 'int', true, '测试表');
|
|
100
|
+
console.log("创建表:" + num);
|
|
101
|
+
if (bl < 0) {
|
|
102
|
+
console.log("SQL:" + db.sql);
|
|
103
|
+
}
|
|
104
|
+
// num = await db.field_add("uid", 'int', 0, true, true, true);
|
|
105
|
+
// console.log("uid结果:" + num);
|
|
106
|
+
// if (num < 0) {
|
|
107
|
+
// console.log("SQL:" + db.sql);
|
|
108
|
+
// }
|
|
109
|
+
|
|
110
|
+
num = await db.field_add("name", 'varchar(18)', '', true);
|
|
111
|
+
console.log("name结果:" + num);
|
|
112
|
+
if (num < 0) {
|
|
113
|
+
console.log("SQL:" + db.sql);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
num = await db.field_add("username", 'varchar(18)', '', true);
|
|
117
|
+
console.log("username结果:" + num);
|
|
118
|
+
if (num < 0) {
|
|
119
|
+
console.log("SQL:" + db.sql);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
num = await db.field_add("password", 'string', '', true);
|
|
123
|
+
console.log("password结果:" + num);
|
|
124
|
+
if (num < 0) {
|
|
125
|
+
console.log("SQL:" + db.sql);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
num = await db.field_add("email", 'varchar', null);
|
|
129
|
+
console.log("email结果:" + num);
|
|
130
|
+
if (num < 0) {
|
|
131
|
+
console.log("SQL:" + db.sql);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
num = await db.field_add("age", 'smallint', 0);
|
|
135
|
+
console.log("age结果:" + num);
|
|
136
|
+
if (num < 0) {
|
|
137
|
+
console.log("SQL:" + db.sql);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
num = await db.field_add("sex", 'tinyint', 0);
|
|
141
|
+
console.log("sex结果:" + num);
|
|
142
|
+
if (num < 0) {
|
|
143
|
+
console.log("SQL:" + db.sql);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
num = await db.field_add("create_time", 'timestamp', null, true, true);
|
|
147
|
+
console.log("create_time结果:" + num);
|
|
148
|
+
if (num < 0) {
|
|
149
|
+
console.log("SQL:" + db.sql);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
num = await db.field_add("update_time", 'timestamp', null, true, true);
|
|
153
|
+
console.log("update_time结果:" + num);
|
|
154
|
+
if (num < 0) {
|
|
155
|
+
console.log("SQL:" + db.sql);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
num = await db.field_add("last_time", 'timestamp');
|
|
159
|
+
console.log("last_time结果:" + num);
|
|
160
|
+
if (num < 0) {
|
|
161
|
+
console.log("SQL:" + db.sql);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
num = await db.field_add("birthday", 'date', '2020-06-28', true);
|
|
165
|
+
console.log("birthday结果:" + num);
|
|
166
|
+
if (num < 0) {
|
|
167
|
+
console.log("SQL:" + db.sql);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
num = await db.field_add("note", 'text', '123123', false);
|
|
171
|
+
console.log("note结果:" + num);
|
|
172
|
+
if (num < 0) {
|
|
173
|
+
console.log("SQL:" + db.sql);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
num = await db.field_add("content", 'longtext', '123123', false);
|
|
177
|
+
console.log("content结果:" + num);
|
|
178
|
+
if (num < 0) {
|
|
179
|
+
console.log("SQL:" + db.sql);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
num = await db.field_add("cycle", 'time', null, true);
|
|
183
|
+
console.log("cycle结果:" + num);
|
|
184
|
+
if (num < 0) {
|
|
185
|
+
console.log("SQL:" + db.sql);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
num = await db.field_add("money", 'double', 0);
|
|
189
|
+
console.log("money结果:" + num);
|
|
190
|
+
if (num < 0) {
|
|
191
|
+
console.log("SQL:" + db.sql);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
num = await db.field_add("like", 'string', '篮球 足球 乒乓球');
|
|
195
|
+
console.log("like结果:" + num);
|
|
196
|
+
if (num < 0) {
|
|
197
|
+
console.log("SQL:" + db.sql);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
194
200
|
|
|
195
|
-
|
|
201
|
+
addField();
|
|
196
202
|
|
|
197
203
|
|
|
198
204
|
// async function test() {
|