@axiosleo/orm-mysql 0.10.12 → 0.10.14

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/bin/orm-mysql.js CHANGED
@@ -9,7 +9,7 @@ const app = new App({
9
9
  name: 'MySQL ORM CLI',
10
10
  desc: 'migrate, model, seed, etc.',
11
11
  bin: 'orm-mysql',
12
- version: '0.10.12',
12
+ version: '0.10.14',
13
13
  commands_dir: path.join(__dirname, '../commands'),
14
14
  });
15
15
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axiosleo/orm-mysql",
3
- "version": "0.10.12",
3
+ "version": "0.10.14",
4
4
  "description": "MySQL ORM tool",
5
5
  "keywords": [
6
6
  "mysql",
package/src/builder.js CHANGED
@@ -58,9 +58,9 @@ class Builder {
58
58
  emit(tmp, this._buildJoins(options.joins));
59
59
  emit(tmp, this._buildCondition(options.conditions));
60
60
  emit(tmp, this._buildGroupField(options.groupField));
61
- emit(tmp, this._buildPagination(options.pageLimit, options.pageOffset));
62
61
  emit(tmp, this._buildHaving(options.having));
63
62
  emit(tmp, this._buildOrders(options.orders));
63
+ emit(tmp, this._buildPagination(options.pageLimit, options.pageOffset));
64
64
  sql = tmp.join(' ');
65
65
  if (options.suffix) {
66
66
  sql += ' ' + options.suffix;
@@ -331,7 +331,14 @@ class Builder {
331
331
  const opt = c.opt.toLowerCase();
332
332
  if (opt === 'group' && Array.isArray(c.value)) {
333
333
  let t = `(${this._buildCondition(c.value, '')})`;
334
- return index === 0 ? t : ` AND ${t}`;
334
+ if (index === 0 || conditions[index - 1].opt === 'group') {
335
+ return t;
336
+ }
337
+ const lastOpt = conditions[index - 1].opt;
338
+ if (['AND', 'OR'].indexOf(lastOpt) > -1) {
339
+ return t;
340
+ }
341
+ return ` AND ${t}`;
335
342
  }
336
343
  if (opt === 'in') {
337
344
  return this._buildConditionIn(c);