w-orm-reladb 1.1.8 → 1.1.9

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.
@@ -750,7 +750,7 @@
750
750
 
751
751
  <dt class="tag-source">Source:</dt>
752
752
  <dd class="tag-source"><ul class="dummy"><li>
753
- <a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line502">line 502</a>
753
+ <a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line525">line 525</a>
754
754
  </li></ul></dd>
755
755
 
756
756
 
@@ -858,7 +858,7 @@
858
858
 
859
859
  <dt class="tag-source">Source:</dt>
860
860
  <dd class="tag-source"><ul class="dummy"><li>
861
- <a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line1693">line 1693</a>
861
+ <a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line1716">line 1716</a>
862
862
  </li></ul></dd>
863
863
 
864
864
 
@@ -972,7 +972,7 @@
972
972
 
973
973
  <dt class="tag-source">Source:</dt>
974
974
  <dd class="tag-source"><ul class="dummy"><li>
975
- <a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line1406">line 1406</a>
975
+ <a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line1429">line 1429</a>
976
976
  </li></ul></dd>
977
977
 
978
978
 
@@ -1304,7 +1304,7 @@
1304
1304
 
1305
1305
  <dt class="tag-source">Source:</dt>
1306
1306
  <dd class="tag-source"><ul class="dummy"><li>
1307
- <a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line1595">line 1595</a>
1307
+ <a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line1618">line 1618</a>
1308
1308
  </li></ul></dd>
1309
1309
 
1310
1310
 
@@ -1634,7 +1634,7 @@
1634
1634
 
1635
1635
  <dt class="tag-source">Source:</dt>
1636
1636
  <dd class="tag-source"><ul class="dummy"><li>
1637
- <a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line1735">line 1735</a>
1637
+ <a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line1758">line 1758</a>
1638
1638
  </li></ul></dd>
1639
1639
 
1640
1640
 
@@ -2162,7 +2162,7 @@
2162
2162
 
2163
2163
  <dt class="tag-source">Source:</dt>
2164
2164
  <dd class="tag-source"><ul class="dummy"><li>
2165
- <a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line1783">line 1783</a>
2165
+ <a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line1806">line 1806</a>
2166
2166
  </li></ul></dd>
2167
2167
 
2168
2168
 
@@ -2467,7 +2467,7 @@
2467
2467
 
2468
2468
  <dt class="tag-source">Source:</dt>
2469
2469
  <dd class="tag-source"><ul class="dummy"><li>
2470
- <a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line518">line 518</a>
2470
+ <a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line541">line 541</a>
2471
2471
  </li></ul></dd>
2472
2472
 
2473
2473
 
@@ -2575,7 +2575,7 @@
2575
2575
 
2576
2576
  <dt class="tag-source">Source:</dt>
2577
2577
  <dd class="tag-source"><ul class="dummy"><li>
2578
- <a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line435">line 435</a>
2578
+ <a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line458">line 458</a>
2579
2579
  </li></ul></dd>
2580
2580
 
2581
2581
 
@@ -2762,7 +2762,7 @@
2762
2762
 
2763
2763
  <dt class="tag-source">Source:</dt>
2764
2764
  <dd class="tag-source"><ul class="dummy"><li>
2765
- <a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line781">line 781</a>
2765
+ <a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line804">line 804</a>
2766
2766
  </li></ul></dd>
2767
2767
 
2768
2768
 
@@ -3141,7 +3141,7 @@ mssql因綁定參數數量上限會由驅動層自動拆為多語句送出,實
3141
3141
 
3142
3142
  <dt class="tag-source">Source:</dt>
3143
3143
  <dd class="tag-source"><ul class="dummy"><li>
3144
- <a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line957">line 957</a>
3144
+ <a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line980">line 980</a>
3145
3145
  </li></ul></dd>
3146
3146
 
3147
3147
 
@@ -3475,7 +3475,7 @@ mssql因綁定參數數量上限會由驅動層自動拆為多語句送出,實
3475
3475
 
3476
3476
  <dt class="tag-source">Source:</dt>
3477
3477
  <dd class="tag-source"><ul class="dummy"><li>
3478
- <a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line1290">line 1290</a>
3478
+ <a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line1313">line 1313</a>
3479
3479
  </li></ul></dd>
3480
3480
 
3481
3481
 
@@ -3851,7 +3851,7 @@ mssql因綁定參數數量上限會由驅動層自動拆為多語句送出,實
3851
3851
 
