Skip to content

Commit 838650b

Browse files
committed
Changes mysql DDL to use execQuery instead of checking for pool (#258)
This also fixes when debug is on and no DDL queries are shown
1 parent 8f8e2db commit 838650b

File tree

1 file changed

+5
-29
lines changed

1 file changed

+5
-29
lines changed

lib/Drivers/DDL/mysql.js

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,8 @@ exports.drop = function (driver, opts, cb) {
1111

1212
pending = queries.length;
1313

14-
if (driver.opts.pool) {
15-
return driver.db.pool.getConnection(function (err, db) {
16-
for (i = 0; i < queries.length; i++) {
17-
db.query(queries[i], function (err) {
18-
if (--pending === 0) {
19-
return cb(err);
20-
}
21-
});
22-
}
23-
});
24-
}
25-
2614
for (i = 0; i < queries.length; i++) {
27-
driver.db.query(queries[i], function (err) {
15+
driver.execQuery(queries[i], function (err) {
2816
if (--pending === 0) {
2917
return cb(err);
3018
}
@@ -71,7 +59,7 @@ exports.sync = function (driver, opts, cb) {
7159
definitions.push("INDEX (" + driver.query.escapeId(k) + ")");
7260
}
7361
}
74-
62+
7563
for (i = 0; i < opts.one_associations.length; i++) {
7664
if (opts.one_associations[i].extension) continue;
7765
if (opts.one_associations[i].reversed) continue;
@@ -118,7 +106,7 @@ exports.sync = function (driver, opts, cb) {
118106
if (index == null) index = driver.query.escapeId(k);
119107
else index += ", " + driver.query.escapeId(k);
120108
}
121-
109+
122110

123111
definitions.push("INDEX (" + index + ")");
124112
queries.push(
@@ -129,20 +117,8 @@ exports.sync = function (driver, opts, cb) {
129117

130118
pending = queries.length;
131119

132-
if (driver.opts.pool) {
133-
return driver.db.pool.getConnection(function (err, db) {
134-
for (i = 0; i < queries.length; i++) {
135-
db.query(queries[i], function (err) {
136-
if (--pending === 0) {
137-
return cb(err);
138-
}
139-
});
140-
}
141-
});
142-
}
143-
144120
for (i = 0; i < queries.length; i++) {
145-
driver.db.query(queries[i], function (err) {
121+
driver.execQuery(queries[i], function (err) {
146122
if (--pending === 0) {
147123
return cb(err);
148124
}
@@ -164,7 +140,7 @@ function buildColumnDefinition(driver, name, prop) {
164140
def = driver.query.escapeId(name) + " LONGTEXT";
165141
} else {
166142
def = driver.query.escapeId(name) + " VARCHAR(" + Math.min(Math.max(parseInt(prop.size, 10) || 255, 1), 65535) + ")";
167-
}
143+
}
168144
break;
169145
case "number":
170146
if (prop.rational === false) {

0 commit comments

Comments
 (0)