typesql-cli 0.5.18 → 0.6.1

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.
Files changed (41) hide show
  1. package/code-generator.js +2 -2
  2. package/code-generator.js.map +1 -1
  3. package/describe-query.d.ts +1 -1
  4. package/describe-query.d.ts.map +1 -1
  5. package/describe-query.js +2 -3
  6. package/describe-query.js.map +1 -1
  7. package/mysql-query-analyzer/collect-constraints.d.ts +22 -49
  8. package/mysql-query-analyzer/collect-constraints.d.ts.map +1 -1
  9. package/mysql-query-analyzer/collect-constraints.js +39 -1757
  10. package/mysql-query-analyzer/collect-constraints.js.map +1 -1
  11. package/mysql-query-analyzer/infer-column-nullability.d.ts +3 -3
  12. package/mysql-query-analyzer/infer-column-nullability.d.ts.map +1 -1
  13. package/mysql-query-analyzer/infer-column-nullability.js +8 -25
  14. package/mysql-query-analyzer/infer-column-nullability.js.map +1 -1
  15. package/mysql-query-analyzer/infer-param-nullability.d.ts +3 -1
  16. package/mysql-query-analyzer/infer-param-nullability.d.ts.map +1 -1
  17. package/mysql-query-analyzer/infer-param-nullability.js +21 -3
  18. package/mysql-query-analyzer/infer-param-nullability.js.map +1 -1
  19. package/mysql-query-analyzer/parse.d.ts +10 -10
  20. package/mysql-query-analyzer/parse.d.ts.map +1 -1
  21. package/mysql-query-analyzer/parse.js +126 -184
  22. package/mysql-query-analyzer/parse.js.map +1 -1
  23. package/mysql-query-analyzer/select-columns.d.ts +8 -9
  24. package/mysql-query-analyzer/select-columns.d.ts.map +1 -1
  25. package/mysql-query-analyzer/select-columns.js +26 -226
  26. package/mysql-query-analyzer/select-columns.js.map +1 -1
  27. package/mysql-query-analyzer/traverse.d.ts +46 -0
  28. package/mysql-query-analyzer/traverse.d.ts.map +1 -0
  29. package/mysql-query-analyzer/traverse.js +1605 -0
  30. package/mysql-query-analyzer/traverse.js.map +1 -0
  31. package/mysql-query-analyzer/types.d.ts +34 -5
  32. package/mysql-query-analyzer/types.d.ts.map +1 -1
  33. package/mysql-query-analyzer/unify.d.ts +4 -3
  34. package/mysql-query-analyzer/unify.d.ts.map +1 -1
  35. package/mysql-query-analyzer/unify.js +540 -48
  36. package/mysql-query-analyzer/unify.js.map +1 -1
  37. package/mysql-query-analyzer/verify-multiple-result.js +1 -1
  38. package/mysql-query-analyzer/verify-multiple-result.js.map +1 -1
  39. package/package.json +1 -1
  40. package/types.d.ts +2 -2
  41. package/types.d.ts.map +1 -1
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.substitute = exports.unify = void 0;
3
+ exports.unionTypeResult = exports.substitute = exports.unify = void 0;
4
4
  function unify(constraints, substitutions) {
5
5
  for (const constraint of constraints) {
6
6
  unifyOne(constraint, substitutions);
@@ -8,8 +8,8 @@ function unify(constraints, substitutions) {
8
8
  }
9
9
  exports.unify = unify;
10
10
  function unifyOne(constraint, substitutions) {
11
- const ty1 = substitute(constraint.type1, substitutions);
12
- const ty2 = substitute(constraint.type2, substitutions);
11
+ const ty1 = substitute(constraint.type1, substitutions, constraint);
12
+ const ty2 = substitute(constraint.type2, substitutions, constraint);
13
13
  if (ty1.kind == 'TypeOperator' && ty2.kind == 'TypeOperator') {
14
14
  ty1.types.forEach((t, i) => {
15
15
  const newConstr = {
@@ -21,46 +21,43 @@ function unifyOne(constraint, substitutions) {
21
21
  });
22
22
  }
23
23
  else if (ty1.kind == 'TypeVar' && ty2.kind == 'TypeVar') {
24
- if (ty1.id == ty2.id)
25
- return;
24
+ // if (ty1.id == ty2.id) return;
26
25
  if (ty1.type != '?') {
27
26
  if (ty2.type != '?') {
28
27
  const bestType = getBestPossibleType(ty1.type, ty2.type, constraint.mostGeneralType, constraint.coercionType);
29
- ty1.type = bestType;
30
- ty2.type = bestType;
31
- setSubstitution(ty1, ty2, substitutions);
32
- setSubstitution(ty2, ty1, substitutions);
28
+ substitutions[ty1.id] = Object.assign(Object.assign({}, ty1), { type: bestType });
33
29
  }
34
30
  else {
35
- const numberTypes = ['number', 'tinyint', 'int', 'bigint', 'decimal', 'double'];
36
- if (constraint.coercionType == 'Sum' && numberTypes.indexOf(ty1.type) >= 0) {
37
- //In the expression ty1 + ?, ty2 = double
38
- ty1.type = 'double';
39
- ty2.type = 'double';
31
+ //type2 = ?
32
+ let newType = ty1.type;
33
+ if (constraint.coercionType == 'Sum') {
34
+ newType = 'double';
40
35
  }
41
- substitutions[ty2.id] = ty1;
36
+ if (constraint.coercionType == 'Coalesce') {
37
+ newType = 'any';
38
+ }
39
+ substitutions[ty2.id] = Object.assign(Object.assign({}, ty1), { list: ty2.list, type: newType });
40
+ substitutions[ty1.id] = Object.assign(Object.assign({}, ty1), { list: ty2.list, type: newType });
42
41
  }
43
42
  }
44
43
  else {
45
- //THEN ? ELSE id; ? will be double; or ? will be int if commented
46
- // const numberTypes = ['number', 'tinyint', 'int', 'bigint', 'decimal', 'double']
47
- // if(!constraint.strict && numberTypes.indexOf(ty2.type) >= 0) {
48
- // ty2.type = 'number';
49
- // }
44
+ ty2.list = ty1.list;
50
45
  if (constraint.coercionType == 'SumFunction') {
51
- const exactValueNumbers = ['int', 'bigint', 'decimal'];
52
- if (exactValueNumbers.indexOf(ty2.type) >= 0) {
53
- ty2.type = 'decimal';
54
- }
55
- else {
56
- ty2.type = 'double';
57
- }
46
+ const bestType = getSumFunctionType(ty2.type);
47
+ substitutions[ty1.id] = Object.assign(Object.assign({}, ty2), { type: bestType });
48
+ substitutions[ty2.id] = Object.assign(Object.assign({}, ty2), { type: bestType });
49
+ }
50
+ else if (constraint.coercionType == 'Sum') {
51
+ const bestType = getSumType(ty2.type);
52
+ substitutions[ty1.id] = Object.assign(Object.assign({}, ty2), { type: bestType });
53
+ substitutions[ty2.id] = Object.assign(Object.assign({}, ty2), { type: bestType });
54
+ }
55
+ else {
56
+ substitutions[ty1.id] = Object.assign({}, ty2);
58
57
  }
59
- substitutions[ty1.id] = ty2;
60
- ty1.type = ty2.type;
61
- ty2.list = ty1.list;
62
58
  }
63
59
  }
60
+ //todo - remove
64
61
  else if (ty1.kind == 'TypeVar' && ty2.kind == 'TypeOperator') {
65
62
  ty2.types.forEach(t => {
66
63
  const listType = t;
@@ -74,21 +71,45 @@ function unifyOne(constraint, substitutions) {
74
71
  unifyOne(newConstraint, substitutions);
75
72
  }
76
73
  }
77
- function setSubstitution(ty1, ty2, substitutions) {
78
- const subs = substitutions[ty1.id];
79
- substitutions[ty1.id] = ty2;
80
- if (subs && subs.id != ty2.id) {
81
- subs.type = ty2.type;
82
- // if(ty2.list) subs.list = true;
83
- setSubstitution(subs, ty2, substitutions);
74
+ function getSumType(type) {
75
+ const exactValueNumbers = ['int'];
76
+ if (exactValueNumbers.indexOf(type) >= 0) {
77
+ return 'bigint';
78
+ }
79
+ const dateTypes = ['date'];
80
+ if (dateTypes.indexOf(type) >= 0) {
81
+ return 'date';
82
+ }
83
+ return 'number';
84
+ }
85
+ function getSumFunctionType(type) {
86
+ const exactValueNumbers = ['int', 'bigint', 'decimal'];
87
+ if (exactValueNumbers.indexOf(type) >= 0) {
88
+ return 'decimal';
89
+ }
90
+ else {
91
+ return 'double';
84
92
  }
85
93
  }
86
94
  function getBestPossibleType(type1, type2, max, coercionType) {
87
- if (coercionType == 'Ceiling' && (type2 == 'decimal' || type1 == 'decimal')) { //ceiling(decimal) returns bigint
95
+ if (coercionType == 'Union') {
96
+ const unionType = unionTypeResult(type1, type2);
97
+ return unionType;
98
+ }
99
+ if (coercionType == 'SumFunction') {
100
+ const exactValueNumbers = ['int', 'bigint', 'decimal'];
101
+ if (exactValueNumbers.indexOf(type2) >= 0) {
102
+ return 'decimal';
103
+ }
104
+ else {
105
+ return 'double';
106
+ }
107
+ }
108
+ if (coercionType == 'Ceiling' && (type1 == 'decimal' || type2 == 'decimal')) { //ceiling(decimal) returns bigint
88
109
  return 'bigint';
89
110
  }
90
111
  if (type1 == 'any') {
91
- return coercionType == 'Coalesce' ? 'any' : type2;
112
+ return coercionType == 'Coalesce' ? type2 : type2;
92
113
  }
93
114
  if (type2 == 'any') {
94
115
  return coercionType == 'Coalesce' ? 'any' : type1;
@@ -97,24 +118,32 @@ function getBestPossibleType(type1, type2, max, coercionType) {
97
118
  return type1;
98
119
  if (coercionType == 'Sum' && max && type1 == 'number' && type2 == 'int' || type1 == 'int' && type2 == 'number')
99
120
  return 'double';
100
- // if( coercionType == 'Sum' && type1 == 'number' && type2 == 'bigint' || type1 == 'bigint' && type2 == 'number') return 'double';
101
121
  if (coercionType == 'Sum' && max && type1 == 'int' && type2 == 'int')
102
122
  return 'bigint';
103
123
  if (coercionType == 'Sum' && max && ((type1 == 'int' && type2 == 'double') || type1 == 'double' && type2 == 'int'))
104
124
  return 'double';
105
125
  if (coercionType == 'Sum' && max && ((type1 == 'bigint' && type2 == 'double') || type1 == 'double' && type2 == 'bigint'))
106
126
  return 'double';
107
- //if( sum && (type1 == 'decimal' && type2 == 'number') || type1 == 'number' && type2 == 'decimal' ) return 'double';
108
127
  if (coercionType == 'Sum' && max && type1 == 'date' && type2 == 'date')
109
128
  return 'bigint';
110
- const order = ['number', 'tinyint', 'smallint', 'int', 'bigint', 'decimal', 'float', 'double'];
129
+ if (coercionType == 'Sum' && type1 == 'int' && type2 == 'int')
130
+ return 'bigint';
131
+ //enum
132
+ if (type1 == type2) {
133
+ return type1;
134
+ }
135
+ const order = ['number', 'tinyint', 'smallint', 'int', 'bigint', 'decimal', 'float', 'double', 'varchar'];
111
136
  const indexType1 = order.indexOf(type1);
112
137
  const indexType2 = order.indexOf(type2);
113
138
  if (indexType1 != -1 && indexType2 != -1) {
114
139
  const index = max ? Math.max(indexType1, indexType2) : Math.min(indexType1, indexType2);
115
- return order[index];
140
+ const resultType = order[index];
141
+ if (resultType == 'varchar' && coercionType == 'Numeric') {
142
+ throw Error('Type mismatch: ' + type1 + ' and ' + type2);
143
+ }
144
+ return resultType;
116
145
  }
117
- const order2 = ['varchar'];
146
+ const order2 = ['char', 'varchar', 'tinytext', 'mediumtext', 'text', 'longtext'];
118
147
  const indexStrType1 = order2.indexOf(type1);
119
148
  const indexStrType2 = order2.indexOf(type2);
120
149
  if (indexStrType1 != -1 && indexStrType2 != -1) {
@@ -139,20 +168,483 @@ function getBestPossibleType(type1, type2, max, coercionType) {
139
168
  }
140
169
  throw Error('Type mismatch: ' + type1 + ' and ' + type2);
141
170
  }
142
- function substitute(type, substitutions) {
171
+ function substitute(type, substitutions, constraint) {
143
172
  if (type.kind == 'TypeVar' && type.type != '?') {
173
+ const subs = substitutions[type.id];
174
+ if (subs) {
175
+ if (type.id != subs.id) {
176
+ return substitute(subs, substitutions, constraint);
177
+ }
178
+ return subs;
179
+ }
144
180
  return type;
145
181
  }
146
182
  if (type.kind == 'TypeVar' && type.type == '?') {
147
183
  const subs = substitutions[type.id];
148
184
  if (subs) {
149
- if (type.list && subs.kind == 'TypeVar')
150
- subs.list;
151
- return substitute(subs, substitutions);
185
+ if (type.id != subs.id) {
186
+ return substitute(subs, substitutions, constraint);
187
+ }
188
+ return subs;
152
189
  }
153
190
  return type;
154
191
  }
155
192
  return type;
156
193
  }
157
194
  exports.substitute = substitute;
195
+ function unionTypeResult(type1, type2) {
196
+ //Gernerated with tests\check-mysql-inference.ts
197
+ const typeMapping = {
198
+ "number_int": "int",
199
+ "bigint_number": "bigint",
200
+ "decimal_tinyint": "decimal",
201
+ "decimal_smallint": "decimal",
202
+ "decimal_int": "decimal",
203
+ "decimal_float": "double",
204
+ "decimal_double": "double",
205
+ "decimal_timestamp": "varchar",
206
+ "decimal_bigint": "decimal",
207
+ "decimal_mediumint": "decimal",
208
+ "decimal_date": "varchar",
209
+ "decimal_time": "varchar",
210
+ "decimal_datetime": "varchar",
211
+ "decimal_year": "decimal",
212
+ "decimal_varchar": "varchar",
213
+ "decimal_bit": "decimal",
214
+ "decimal_json": "varbinary",
215
+ "decimal_enum": "varchar",
216
+ "decimal_set": "varchar",
217
+ "decimal_tinyblob": "text",
218
+ "decimal_mediumblob": "text",
219
+ "decimal_longblob": "longtext",
220
+ "decimal_blob": "text",
221
+ "decimal_tinytext": "text",
222
+ "decimal_mediumtext": "text",
223
+ "decimal_longtext": "longtext",
224
+ "decimal_text": "text",
225
+ "decimal_varbinary": "varbinary",
226
+ "decimal_binary": "binary",
227
+ "decimal_char": "binary",
228
+ "decimal_geometry": "varbinary",
229
+ "tinyint_smallint": "smallint",
230
+ "tinyint_int": "int",
231
+ "tinyint_float": "float",
232
+ "tinyint_double": "double",
233
+ "tinyint_timestamp": "varchar",
234
+ "tinyint_bigint": "bigint",
235
+ "tinyint_mediumint": "mediumint",
236
+ "tinyint_date": "varchar",
237
+ "tinyint_time": "varchar",
238
+ "tinyint_datetime": "varchar",
239
+ "tinyint_year": "tinyint",
240
+ "tinyint_varchar": "varchar",
241
+ "tinyint_bit": "decimal",
242
+ "tinyint_json": "varbinary",
243
+ "tinyint_enum": "varchar",
244
+ "tinyint_set": "varchar",
245
+ "tinyint_tinyblob": "text",
246
+ "tinyint_mediumblob": "text",
247
+ "tinyint_longblob": "longtext",
248
+ "tinyint_blob": "text",
249
+ "tinyint_tinytext": "text",
250
+ "tinyint_mediumtext": "text",
251
+ "tinyint_longtext": "longtext",
252
+ "tinyint_text": "text",
253
+ "tinyint_varbinary": "varbinary",
254
+ "tinyint_binary": "binary",
255
+ "tinyint_char": "binary",
256
+ "tinyint_geometry": "varbinary",
257
+ "smallint_int": "int",
258
+ "smallint_float": "float",
259
+ "smallint_double": "double",
260
+ "smallint_timestamp": "varchar",
261
+ "smallint_bigint": "bigint",
262
+ "smallint_mediumint": "mediumint",
263
+ "smallint_date": "varchar",
264
+ "smallint_time": "varchar",
265
+ "smallint_datetime": "varchar",
266
+ "smallint_year": "smallint",
267
+ "smallint_varchar": "varchar",
268
+ "smallint_bit": "decimal",
269
+ "smallint_json": "varbinary",
270
+ "smallint_enum": "varchar",
271
+ "smallint_set": "varchar",
272
+ "smallint_tinyblob": "text",
273
+ "smallint_mediumblob": "text",
274
+ "smallint_longblob": "longtext",
275
+ "smallint_blob": "text",
276
+ "smallint_tinytext": "text",
277
+ "smallint_mediumtext": "text",
278
+ "smallint_longtext": "longtext",
279
+ "smallint_text": "text",
280
+ "smallint_varbinary": "varbinary",
281
+ "smallint_binary": "binary",
282
+ "smallint_char": "binary",
283
+ "smallint_geometry": "varbinary",
284
+ "int_float": "double",
285
+ "int_double": "double",
286
+ "int_timestamp": "varchar",
287
+ "int_bigint": "bigint",
288
+ "int_mediumint": "int",
289
+ "int_date": "varchar",
290
+ "int_time": "varchar",
291
+ "int_datetime": "varchar",
292
+ "int_year": "int",
293
+ "int_varchar": "varchar",
294
+ "int_bit": "decimal",
295
+ "int_json": "varbinary",
296
+ "int_enum": "varchar",
297
+ "int_set": "varchar",
298
+ "int_tinyblob": "text",
299
+ "int_mediumblob": "text",
300
+ "int_longblob": "longtext",
301
+ "int_blob": "text",
302
+ "int_tinytext": "text",
303
+ "int_mediumtext": "text",
304
+ "int_longtext": "longtext",
305
+ "int_text": "text",
306
+ "int_varbinary": "varbinary",
307
+ "int_binary": "binary",
308
+ "int_char": "binary",
309
+ "int_geometry": "varbinary",
310
+ "float_double": "double",
311
+ "float_timestamp": "varchar",
312
+ "float_bigint": "float",
313
+ "float_mediumint": "float",
314
+ "float_date": "varchar",
315
+ "float_time": "varchar",
316
+ "float_datetime": "varchar",
317
+ "float_year": "float",
318
+ "float_varchar": "varchar",
319
+ "float_bit": "double",
320
+ "float_json": "varbinary",
321
+ "float_enum": "varchar",
322
+ "float_set": "varchar",
323
+ "float_tinyblob": "text",
324
+ "float_mediumblob": "text",
325
+ "float_longblob": "longtext",
326
+ "float_blob": "text",
327
+ "float_tinytext": "text",
328
+ "float_mediumtext": "text",
329
+ "float_longtext": "longtext",
330
+ "float_text": "text",
331
+ "float_varbinary": "varbinary",
332
+ "float_binary": "binary",
333
+ "float_char": "binary",
334
+ "float_geometry": "varbinary",
335
+ "double_timestamp": "varchar",
336
+ "double_bigint": "double",
337
+ "double_mediumint": "double",
338
+ "double_date": "varchar",
339
+ "double_time": "varchar",
340
+ "double_datetime": "varchar",
341
+ "double_year": "double",
342
+ "double_varchar": "varchar",
343
+ "double_bit": "double",
344
+ "double_json": "varbinary",
345
+ "double_enum": "varchar",
346
+ "double_set": "varchar",
347
+ "double_tinyblob": "text",
348
+ "double_mediumblob": "text",
349
+ "double_longblob": "longtext",
350
+ "double_blob": "text",
351
+ "double_tinytext": "text",
352
+ "double_mediumtext": "text",
353
+ "double_longtext": "longtext",
354
+ "double_text": "text",
355
+ "double_varbinary": "varbinary",
356
+ "double_binary": "binary",
357
+ "double_char": "binary",
358
+ "double_geometry": "varbinary",
359
+ "timestamp_bigint": "varchar",
360
+ "timestamp_mediumint": "varchar",
361
+ "timestamp_date": "datetime",
362
+ "timestamp_time": "datetime",
363
+ "timestamp_datetime": "datetime",
364
+ "timestamp_year": "varchar",
365
+ "timestamp_varchar": "varchar",
366
+ "timestamp_bit": "varbinary",
367
+ "timestamp_json": "varbinary",
368
+ "timestamp_enum": "varchar",
369
+ "timestamp_set": "varchar",
370
+ "timestamp_tinyblob": "text",
371
+ "timestamp_mediumblob": "text",
372
+ "timestamp_longblob": "longtext",
373
+ "timestamp_blob": "text",
374
+ "timestamp_tinytext": "text",
375
+ "timestamp_mediumtext": "text",
376
+ "timestamp_longtext": "longtext",
377
+ "timestamp_text": "text",
378
+ "timestamp_varbinary": "varbinary",
379
+ "timestamp_binary": "binary",
380
+ "timestamp_char": "binary",
381
+ "timestamp_geometry": "varbinary",
382
+ "bigint_mediumint": "bigint",
383
+ "bigint_date": "varchar",
384
+ "bigint_time": "varchar",
385
+ "bigint_datetime": "varchar",
386
+ "bigint_year": "bigint",
387
+ "bigint_varchar": "varchar",
388
+ "bigint_bit": "decimal",
389
+ "bigint_json": "varbinary",
390
+ "bigint_enum": "varchar",
391
+ "bigint_set": "varchar",
392
+ "bigint_tinyblob": "text",
393
+ "bigint_mediumblob": "text",
394
+ "bigint_longblob": "longtext",
395
+ "bigint_blob": "text",
396
+ "bigint_tinytext": "text",
397
+ "bigint_mediumtext": "text",
398
+ "bigint_longtext": "longtext",
399
+ "bigint_text": "text",
400
+ "bigint_varbinary": "varbinary",
401
+ "bigint_binary": "binary",
402
+ "bigint_char": "binary",
403
+ "bigint_geometry": "varbinary",
404
+ "mediumint_date": "varchar",
405
+ "mediumint_time": "varchar",
406
+ "mediumint_datetime": "varchar",
407
+ "mediumint_year": "mediumint",
408
+ "mediumint_varchar": "varchar",
409
+ "mediumint_bit": "decimal",
410
+ "mediumint_json": "varbinary",
411
+ "mediumint_enum": "varchar",
412
+ "mediumint_set": "varchar",
413
+ "mediumint_tinyblob": "text",
414
+ "mediumint_mediumblob": "text",
415
+ "mediumint_longblob": "longtext",
416
+ "mediumint_blob": "text",
417
+ "mediumint_tinytext": "text",
418
+ "mediumint_mediumtext": "text",
419
+ "mediumint_longtext": "longtext",
420
+ "mediumint_text": "text",
421
+ "mediumint_varbinary": "varbinary",
422
+ "mediumint_binary": "binary",
423
+ "mediumint_char": "binary",
424
+ "mediumint_geometry": "varbinary",
425
+ "date_time": "datetime",
426
+ "date_datetime": "datetime",
427
+ "date_year": "varchar",
428
+ "date_varchar": "varchar",
429
+ "date_bit": "varbinary",
430
+ "date_json": "varbinary",
431
+ "date_enum": "varchar",
432
+ "date_set": "varchar",
433
+ "date_tinyblob": "text",
434
+ "date_mediumblob": "text",
435
+ "date_longblob": "longtext",
436
+ "date_blob": "text",
437
+ "date_tinytext": "text",
438
+ "date_mediumtext": "text",
439
+ "date_longtext": "longtext",
440
+ "date_text": "text",
441
+ "date_varbinary": "varbinary",
442
+ "date_binary": "binary",
443
+ "date_char": "binary",
444
+ "date_geometry": "varbinary",
445
+ "time_datetime": "datetime",
446
+ "time_year": "varchar",
447
+ "time_varchar": "varchar",
448
+ "time_bit": "varbinary",
449
+ "time_json": "varbinary",
450
+ "time_enum": "varchar",
451
+ "time_set": "varchar",
452
+ "time_tinyblob": "text",
453
+ "time_mediumblob": "text",
454
+ "time_longblob": "longtext",
455
+ "time_blob": "text",
456
+ "time_tinytext": "text",
457
+ "time_mediumtext": "text",
458
+ "time_longtext": "longtext",
459
+ "time_text": "text",
460
+ "time_varbinary": "varbinary",
461
+ "time_binary": "binary",
462
+ "time_char": "binary",
463
+ "time_geometry": "varbinary",
464
+ "datetime_year": "varchar",
465
+ "datetime_varchar": "varchar",
466
+ "datetime_bit": "varbinary",
467
+ "datetime_json": "varbinary",
468
+ "datetime_enum": "varchar",
469
+ "datetime_set": "varchar",
470
+ "datetime_tinyblob": "text",
471
+ "datetime_mediumblob": "text",
472
+ "datetime_longblob": "longtext",
473
+ "datetime_blob": "text",
474
+ "datetime_tinytext": "text",
475
+ "datetime_mediumtext": "text",
476
+ "datetime_longtext": "longtext",
477
+ "datetime_text": "text",
478
+ "datetime_varbinary": "varbinary",
479
+ "datetime_binary": "binary",
480
+ "datetime_char": "binary",
481
+ "datetime_geometry": "varbinary",
482
+ "year_varchar": "varchar",
483
+ "year_bit": "bigint",
484
+ "year_json": "varbinary",
485
+ "year_enum": "varchar",
486
+ "year_set": "varchar",
487
+ "year_tinyblob": "text",
488
+ "year_mediumblob": "text",
489
+ "year_longblob": "longtext",
490
+ "year_blob": "text",
491
+ "year_tinytext": "text",
492
+ "year_mediumtext": "text",
493
+ "year_longtext": "longtext",
494
+ "year_text": "text",
495
+ "year_varbinary": "varbinary",
496
+ "year_binary": "binary",
497
+ "year_char": "binary",
498
+ "year_geometry": "varbinary",
499
+ "varchar_bit": "varbinary",
500
+ "varchar_json": "varbinary",
501
+ "varchar_enum": "varchar",
502
+ "varchar_set": "varchar",
503
+ "varchar_tinyblob": "text",
504
+ "varchar_mediumblob": "text",
505
+ "varchar_longblob": "longtext",
506
+ "varchar_blob": "text",
507
+ "varchar_tinytext": "text",
508
+ "varchar_mediumtext": "text",
509
+ "varchar_longtext": "longtext",
510
+ "varchar_text": "text",
511
+ "varchar_varbinary": "varbinary",
512
+ "varchar_binary": "varbinary",
513
+ "varchar_char": "varchar",
514
+ "varchar_geometry": "varbinary",
515
+ "bit_json": "varbinary",
516
+ "bit_enum": "varbinary",
517
+ "bit_set": "varbinary",
518
+ "bit_tinyblob": "text",
519
+ "bit_mediumblob": "text",
520
+ "bit_longblob": "longtext",
521
+ "bit_blob": "text",
522
+ "bit_tinytext": "tinytext",
523
+ "bit_mediumtext": "mediumtext",
524
+ "bit_longtext": "longtext",
525
+ "bit_text": "text",
526
+ "bit_varbinary": "varbinary",
527
+ "bit_binary": "binary",
528
+ "bit_char": "binary",
529
+ "bit_geometry": "varbinary",
530
+ "json_enum": "varbinary",
531
+ "json_set": "varbinary",
532
+ "json_tinyblob": "longtext",
533
+ "json_mediumblob": "longtext",
534
+ "json_longblob": "longtext",
535
+ "json_blob": "longtext",
536
+ "json_tinytext": "longtext",
537
+ "json_mediumtext": "longtext",
538
+ "json_longtext": "longtext",
539
+ "json_text": "longtext",
540
+ "json_varbinary": "varbinary",
541
+ "json_binary": "varbinary",
542
+ "json_char": "varbinary",
543
+ "json_geometry": "varbinary",
544
+ "enum_set": "varchar",
545
+ "enum_tinyblob": "text",
546
+ "enum_mediumblob": "text",
547
+ "enum_longblob": "longtext",
548
+ "enum_blob": "text",
549
+ "enum_tinytext": "text",
550
+ "enum_mediumtext": "text",
551
+ "enum_longtext": "longtext",
552
+ "enum_text": "text",
553
+ "enum_varbinary": "varbinary",
554
+ "enum_binary": "binary",
555
+ "enum_char": "binary",
556
+ "enum_geometry": "varbinary",
557
+ "set_tinyblob": "text",
558
+ "set_mediumblob": "text",
559
+ "set_longblob": "longtext",
560
+ "set_blob": "text",
561
+ "set_tinytext": "text",
562
+ "set_mediumtext": "text",
563
+ "set_longtext": "longtext",
564
+ "set_text": "text",
565
+ "set_varbinary": "varbinary",
566
+ "set_binary": "binary",
567
+ "set_char": "binary",
568
+ "set_geometry": "varbinary",
569
+ "tinyblob_mediumblob": "text",
570
+ "tinyblob_longblob": "longtext",
571
+ "tinyblob_blob": "text",
572
+ "tinyblob_tinytext": "tinytext",
573
+ "tinyblob_mediumtext": "mediumtext",
574
+ "tinyblob_longtext": "longtext",
575
+ "tinyblob_text": "text",
576
+ "tinyblob_varbinary": "text",
577
+ "tinyblob_binary": "text",
578
+ "tinyblob_char": "text",
579
+ "tinyblob_geometry": "longtext",
580
+ "mediumblob_longblob": "longtext",
581
+ "mediumblob_blob": "text",
582
+ "mediumblob_tinytext": "text",
583
+ "mediumblob_mediumtext": "mediumtext",
584
+ "mediumblob_longtext": "longtext",
585
+ "mediumblob_text": "text",
586
+ "mediumblob_varbinary": "text",
587
+ "mediumblob_binary": "text",
588
+ "mediumblob_char": "text",
589
+ "mediumblob_geometry": "longtext",
590
+ "longblob_blob": "longtext",
591
+ "longblob_tinytext": "longtext",
592
+ "longblob_mediumtext": "longtext",
593
+ "longblob_longtext": "longtext",
594
+ "longblob_text": "longtext",
595
+ "longblob_varbinary": "longtext",
596
+ "longblob_binary": "longtext",
597
+ "longblob_char": "longtext",
598
+ "longblob_geometry": "longtext",
599
+ "blob_tinytext": "text",
600
+ "blob_mediumtext": "mediumtext",
601
+ "blob_longtext": "longtext",
602
+ "blob_text": "text",
603
+ "blob_varbinary": "text",
604
+ "blob_binary": "text",
605
+ "blob_char": "text",
606
+ "blob_geometry": "longtext",
607
+ "tinytext_mediumtext": "text",
608
+ "tinytext_longtext": "longtext",
609
+ "tinytext_text": "text",
610
+ "tinytext_varbinary": "tinytext",
611
+ "tinytext_binary": "tinytext",
612
+ "tinytext_char": "text",
613
+ "tinytext_geometry": "longtext",
614
+ "mediumtext_longtext": "longtext",
615
+ "mediumtext_text": "text",
616
+ "mediumtext_varbinary": "mediumtext",
617
+ "mediumtext_binary": "mediumtext",
618
+ "mediumtext_char": "text",
619
+ "mediumtext_geometry": "longtext",
620
+ "longtext_text": "longtext",
621
+ "longtext_varbinary": "longtext",
622
+ "longtext_binary": "longtext",
623
+ "longtext_char": "longtext",
624
+ "longtext_geometry": "longtext",
625
+ "text_varbinary": "text",
626
+ "text_binary": "text",
627
+ "text_char": "text",
628
+ "text_geometry": "longtext",
629
+ "varbinary_binary": "varbinary",
630
+ "varbinary_char": "varbinary",
631
+ "varbinary_geometry": "varbinary",
632
+ "binary_char": "binary",
633
+ "binary_geometry": "varbinary",
634
+ "char_geometry": "varbinary"
635
+ };
636
+ if (type1 == type2)
637
+ return type1;
638
+ //ex. tinyint_smallint or smallint_tinyint
639
+ //@ts-ignore
640
+ if (typeMapping[type1 + "_" + type2] == type1 || typeMapping[type2 + "_" + type1] == type1) {
641
+ return type1;
642
+ }
643
+ //@ts-ignore
644
+ if (typeMapping[type1 + "_" + type2] == type2 || typeMapping[type2 + "_" + type1] == type2) {
645
+ return type2;
646
+ }
647
+ throw Error("unionTypeResult:" + type1 + "_" + type2);
648
+ }
649
+ exports.unionTypeResult = unionTypeResult;
158
650
  //# sourceMappingURL=unify.js.map