leoric 2.4.0 → 2.6.0

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/index.js CHANGED
@@ -39,10 +39,17 @@ const connect = async function connect(opts) {
39
39
  return realm;
40
40
  };
41
41
 
42
+ const disconnect = async function disconnect(realm, ...args) {
43
+ if (realm instanceof Realm && realm.connected) {
44
+ return await realm.disconnect(...args);
45
+ }
46
+ };
47
+
42
48
  Object.assign(Realm.prototype, migrations, { DataTypes });
43
49
  Object.assign(Realm, {
44
50
  default: Realm,
45
51
  connect,
52
+ disconnect,
46
53
  Bone,
47
54
  Collection,
48
55
  DataTypes,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "leoric",
3
- "version": "2.4.0",
3
+ "version": "2.6.0",
4
4
  "description": "JavaScript Object-relational mapping alchemy",
5
5
  "main": "index.js",
6
6
  "types": "types/index.d.ts",
package/src/bone.js CHANGED
@@ -20,6 +20,7 @@ const {
20
20
  TIMESTAMP_NAMES,
21
21
  LEGACY_TIMESTAMP_COLUMN_MAP,
22
22
  ASSOCIATE_METADATA_MAP,
23
+ TIMESTAMP_ATTRIBUTE_NAMES,
23
24
  } = require('./constants');
24
25
 
25
26
  const columnAttributesKey = Symbol('leoric#columns');
@@ -138,6 +139,8 @@ function valuesValidate(values, attributes, ctx) {
138
139
  */
139
140
  class Bone {
140
141
 
142
+ static DataTypes = DataTypes.invokable;
143
+
141
144
  // private variables
142
145
  #raw = {};
143
146
  #rawSaved = {};
@@ -997,7 +1000,7 @@ class Bone {
997
1000
  const attribute = new Attribute(name, attributes[name], options.define);
998
1001
  attributeMap[attribute.columnName] = attribute;
999
1002
  attributes[name] = attribute;
1000
- if (TIMESTAMP_NAMES.includes(name)) {
1003
+ if (TIMESTAMP_ATTRIBUTE_NAMES.includes(name)) {
1001
1004
  const { columnName } = attribute;
1002
1005
  const legacyColumnName = LEGACY_TIMESTAMP_COLUMN_MAP[columnName];
1003
1006
  if (!columnMap[columnName] && legacyColumnName && columnMap[legacyColumnName]) {
@@ -1712,6 +1715,4 @@ for (const getter of Spell_getters) {
1712
1715
  });
1713
1716
  }
1714
1717
 
1715
- Object.assign(Bone, { DataTypes });
1716
-
1717
1718
  module.exports = Bone;
package/src/constants.js CHANGED
@@ -20,6 +20,12 @@ const LEGACY_TIMESTAMP_COLUMN_MAP = {
20
20
  deleted_at: 'gmt_deleted',
21
21
  };
22
22
 
23
+ const TIMESTAMP_ATTRIBUTE_NAMES = [
24
+ 'createdAt', 'updatedAt', 'deletedAt',
25
+ 'gmtCreate', 'gmtModified', 'gmtDeleted',
26
+ 'created_at', 'updated_at', 'deleted_at',
27
+ 'gmt_create', 'gmt_modified', 'gmt_deleted',
28
+ ];
23
29
  const TIMESTAMP_NAMES = [ 'createdAt', 'updatedAt', 'deletedAt' ];
24
30
 
25
31
  const ASSOCIATE_METADATA_MAP = {
@@ -33,5 +39,6 @@ module.exports = {
33
39
  LEGACY_TIMESTAMP_MAP,
34
40
  TIMESTAMP_NAMES,
35
41
  LEGACY_TIMESTAMP_COLUMN_MAP,
36
- ASSOCIATE_METADATA_MAP
42
+ ASSOCIATE_METADATA_MAP,
43
+ TIMESTAMP_ATTRIBUTE_NAMES
37
44
  };
package/src/data_types.js CHANGED
@@ -110,20 +110,20 @@ class DataType {
110
110
  * STRING
111
111
  * STRING(127)
112
112
  * STRING.BINARY
113
- * @param {number} length
113
+ * @param {number} dataLength
114
114
  */
115
115
  class STRING extends DataType {
116
- constructor(length = 255) {
116
+ constructor(dataLength = 255) {
117
117
  super();
118
118
  this.dataType = 'varchar';
119
- this.length = length;
119
+ this.dataLength = dataLength;
120
120
  }
121
121
 
122
122
  toSqlString() {
123
- const { length } = this;
123
+ const { dataLength } = this;
124
124
  const dataType = this.dataType.toUpperCase();
125
125
  const chunks = [];
126
- chunks.push(length > 0 ? `${dataType}(${length})` : dataType);
126
+ chunks.push(dataLength > 0 ? `${dataType}(${dataLength})` : dataType);
127
127
  return chunks.join(' ');
128
128
  }
129
129
 
@@ -134,17 +134,17 @@ class STRING extends DataType {
134
134
  }
135
135
 
136
136
  class BINARY extends DataType {
137
- constructor(length = 255) {
137
+ constructor(dataLength = 255) {
138
138
  super();
139
- this.length = length;
139
+ this.dataLength = dataLength;
140
140
  this.dataType = 'binary';
141
141
  }
142
142
 
143
143
  toSqlString() {
144
- const { length } = this;
144
+ const { dataLength } = this;
145
145
  const dataType = this.dataType.toUpperCase();
146
146
  const chunks = [];
147
- chunks.push(length > 0 ? `${dataType}(${length})` : dataType);
147
+ chunks.push(dataLength > 0 ? `${dataType}(${dataLength})` : dataType);
148
148
  return chunks.join(' ');
149
149
  }
150
150
 
@@ -156,8 +156,8 @@ class BINARY extends DataType {
156
156
  }
157
157
 
158
158
  class VARBINARY extends BINARY {
159
- constructor(length) {
160
- super(length);
159
+ constructor(dataLength) {
160
+ super(dataLength);
161
161
  this.dataType = 'varbinary';
162
162
  }
163
163
  }
@@ -170,12 +170,12 @@ class VARBINARY extends BINARY {
170
170
  * INTEGER.UNSIGNED
171
171
  * INTEGER.UNSIGNED.ZEROFILL
172
172
  * INTEGER(10)
173
- * @param {number} length
173
+ * @param {number} dataLength
174
174
  */
175
175
  class INTEGER extends DataType {
176
- constructor(length) {
176
+ constructor(dataLength) {
177
177
  super();
178
- this.length = length;
178
+ this.dataLength = dataLength;
179
179
  this.dataType = 'integer';
180
180
  }
181
181
 
@@ -190,10 +190,10 @@ class INTEGER extends DataType {
190
190
  }
191
191
 
192
192
  toSqlString() {
193
- const { length, unsigned, zerofill } = this;
193
+ const { dataLength, unsigned, zerofill } = this;
194
194
  const dataType = this.dataType.toUpperCase();
195
195
  const chunks = [];
196
- chunks.push(length > 0 ? `${dataType}(${length})` : dataType);
196
+ chunks.push(dataLength > 0 ? `${dataType}(${dataLength})` : dataType);
197
197
  if (unsigned) chunks.push('UNSIGNED');
198
198
  if (zerofill) chunks.push('ZEROFILL');
199
199
  return chunks.join(' ');
@@ -222,11 +222,11 @@ class INTEGER extends DataType {
222
222
  * TINYINT
223
223
  * TINYINT.UNSIGNED
224
224
  * TINYINT(1)
225
- * @param {number} length
225
+ * @param {number} dataLength
226
226
  */
227
227
  class TINYINT extends INTEGER {
228
- constructor(length) {
229
- super(length);
228
+ constructor(dataLength) {
229
+ super(dataLength);
230
230
  this.dataType = 'tinyint';
231
231
  }
232
232
  }
@@ -237,11 +237,11 @@ class TINYINT extends INTEGER {
237
237
  * SMALLINT
238
238
  * SMALLINT.UNSIGNED
239
239
  * SMALLINT(2)
240
- * @param {number} length
240
+ * @param {number} dataLength
241
241
  */
242
242
  class SMALLINT extends INTEGER {
243
- constructor(length) {
244
- super(length);
243
+ constructor(dataLength) {
244
+ super(dataLength);
245
245
  this.dataType = 'smallint';
246
246
  }
247
247
  }
@@ -252,11 +252,11 @@ class SMALLINT extends INTEGER {
252
252
  * MEDIUMINT
253
253
  * MEDIUMINT.UNSIGNED
254
254
  * MEDIUMINT(3)
255
- * @param {number} length
255
+ * @param {number} dataLength
256
256
  */
257
257
  class MEDIUMINT extends INTEGER {
258
- constructor(length) {
259
- super(length);
258
+ constructor(dataLength) {
259
+ super(dataLength);
260
260
  this.dataType = 'mediumint';
261
261
  }
262
262
  }
@@ -268,11 +268,11 @@ class MEDIUMINT extends INTEGER {
268
268
  * BIGINT
269
269
  * BIGINT.UNSIGNED
270
270
  * BIGINT(8)
271
- * @param {number} length
271
+ * @param {number} dataLength
272
272
  */
273
273
  class BIGINT extends INTEGER {
274
- constructor(length) {
275
- super(length);
274
+ constructor(dataLength) {
275
+ super(dataLength);
276
276
  this.dataType = 'bigint';
277
277
  }
278
278
  }
@@ -312,8 +312,7 @@ class DECIMAL extends INTEGER {
312
312
  }
313
313
  }
314
314
 
315
- const rDateFormat = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}(?:[,.]\d{3,6})$/;
316
-
315
+ const rDateFormat = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}(?:[,.]\d{3,6}){0,1}$/;
317
316
  class DATE extends DataType {
318
317
  constructor(precision, timezone = true) {
319
318
  super();
@@ -359,7 +358,8 @@ class DATE extends DataType {
359
358
  // @deprecated
360
359
  // vaguely standard date formats such as 2021-10-15 15:50:02,548
361
360
  if (typeof value === 'string' && rDateFormat.test(value)) {
362
- value = new Date(`${value.replace(' ', 'T').replace(',', '.')}Z`);
361
+ // 2021-10-15 15:50:02,548 => 2021-10-15T15:50:02,548, 2021-10-15 15:50:02 => 2021-10-15T15:50:02.000
362
+ value = new Date(`${value.replace(' ', 'T').replace(',', '.')}`);
363
363
  }
364
364
 
365
365
  // 1634611135776
@@ -371,10 +371,12 @@ class DATE extends DataType {
371
371
  }
372
372
  }
373
373
 
374
- class DATEONLY extends DataType {
374
+ class DATEONLY extends DATE {
375
375
  constructor() {
376
376
  super();
377
377
  this.dataType = 'date';
378
+ this.precision = null;
379
+ this.timezone = false;
378
380
  }
379
381
 
380
382
  toSqlString() {
@@ -387,34 +389,6 @@ class DATEONLY extends DataType {
387
389
  }
388
390
  return value;
389
391
  }
390
-
391
- cast(value) {
392
- const original = value;
393
- if (value == null) return value;
394
- if (!(value instanceof Date)) value = new Date(value);
395
- if (isNaN(value.getTime())) return original;
396
- return this._round(value);
397
- }
398
-
399
- uncast(value) {
400
- const originValue = value;
401
-
402
- if (value == null || value instanceof Raw) return value;
403
- if (typeof value.toDate === 'function') {
404
- value = value.toDate();
405
- }
406
-
407
- // @deprecated
408
- // vaguely standard date formats such as 2021-10-15 15:50:02,548
409
- if (typeof value === 'string' && rDateFormat.test(value)) {
410
- value = new Date(`${value.replace(' ', 'T').replace(',', '.')}Z`);
411
- }
412
-
413
- if (!(value instanceof Date)) value = new Date(value);
414
- if (isNaN(value)) throw new Error(util.format('invalid date: %s', originValue));
415
-
416
- return this._round(value);
417
- }
418
392
  }
419
393
 
420
394
  class BOOLEAN extends DataType {
@@ -442,11 +416,11 @@ class TEXT extends DataType {
442
416
  }
443
417
  super();
444
418
  this.dataType = 'text';
445
- this.length = length;
419
+ this.dataLength = length;
446
420
  }
447
421
 
448
422
  toSqlString() {
449
- return [ this.length, this.dataType ].join('').toUpperCase();
423
+ return [ this.dataLength, this.dataType ].join('').toUpperCase();
450
424
  }
451
425
  }
452
426
 
@@ -457,11 +431,11 @@ class BLOB extends DataType {
457
431
  }
458
432
  super();
459
433
  this.dataType = 'blob';
460
- this.length = length;
434
+ this.dataLength = length;
461
435
  }
462
436
 
463
437
  toSqlString() {
464
- return [ this.length, this.dataType ].join('').toUpperCase();
438
+ return [ this.dataLength, this.dataType ].join('').toUpperCase();
465
439
  }
466
440
 
467
441
  cast(value) {
@@ -77,7 +77,7 @@ function createType(DataTypes, params) {
77
77
  case 'VARBINARY':
78
78
  case 'CHAR':
79
79
  case 'VARCHAR':
80
- return new DataType(type.length);
80
+ return new DataType(type.dataLength);
81
81
  default:
82
82
  return new DataType();
83
83
  }
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const SqlString = require('sqlstring');
4
+ const debug = require('debug')('leoric');
4
5
 
5
6
  const Logger = require('./logger');
6
7
  const Attribute = require('./attribute');
@@ -54,6 +55,14 @@ class AbstractDriver {
54
55
  throw new Error('unimplemented!');
55
56
  }
56
57
 
58
+ /**
59
+ * disconnect manually
60
+ * @param {Function} callback
61
+ */
62
+ async disconnect(callback) {
63
+ debug('[disconnect] called');
64
+ }
65
+
57
66
  get dialect() {
58
67
  return camelCase(this.constructor.name.replace('Driver', ''));
59
68
  }
@@ -94,20 +94,21 @@ class MysqlDriver extends AbstractDriver {
94
94
  });
95
95
  });
96
96
  const sql = logger.format(query, values, opts);
97
+ const logOpts = { ...opts, query };
97
98
  const start = performance.now();
98
99
  let result;
99
100
 
100
101
  try {
101
102
  result = await promise;
102
103
  } catch (err) {
103
- logger.logQueryError(err, sql, calculateDuration(start), opts);
104
+ logger.logQueryError(err, sql, calculateDuration(start), logOpts);
104
105
  throw err;
105
106
  } finally {
106
107
  if (!opts.connection) connection.release();
107
108
  }
108
109
 
109
110
  const [ results, fields ] = result;
110
- logger.tryLogQuery(sql, calculateDuration(start), opts, results);
111
+ logger.tryLogQuery(sql, calculateDuration(start), logOpts, results);
111
112
  if (fields) return { rows: results, fields };
112
113
  return results;
113
114
  }
@@ -41,8 +41,8 @@ class Postgres_BINARY extends DataTypes {
41
41
  }
42
42
 
43
43
  class Postgres_INTEGER extends DataTypes.INTEGER {
44
- constructor(length) {
45
- super(length);
44
+ constructor(dataLength) {
45
+ super(dataLength);
46
46
  }
47
47
 
48
48
  uncast(value) {
@@ -51,6 +51,7 @@ class PostgresDriver extends AbstractDriver {
51
51
  const command = sql.slice(0, sql.indexOf(' ')).toLowerCase();
52
52
 
53
53
  async function tryQuery(...args) {
54
+ const logOpts = { ...spell, query: sql };
54
55
  const formatted = logger.format(sql, values, spell);
55
56
  const start = performance.now();
56
57
  let result;
@@ -58,13 +59,13 @@ class PostgresDriver extends AbstractDriver {
58
59
  try {
59
60
  result = await connection.query(...args);
60
61
  } catch (err) {
61
- logger.logQueryError(err, formatted, calculateDuration(start), spell);
62
+ logger.logQueryError(err, formatted, calculateDuration(start), logOpts);
62
63
  throw err;
63
64
  } finally {
64
65
  if (!spell.connection) connection.release();
65
66
  }
66
67
 
67
- logger.tryLogQuery(formatted, calculateDuration(start), spell, result);
68
+ logger.tryLogQuery(formatted, calculateDuration(start), logOpts, result);
68
69
  return result;
69
70
  }
70
71
 
@@ -34,8 +34,8 @@ class Sqlite_DATEONLY extends DataTypes.DATEONLY {
34
34
  }
35
35
 
36
36
  class Sqlite_INTEGER extends DataTypes.INTEGER {
37
- constructor(length) {
38
- super(length);
37
+ constructor(dataLength) {
38
+ super(dataLength);
39
39
  }
40
40
 
41
41
  uncast(value) {
@@ -54,24 +54,24 @@ class Sqlite_BIGINT extends DataTypes.BIGINT {
54
54
  }
55
55
  }
56
56
  class Sqlite_BINARY extends DataTypes {
57
- constructor(length = 255) {
58
- super(length);
59
- this.length = length;
57
+ constructor(dataLength = 255) {
58
+ super(dataLength);
59
+ this.dataLength = dataLength;
60
60
  this.dataType = 'binary';
61
61
  }
62
62
 
63
63
  toSqlString() {
64
- const { length } = this;
64
+ const { dataLength } = this;
65
65
  const dataType = this.dataType.toUpperCase();
66
66
  const chunks = [];
67
67
  chunks.push('VARCHAR');
68
- chunks.push(length > 0 ? `${dataType}(${length})` : dataType);
68
+ chunks.push(dataLength > 0 ? `${dataType}(${dataLength})` : dataType);
69
69
  return chunks.join(' ');
70
70
  }
71
71
  }
72
72
  class Sqlite_VARBINARY extends Sqlite_BINARY {
73
- constructor(length) {
74
- super(length);
73
+ constructor(dataLength) {
74
+ super(dataLength);
75
75
  this.dataType = 'varbinary';
76
76
  }
77
77
  }
@@ -53,6 +53,7 @@ class SqliteDriver extends AbstractDriver {
53
53
  }
54
54
 
55
55
  const { logger } = this;
56
+ const logOpts = { ...opts, query };
56
57
  const sql = logger.format(query, values, opts);
57
58
  const start = performance.now();
58
59
  let result;
@@ -60,13 +61,13 @@ class SqliteDriver extends AbstractDriver {
60
61
  try {
61
62
  result = await connection.query(query, values, opts);
62
63
  } catch (err) {
63
- logger.logQueryError(err, sql, calculateDuration(start), opts);
64
+ logger.logQueryError(err, sql, calculateDuration(start), logOpts);
64
65
  throw err;
65
66
  } finally {
66
67
  if (!opts.connection) connection.release();
67
68
  }
68
69
 
69
- logger.tryLogQuery(sql, calculateDuration(start), opts, result);
70
+ logger.tryLogQuery(sql, calculateDuration(start), logOpts, result);
70
71
  return result;
71
72
  }
72
73
 
package/src/realm.js CHANGED
@@ -160,6 +160,12 @@ class Realm {
160
160
  return this.Bone;
161
161
  }
162
162
 
163
+ async disconnect(callback) {
164
+ if (this.connected && this.driver) {
165
+ return await this.driver.disconnect(callback);
166
+ }
167
+ }
168
+
163
169
  async sync(options) {
164
170
  if (!this.connected) await this.connect();
165
171
  const { models } = this;
@@ -18,6 +18,9 @@ function invokable(DataType) {
18
18
 
19
19
  // INTEGER.UNSIGNED
20
20
  get(target, p) {
21
+ // ref: https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Function/length
22
+ // The length property indicates the number of parameters expected by the function.
23
+ // invokable INTEGER.toSqlString() will default to return "INTEGER(1)"
21
24
  return target.hasOwnProperty(p) ? target[p] : new target()[p];
22
25
  }
23
26
  });
@@ -1,65 +1,68 @@
1
1
  type LENGTH_VARIANTS = 'tiny' | '' | 'medium' | 'long';
2
2
 
3
- interface INVOKABLE<T> {
4
- (length: LENGTH_VARIANTS): T;
5
- (length: number): T;
3
+ interface INVOKABLE<T> extends DataType {
4
+ (dataLength?: LENGTH_VARIANTS): T;
5
+ (dataLength?: number): T;
6
6
  }
7
7
 
8
8
  export default class DataType {
9
9
  toSqlString(): string;
10
10
 
11
- static STRING: typeof STRING & INVOKABLE<STRING>;
12
- static INTEGER: typeof INTEGER & INVOKABLE<INTEGER>;
13
- static BIGINT: typeof BIGINT & INVOKABLE<BIGINT>;
14
- static DECIMAL: typeof DECIMAL & INVOKABLE<DECIMAL>;
15
- static TEXT: typeof TEXT & INVOKABLE<TEXT>;
16
- static BLOB: typeof BLOB & INVOKABLE<BLOB>;
17
- static JSON: typeof JSON & INVOKABLE<JSON>;
18
- static JSONB: typeof JSONB & INVOKABLE<JSONB>;
19
- static BINARY: typeof BINARY & INVOKABLE<BINARY>;
20
- static VARBINARY: typeof VARBINARY & INVOKABLE<VARBINARY>;
21
- static DATE: typeof DATE & INVOKABLE<DATE>;
22
- static DATEONLY: typeof DATEONLY & INVOKABLE<DATEONLY>;
23
- static BOOLEAN: typeof BOOLEAN & INVOKABLE<BOOLEAN>;
24
- static VIRTUAL: typeof VIRTUAL & INVOKABLE<VIRTUAL>;
11
+ static STRING: INVOKABLE<STRING>;
12
+ static INTEGER: INTEGER & INVOKABLE<INTEGER>;
13
+ static BIGINT: BIGINT & INVOKABLE<BIGINT>;
14
+ static DECIMAL: DECIMAL & INVOKABLE<DECIMAL>;
15
+ static TEXT: INVOKABLE<TEXT>;
16
+ static BLOB: INVOKABLE<BLOB>;
17
+ static JSON: JSON;
18
+ static JSONB: JSONB;
19
+ static BINARY: BINARY & INVOKABLE<BINARY>;
20
+ static VARBINARY: VARBINARY & INVOKABLE<VARBINARY>;
21
+ static DATE: DATE & INVOKABLE<DATE>;
22
+ static DATEONLY: DATEONLY;
23
+ static BOOLEAN: BOOLEAN;
24
+ static VIRTUAL: VIRTUAL;
25
25
 
26
26
  }
27
27
 
28
28
  declare class STRING extends DataType {
29
29
  dataType: 'varchar';
30
- length: number;
31
- constructor(length: number);
30
+ dataLength: number;
31
+ constructor(dataLength: number);
32
32
  }
33
33
 
34
34
  declare class INTEGER extends DataType {
35
35
  dataType: 'integer' | 'bigint' | 'decimal';
36
- length: number;
37
- constructor(length: number);
38
- get UNSIGNED(): this;
39
- get ZEROFILL(): this;
36
+ dataLength: number;
37
+ constructor(dataLength: number);
38
+ // avoid INTEGER.UNSIGNED.ZEROFILL.UNSIGNED.UNSIGNED
39
+ get UNSIGNED(): Omit<this, 'UNSIGNED' | 'ZEROFILL'>;
40
+ get ZEROFILL(): Omit<this, 'UNSIGNED' | 'ZEROFILL'>;
40
41
  }
41
42
 
42
43
  declare class BIGINT extends INTEGER {
43
44
  dataType: 'bigint';
44
45
  }
45
46
 
46
- declare class DECIMAL extends INTEGER {
47
+ declare class DECIMAL_INNER extends INTEGER {
47
48
  dataType: 'decimal';
48
49
  precision: number;
49
50
  scale: number;
50
51
  constructor(precision: number, scale: number);
51
52
  }
52
53
 
54
+ declare type DECIMAL = Omit<DECIMAL_INNER, 'dataLength'>;
55
+
53
56
  declare class TEXT extends DataType {
54
57
  dataType: 'text';
55
- length: LENGTH_VARIANTS;
56
- constructor(length: LENGTH_VARIANTS);
58
+ dataLength: LENGTH_VARIANTS;
59
+ constructor(dataLength: LENGTH_VARIANTS);
57
60
  }
58
61
 
59
62
  declare class BLOB extends DataType {
60
63
  dataType: 'blob';
61
- length: LENGTH_VARIANTS;
62
- constructor(length: LENGTH_VARIANTS)
64
+ dataLength: LENGTH_VARIANTS;
65
+ constructor(dataLength: LENGTH_VARIANTS)
63
66
  }
64
67
 
65
68
  declare class JSON extends DataType {
@@ -72,14 +75,14 @@ declare class JSONB extends JSON {
72
75
 
73
76
  declare class BINARY extends DataType {
74
77
  dataType: 'binary';
75
- length: number;
76
- constructor(length: number);
78
+ dataLength: number;
79
+ constructor(dataLength: number);
77
80
  }
78
81
 
79
82
  declare class VARBINARY extends DataType {
80
83
  dataType: 'varbinary';
81
- length: number;
82
- constructor(length: number);
84
+ dataLength: number;
85
+ constructor(dataLength: number);
83
86
  }
84
87
 
85
88
  declare class DATE extends DataType {