jsql-neo 2.1.0 → 2.1.2
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/lib/table.js +10 -1
- package/package.json +1 -1
package/lib/table.js
CHANGED
|
@@ -715,13 +715,22 @@ class Table {
|
|
|
715
715
|
throw createError('ER_BAD_NULL_ERROR', field);
|
|
716
716
|
}
|
|
717
717
|
|
|
718
|
-
// UNIQUE
|
|
718
|
+
// UNIQUE(B-Tree 优化 O(log n))
|
|
719
719
|
if (def.unique && data[field] !== undefined) {
|
|
720
720
|
if (uniqueTracker && uniqueTracker[field]) {
|
|
721
721
|
if (uniqueTracker[field].has(data[field])) {
|
|
722
722
|
throw createError('ER_DUP_ENTRY', String(data[field]), field);
|
|
723
723
|
}
|
|
724
724
|
uniqueTracker[field].add(data[field]);
|
|
725
|
+
} else if (this._btrees[field]) {
|
|
726
|
+
const found = this._btrees[field].search(data[field]);
|
|
727
|
+
if (found.length > 0) {
|
|
728
|
+
for (const idx of found) {
|
|
729
|
+
if (idx !== excludeIndex && this._rows[idx] && this._rows[idx][field] === data[field]) {
|
|
730
|
+
throw createError('ER_DUP_ENTRY', String(data[field]), field);
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
}
|
|
725
734
|
} else {
|
|
726
735
|
for (let i = 0; i < this._rows.length; i++) {
|
|
727
736
|
if (i === excludeIndex) continue;
|
package/package.json
CHANGED