Skip to content

Commit 709c6f8

Browse files
committed
ColumnDefinition: Remove deprecated .defaultRaw() method
1 parent ca1ace4 commit 709c6f8

File tree

4 files changed

+0
-57
lines changed

4 files changed

+0
-57
lines changed

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,9 +1142,6 @@ This class is what is used to define the column's attributes. These attributes c
11421142
+ Examples:
11431143
+ `.default('Hello')` produces `DEFAULT 'Hello'`
11441144
+ `.default(null)` produces `DEFAULT NULL`
1145-
+ ~~`defaultRaw(value: string)` - Sets the column's `DEFAULT` value without escaping the input value~~
1146-
+ **deprecated** since version 0.5.0 and will be removed in version 0.6.0
1147-
+ Examples: `.defaultRaw('CURRENT_TIMESTAMP')` produces `DEFAULT CURRENT_TIMESTAMP`
11481145
+ `primaryKey()` - Declares the column to be the table's primary key
11491146
+ `unique()` - Declares the column as a unique index
11501147
+ `index()` - Declares the column as an index

jsdoc2md/README.hbs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,9 +342,6 @@ This class is what is used to define the column's attributes. These attributes c
342342
+ Examples:
343343
+ `.default('Hello')` produces `DEFAULT 'Hello'`
344344
+ `.default(null)` produces `DEFAULT NULL`
345-
+ ~~`defaultRaw(value: string)` - Sets the column's `DEFAULT` value without escaping the input value~~
346-
+ **deprecated** since version 0.5.0 and will be removed in version 0.6.0
347-
+ Examples: `.defaultRaw('CURRENT_TIMESTAMP')` produces `DEFAULT CURRENT_TIMESTAMP`
348345
+ `primaryKey()` - Declares the column to be the table's primary key
349346
+ `unique()` - Declares the column as a unique index
350347
+ `index()` - Declares the column as an index

lib/ColumnDefinitions/ColumnDefinition.js

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict';
22

33
const mysql = require('mysql');
4-
const util = require('util');
54

65
class ColumnDefinition {
76
constructor(type, m, d) {
@@ -47,16 +46,6 @@ class ColumnDefinition {
4746
return this;
4847
}
4948

50-
defaultRaw(value) {
51-
if (typeof value !== 'string') {
52-
throw new TypeError(
53-
'The value passed to `.defaultRaw()` must be a string. You should use `.default()` for other types of values.'
54-
);
55-
}
56-
57-
return this.$defaultRaw(value);
58-
}
59-
6049
oldName(oldName) {
6150
this.$oldName = oldName;
6251
return this;
@@ -113,10 +102,4 @@ class ColumnDefinition {
113102
}
114103
}
115104

116-
ColumnDefinition.prototype.defaultRaw = util.deprecate(
117-
ColumnDefinition.prototype.defaultRaw,
118-
'The `.defaultRaw()` method has been deprecated and will be removed in version 0.6.0. ' +
119-
'Please use `.default()` or `.defaultCurrentTimestamp()` instead.'
120-
);
121-
122105
module.exports = ColumnDefinition;

test/unit/ColumnDefinitions.test.js

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -30,34 +30,18 @@ describe('ColumnDefinitions', () => {
3030
b = ColumnDefinitions.blob();
3131
a.$equals(b).should.be.false();
3232

33-
a = ColumnDefinitions.blob().defaultRaw('a');
34-
b = ColumnDefinitions.blob();
35-
a.$equals(b).should.be.false();
36-
3733
a = ColumnDefinitions.blob().default('a');
3834
b = ColumnDefinitions.blob().default('a');
3935
a.$equals(b).should.be.true();
4036

41-
a = ColumnDefinitions.blob().defaultRaw('a');
42-
b = ColumnDefinitions.blob().defaultRaw('a');
43-
a.$equals(b).should.be.true();
44-
4537
a = ColumnDefinitions.blob().notNull();
4638
b = ColumnDefinitions.blob().notNull().default('a');
4739
a.$equals(b).should.be.false();
4840

49-
a = ColumnDefinitions.blob().notNull();
50-
b = ColumnDefinitions.blob().notNull().defaultRaw('a');
51-
a.$equals(b).should.be.false();
52-
5341
a = ColumnDefinitions.blob().notNull().default('a');
5442
b = ColumnDefinitions.blob().notNull().default('b');
5543
a.$equals(b).should.be.false();
5644

57-
a = ColumnDefinitions.blob().notNull().defaultRaw('a');
58-
b = ColumnDefinitions.blob().notNull().defaultRaw('b');
59-
a.$equals(b).should.be.false();
60-
6145
a = ColumnDefinitions.int().unsigned().zerofill().notNull().default(2).autoIncrement();
6246
b = ColumnDefinitions.int().unsigned().zerofill().notNull().default(2).autoIncrement();
6347
a.$equals(b).should.be.true();
@@ -374,28 +358,10 @@ describe('ColumnDefinitions', () => {
374358
cd = ColumnDefinitions.timestamp().default('CURRENT_TIMESTAMP');
375359
cd.$toSQL().should.equal('timestamp DEFAULT \'CURRENT_TIMESTAMP\'');
376360

377-
cd = ColumnDefinitions.datetime().notNull().defaultRaw('NOW()');
378-
cd.$toSQL().should.equal('datetime NOT NULL DEFAULT NOW()');
379-
380-
cd = ColumnDefinitions.timestamp().notNull().defaultRaw('CURRENT_TIMESTAMP');
381-
cd.$toSQL().should.equal('timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP');
382-
383-
cd = ColumnDefinitions.tinyint().notNull().defaultRaw('1');
384-
cd.$toSQL().should.equal('tinyint NOT NULL DEFAULT 1');
385-
386361
cd = ColumnDefinitions.datetime().default('1970-01-01 00:00:01');
387362
cd.$toSQL().should.equal('datetime DEFAULT \'1970-01-01 00:00:01\'');
388363
});
389364

390-
it('should throw if the value passed to `.defaultRaw()` is not a string', () => {
391-
should.throws(() => ColumnDefinitions.int().defaultRaw(1), /defaultRaw.+must be a string/);
392-
should.throws(() => ColumnDefinitions.int().defaultRaw([1]), /defaultRaw.+must be a string/);
393-
should.throws(() => ColumnDefinitions.int().defaultRaw(null), /defaultRaw.+must be a string/);
394-
should.throws(() => ColumnDefinitions.int().defaultRaw(undefined), /defaultRaw.+must be a string/);
395-
should.throws(() => ColumnDefinitions.int().defaultRaw(true), /defaultRaw.+must be a string/);
396-
should.throws(() => ColumnDefinitions.int().defaultRaw(false), /defaultRaw.+must be a string/);
397-
});
398-
399365
it('should allow the columns to be defined as keys, but not change the SQL', () => {
400366
var cd;
401367

0 commit comments

Comments
 (0)