3852
3852
  <dt class="tag-source">Source:</dt>
3853
3853
  <dd class="tag-source"><ul class="dummy"><li>
3854
- <a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line553">line 553</a>
3854
+ <a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line576">line 576</a>
3855
3855
  </li></ul></dd>
3856
3856
 
3857
3857
 
@@ -4184,7 +4184,7 @@ mssql因綁定參數數量上限會由驅動層自動拆為多語句送出,實
4184
4184
 
4185
4185
  <dt class="tag-source">Source:</dt>
4186
4186
  <dd class="tag-source"><ul class="dummy"><li>
4187
- <a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line651">line 651</a>
4187
+ <a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line674">line 674</a>
4188
4188
  </li></ul></dd>
4189
4189
 
4190
4190
 
@@ -4510,7 +4510,7 @@ mssql因綁定參數數量上限會由驅動層自動拆為多語句送出,實
4510
4510
  <br class="clear">
4511
4511
 
4512
4512
  <footer>
4513
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Fri Oct 16 2026 14:32:44 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
4513
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Fri Oct 16 2026 19:47:28 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
4514
4514
  </footer>
4515
4515
 
4516
4516
  <script>prettyPrint();</script>
@@ -375,6 +375,10 @@ function WOrmReladb(opt = {}) {
375
375
  * 檢查model之預設scope是否會使select與delAll之對象分歧
376
376
  * 註: defaultScope帶limit或offset時, select依其order取前幾筆, 而sequelize之限量刪除不採order(sqlite為rowid IN子查詢),
377
377
  * 兩者命中之數據不同而會刪錯列, 故delAll遇此類model即拒絕
378
+ * 註: defaultScope帶group或having時, findAll套用而destroy不套用(having過濾後只回部分列, 卻刪除全部符合where者);
379
+ * 帶非空之include時, findAll以INNER JOIN篩列(required)而destroy不JOIN; 兩者亦拒絕
380
+ * 註: defaultScope.where含Op.and時, sequelize以Object.assign合併scope與cvFind輸出之where, 後者頂層恆為Op.and而覆寫scope之條件(select與delAll皆然),
381
+ * delAll會刪到scope範圍外之列, 故拒絕; 其他鍵(含Op.or)與cvFind輸出之Op.and並存而以AND結合, 不受影響
378
382
  *
379
383
  * @ignore
380
384
  * @param {Object} md 輸入資料表model物件
@@ -382,8 +386,27 @@ function WOrmReladb(opt = {}) {
382
386
  */
383
387
  function chkScopeForDelAll(md) {
384
388
  let sc = get(md, '_scope', {})
385
- if (get(sc, 'limit') !== undefined || get(sc, 'offset') !== undefined) {
386
- throw new Error(`model [${opt.cl}] has defaultScope with limit or offset, delAll can not delete the same rows as select`)
389
+ let bads = []
390
+ for (let k of ['limit', 'offset']) {
391
+ if (get(sc, k) !== undefined) {
392
+ bads.push(k)
393
+ }
394
+ }
395
+ for (let k of ['group', 'having']) {
396
+ let v = get(sc, k)
397
+ if (v !== undefined &amp;&amp; v !== null &amp;&amp; !(Array.isArray(v) &amp;&amp; v.length === 0)) {
398
+ bads.push(k)
399
+ }
400
+ }
401
+ if (isearr(get(sc, 'include'))) {
402
+ bads.push('include')
403
+ }
404
+ let w = get(sc, 'where')
405
+ if (w !== null &amp;&amp; typeof w === 'object' &amp;&amp; Object.prototype.hasOwnProperty.call(w, Sequelize.Op.and)) {
406
+ bads.push('where[Op.and]')
407
+ }
408
+ if (bads.length > 0) {
409
+ throw new Error(`model [${opt.cl}] has defaultScope with ${bads.join(', ')}, delAll can not delete the same rows as select`)
387
410
  }
388
411
  }
389
412
 
@@ -1897,7 +1920,7 @@ export default WOrmReladb
1897
1920
  <br class="clear">
1898
1921
 
1899
1922
  <footer>
1900
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Fri Oct 16 2026 14:32:44 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
1923
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Fri Oct 16 2026 19:47:28 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
1901
1924
  </footer>
1902
1925
 
1903
1926
  <script>prettyPrint();</script>