Skip to content

Commit 5bdbafb

Browse files
committed
removed all ES6 strings and functions
1 parent 832dc9b commit 5bdbafb

File tree

9 files changed

+114
-201
lines changed

9 files changed

+114
-201
lines changed

oracleDriver.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ module.exports = function () {
5151

5252
function makeConnection() {
5353
if (config.pool === true) {
54-
return connectionPool(oracledb, config, swormConfig).then(pool => {
55-
return promisify(cb => pool.getConnection(cb));
54+
return connectionPool(oracledb, config, swormConfig).then(function (pool) {
55+
return promisify(function (cb) { pool.getConnection(cb); });
5656
});
5757
} else if (config.pool) {
58-
return promisify(cb => config.pool.getConnection(cb));
58+
return promisify(function (cb) { config.pool.getConnection(cb); });
5959
} else {
60-
return promisify(cb => oracledb.getConnection(config, cb));
60+
return promisify(function (cb) { oracledb.getConnection(config, cb); });
6161
}
6262
}
6363

@@ -143,7 +143,7 @@ function parseValue(value) {
143143
function parseOptions(options) {
144144
var result = {};
145145

146-
Object.keys(options).forEach(key => {
146+
Object.keys(options).forEach(function (key) {
147147
result[key] = parseValue(options[key]);
148148
});
149149

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"devDependencies": {
1414
"chai": "3.5.0",
1515
"chai-as-promised": "5.3.0",
16+
"es6-promise": "3.2.1",
1617
"fs-promise": "0.5.0",
1718
"mocha": "2.5.3",
1819
"mssql": "3.3.0",

test/addUrlParams.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ var modifyUrl = require('./modifyUrl');
22
var _ = require('underscore');
33

44
module.exports = function(url, extras) {
5-
return modifyUrl(url, parsedUrl => {
5+
return modifyUrl(url, function (parsedUrl) {
66
_.extend(parsedUrl.query, extras);
77
});
88
};

test/describeDatabase.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ var chaiAsPromised = require("chai-as-promised");
66
chai.use(chaiAsPromised);
77
var _ = require("underscore");
88

9+
require('es6-promise').polyfill();
10+
911
module.exports = function(name, config, database, otherTests) {
1012
describe(name, function() {
1113
describe("missing modules", function() {
@@ -145,10 +147,10 @@ module.exports = function(name, config, database, otherTests) {
145147
return db.connect(function () {
146148
expect(db.connected).to.be.true;
147149

148-
return db.query('select * from people').then(people => {
150+
return db.query('select * from people').then(function (people) {
149151
expect(people).to.eql([]);
150152
});
151-
}).then(() => {
153+
}).then(function () {
152154
expect(db.connected).to.be.false;
153155
});
154156
});

test/mssqlSpec.js

Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,56 +10,35 @@ var database = {
1010
}
1111

1212
return createTable("people",
13-
`CREATE TABLE [dbo].[people](
14-
[id] [int] IDENTITY(1,1) NOT NULL,
15-
[name] [nvarchar](50) NOT NULL,
16-
[address_id] [int] NULL
17-
)`
13+
'CREATE TABLE [dbo].[people]([id] [int] IDENTITY(1,1) NOT NULL, [name] [nvarchar](50) NOT NULL, [address_id] [int] NULL)'
1814
).then(function() {
1915
return createTable("people_addresses",
20-
`CREATE TABLE [dbo].[people_addresses](
21-
[address_id] [int] NOT NULL,
22-
[person_id] [int] NOT NULL,
23-
[rating] [int] NULL
24-
)`
16+
'CREATE TABLE [dbo].[people_addresses]([address_id] [int] NOT NULL, [person_id] [int] NOT NULL, [rating] [int] NULL)'
2517
);
2618
}).then(function () {
2719
return createTable("addresses",
28-
`CREATE TABLE [dbo].[addresses](
29-
[id] [int] IDENTITY(1,1) NOT NULL,
30-
[address] [nvarchar](50) NOT NULL
31-
)`
20+
'CREATE TABLE [dbo].[addresses]([id] [int] IDENTITY(1,1) NOT NULL, [address] [nvarchar](50) NOT NULL)'
3221
);
3322
}).then(function () {
3423
return createTable("people_weird_id",
35-
`CREATE TABLE [dbo].[people_weird_id](
36-
[weird_id] [int] IDENTITY(1,1) NOT NULL,
37-
[name] [nvarchar](50) NULL,
38-
[address_weird_id] [int] NULL
39-
)`
24+
'CREATE TABLE [dbo].[people_weird_id]([weird_id] [int] IDENTITY(1,1) NOT NULL, [name] [nvarchar](50) NULL, [address_weird_id] [int] NULL)'
4025
);
4126
}).then(function () {
4227
return createTable("people_explicit_id",
43-
`CREATE TABLE [dbo].[people_explicit_id](
44-
[id] [int] NOT NULL,
45-
[name] [nvarchar](50) NOT NULL
46-
)`
28+
'CREATE TABLE [dbo].[people_explicit_id]([id] [int] NOT NULL, [name] [nvarchar](50) NOT NULL)'
4729
);
4830
}).then(function () {
4931
return createTable("other_people",
50-
`CREATE TABLE [dbo].[other_people](
51-
[id] [int] IDENTITY(1,1) NOT NULL,
52-
[name] [nvarchar](50) NOT NULL
53-
)`
32+
'CREATE TABLE [dbo].[other_people]([id] [int] IDENTITY(1,1) NOT NULL, [name] [nvarchar](50) NOT NULL)'
5433
);
5534
}).then(function () {
5635
return db.query(
57-
`CREATE TRIGGER people_trigger
58-
ON people
59-
FOR INSERT AS
60-
BEGIN
61-
INSERT other_people VALUES ('person')
62-
END;`
36+
"CREATE TRIGGER people_trigger " +
37+
" ON people " +
38+
" FOR INSERT AS " +
39+
"BEGIN " +
40+
" INSERT other_people VALUES ('person') " +
41+
"END;"
6342
);
6443
});
6544
},

test/mysqlSpec.js

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,40 +24,22 @@ var database = {
2424
}
2525

2626
return createTable("people",
27-
`create table if not exists people (
28-
id serial NOT NULL,
29-
name varchar(50) NOT NULL,
30-
address_id int NULL
31-
)`
27+
'create table if not exists people (id serial NOT NULL, name varchar(50) NOT NULL, address_id int NULL)'
3228
).then(function() {
3329
return createTable("people_addresses",
34-
`create table if not exists people_addresses(
35-
address_id int NOT NULL,
36-
person_id int NOT NULL,
37-
rating int NULL
38-
)`
30+
'create table if not exists people_addresses(address_id int NOT NULL, person_id int NOT NULL, rating int NULL)'
3931
);
4032
}).then(function() {
4133
return createTable("addresses",
42-
`create table if not exists addresses(
43-
id serial NOT NULL,
44-
address varchar(50) NOT NULL
45-
)`
34+
'create table if not exists addresses(id serial NOT NULL, address varchar(50) NOT NULL)'
4635
);
4736
}).then(function() {
4837
return createTable("people_weird_id",
49-
`create table if not exists people_weird_id(
50-
weird_id serial NOT NULL,
51-
name varchar(50) NULL,
52-
address_weird_id int NULL
53-
)`
38+
'create table if not exists people_weird_id(weird_id serial NOT NULL, name varchar(50) NULL, address_weird_id int NULL)'
5439
);
5540
}).then(function() {
5641
return createTable("people_explicit_id",
57-
`create table if not exists people_explicit_id(
58-
id int NOT NULL,
59-
name varchar(50) NOT NULL
60-
)`
42+
'create table if not exists people_explicit_id(id int NOT NULL, name varchar(50) NOT NULL)'
6143
);
6244
});
6345
},

test/oracleSpec.js

Lines changed: 40 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,36 @@ if (!process.env.TRAVIS) {
1313
function createTable(name, id, sql, noAutoId) {
1414
tables.push(name);
1515
return db.query(
16-
`BEGIN
17-
EXECUTE IMMEDIATE 'DROP TABLE ${name}';
18-
EXCEPTION WHEN OTHERS THEN
19-
IF SQLCODE != -942 THEN
20-
RAISE;
21-
END IF;
22-
END;`
16+
"BEGIN " +
17+
" EXECUTE IMMEDIATE 'DROP TABLE " + name + "'; " +
18+
"EXCEPTION WHEN OTHERS THEN " +
19+
" IF SQLCODE != -942 THEN " +
20+
" RAISE; " +
21+
" END IF; " +
22+
"END;"
2323
).then(function() {
2424
return db.query(
25-
`BEGIN
26-
EXECUTE IMMEDIATE 'DROP SEQUENCE ${name}_seq';
27-
EXCEPTION WHEN OTHERS THEN
28-
IF SQLCODE != -2289 THEN
29-
RAISE;
30-
END IF;
31-
END;`
25+
"BEGIN " +
26+
" EXECUTE IMMEDIATE 'DROP SEQUENCE " + name + "_seq'; " +
27+
"EXCEPTION WHEN OTHERS THEN " +
28+
" IF SQLCODE != -2289 THEN " +
29+
" RAISE; " +
30+
" END IF; " +
31+
"END;"
3232
).then(function() {
3333
if (!noAutoId) {
34-
return db.query(`CREATE SEQUENCE ${name}_seq`);
34+
return db.query('CREATE SEQUENCE ' + name + '_seq');
3535
}
3636
}).then(function() {
3737
return db.query(sql).then(function() {
3838
if (!noAutoId) {
3939
return db.query(
40-
`create or replace trigger ${name}_id
41-
before insert on ${name}
42-
for each row
43-
begin
44-
select ${name}_seq.nextval into :new.${id} from dual;
45-
end;`
40+
"create or replace trigger " + name + "_id " +
41+
" before insert on " + name + " " +
42+
" for each row " +
43+
"begin " +
44+
" select " + name + "_seq.nextval into :new." + id + " from dual; " +
45+
"end;"
4646
);
4747
}
4848
});
@@ -51,41 +51,23 @@ if (!process.env.TRAVIS) {
5151
}
5252

5353
return createTable("people", "id",
54-
`create table people (
55-
id number primary key,
56-
name varchar2(50) NOT NULL,
57-
address_id number NULL
58-
)`
54+
'create table people (id number primary key, name varchar2(50) NOT NULL, address_id number NULL)'
5955
).then(function() {
6056
return createTable("people_addresses", "address_id",
61-
`create table people_addresses(
62-
address_id int NOT NULL,
63-
person_id int NOT NULL,
64-
rating int NULL
65-
)`,
57+
'create table people_addresses(address_id int NOT NULL, person_id int NOT NULL, rating int NULL)',
6658
true
6759
);
6860
}).then(function() {
6961
return createTable("addresses", "id",
70-
`create table addresses(
71-
id number primary key,
72-
address varchar2(50) NOT NULL
73-
)`
62+
'create table addresses(id number primary key, address varchar2(50) NOT NULL)'
7463
);
7564
}).then(function() {
7665
return createTable("people_weird_id", "weird_id",
77-
`create table people_weird_id(
78-
weird_id number primary key,
79-
name varchar2(50) NULL,
80-
address_weird_id int NULL
81-
)`
66+
'create table people_weird_id(weird_id number primary key, name varchar2(50) NULL, address_weird_id int NULL)'
8267
);
8368
}).then(function() {
8469
return createTable("people_explicit_id", "id",
85-
`create table people_explicit_id(
86-
id int NOT NULL,
87-
name varchar2(50) NOT NULL
88-
)`
70+
'create table people_explicit_id(id int NOT NULL, name varchar2(50) NOT NULL)'
8971
);
9072
});
9173
},
@@ -103,7 +85,7 @@ if (!process.env.TRAVIS) {
10385
function urlConfig(options) {
10486
return {
10587
driver: 'oracle',
106-
url: addUrlParams(`oracle://system:oracle@${dockerHostname}:1521/XE`, options)
88+
url: addUrlParams('oracle://system:oracle@' + dockerHostname + ':1521/XE', options)
10789
};
10890
}
10991

@@ -113,7 +95,7 @@ if (!process.env.TRAVIS) {
11395
config: _.extend({
11496
user: "system",
11597
password: "oracle",
116-
connectString: `${dockerHostname}:1521/XE`
98+
connectString: dockerHostname + ':1521/XE'
11799
}, options)
118100
};
119101
}
@@ -128,7 +110,7 @@ if (!process.env.TRAVIS) {
128110
return Promise.all([
129111
db? db.close(): undefined,
130112
db1? db1.close(): undefined
131-
]).then(() => {
113+
]).then(function () {
132114
db = undefined;
133115
db1 = undefined;
134116
});
@@ -141,29 +123,29 @@ if (!process.env.TRAVIS) {
141123
it("doesn't pool connections normally", function () {
142124
db = sworm.db(urlConfig());
143125
var poolsBefore = numberOfPools();
144-
return db.query('select * from people').then((rows) => {
126+
return db.query('select * from people').then(function (rows) {
145127
expect(rows).to.eql([]);
146-
expect(Object.keys(numberOfPools()).length).to.equal(poolsBefore);
128+
expect(numberOfPools()).to.equal(poolsBefore);
147129
});
148130
});
149131

150132
function testConnectionPooling(config) {
151133
var db1 = sworm.db(config);
152134
var poolsBefore = numberOfPools();
153-
return db1.query('select * from people').then((rows) => {
135+
return db1.query('select * from people').then(function (rows) {
154136
expect(rows).to.eql([]);
155137
expect(numberOfPools()).to.equal(poolsBefore + 1);
156-
}).then(() => {
138+
}).then(function () {
157139
db2 = sworm.db(config);
158140

159-
return db2.query('select * from people').then((rows) => {
141+
return db2.query('select * from people').then(function (rows) {
160142
expect(rows).to.eql([]);
161143
expect(numberOfPools()).to.equal(poolsBefore + 1);
162-
}).then(() => {
144+
}).then(function () {
163145
return db2.close();
164146
});
165-
}).then(() => {
166-
return db1.query('select * from people').then((rows) => {
147+
}).then(function () {
148+
return db1.query('select * from people').then(function (rows) {
167149
expect(rows).to.eql([]);
168150
expect(numberOfPools()).to.equal(poolsBefore + 1);
169151
});
@@ -185,7 +167,7 @@ if (!process.env.TRAVIS) {
185167
it('can pass connection options', function () {
186168
oracledb.maxRows = 100;
187169
db = sworm.db(urlConfig({maxRows: 100000}));
188-
return db.connect().then(() => {
170+
return db.connect().then(function () {
189171
expect(oracledb.maxRows).to.equal(100000);
190172
});
191173
});
@@ -204,8 +186,8 @@ if (!process.env.TRAVIS) {
204186
name: 'bob'
205187
});
206188

207-
return bob.save().then(() => {
208-
return db.query('select * from people', {}, {formatRows: false, outFormat: oracledb.OBJECT}).then(rows => {
189+
return bob.save().then(function () {
190+
return db.query('select * from people', {}, {formatRows: false, outFormat: oracledb.OBJECT}).then(function (rows) {
209191
expect(rows.metaData).to.eql([
210192
{name: 'ID'},
211193
{name: 'NAME'},

0 commit comments

Comments
 (0)