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