Skip to content

Commit 725cdfa

Browse files
committed
MySQLTable: Simplify parsing arguments to .insert() and .update()
1 parent 55cc324 commit 725cdfa

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

lib/MySQLTable.js

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -154,17 +154,13 @@ class MySQLTable {
154154
);
155155
}
156156

157-
if (cb) {
158-
sqlString = this._db.format(sqlString, values);
159-
} else if (values) {
160-
if (typeof values === 'function') {
161-
cb = values;
162-
} else {
157+
if (typeof sqlString === 'string') {
158+
if (typeof values === 'object') {
163159
sqlString = this._db.format(sqlString, values);
160+
} else {
161+
cb = values;
164162
}
165-
} else if (sqlString === undefined) {
166-
sqlString = '';
167-
} else if (typeof sqlString === 'function') {
163+
} else {
168164
cb = sqlString;
169165
sqlString = '';
170166
}
@@ -234,17 +230,13 @@ class MySQLTable {
234230
);
235231
}
236232

237-
if (cb) {
238-
sqlString = this._db.format(sqlString, values);
239-
} else if (values) {
240-
if (typeof values === 'function') {
241-
cb = values;
242-
} else {
233+
if (typeof sqlString === 'string') {
234+
if (typeof values === 'object') {
243235
sqlString = this._db.format(sqlString, values);
236+
} else {
237+
cb = values;
244238
}
245-
} else if (sqlString === undefined) {
246-
sqlString = '';
247-
} else if (typeof sqlString === 'function') {
239+
} else {
248240
cb = sqlString;
249241
sqlString = '';
250242
}

0 commit comments

Comments
 (0)