sonamu 0.2.43 → 0.2.44
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/dist/bin/cli.js +48 -48
- package/dist/bin/cli.mjs +1 -1
- package/dist/{chunk-COTJCJ2O.js → chunk-EYNTBWQC.js} +36 -32
- package/dist/chunk-EYNTBWQC.js.map +1 -0
- package/dist/{chunk-5B6LB6JU.mjs → chunk-FOD6BJQJ.mjs} +36 -32
- package/dist/{chunk-5B6LB6JU.mjs.map → chunk-FOD6BJQJ.mjs.map} +1 -1
- package/dist/index.js +3 -3
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/src/database/knex-plugins/knex-on-duplicate-update.ts +36 -32
- package/tsup.config.js +17 -2
- package/dist/chunk-COTJCJ2O.js.map +0 -1
|
@@ -4760,37 +4760,41 @@ import fs3 from "fs-extra";
|
|
|
4760
4760
|
// src/database/knex-plugins/knex-on-duplicate-update.ts
|
|
4761
4761
|
import knex2 from "knex";
|
|
4762
4762
|
function attachOnDuplicateUpdate() {
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
4763
|
+
try {
|
|
4764
|
+
knex2.QueryBuilder.extend("onDuplicateUpdate", function(...columns) {
|
|
4765
|
+
if (columns.length === 0) {
|
|
4766
|
+
const { sql: originalSQL2, bindings: originalBindings2 } = this.toSQL();
|
|
4767
|
+
return this.client.raw(originalSQL2, originalBindings2);
|
|
4768
|
+
}
|
|
4769
|
+
const { placeholders, bindings } = columns.reduce(
|
|
4770
|
+
(result, column) => {
|
|
4771
|
+
if (typeof column === "string") {
|
|
4772
|
+
result.placeholders.push(`?? = Values(??)`);
|
|
4773
|
+
result.bindings.push(column, column);
|
|
4774
|
+
} else if (column && typeof column === "object") {
|
|
4775
|
+
Object.keys(column).forEach((key) => {
|
|
4776
|
+
result.placeholders.push(`?? = ?`);
|
|
4777
|
+
result.bindings.push(key, column[key]);
|
|
4778
|
+
});
|
|
4779
|
+
} else {
|
|
4780
|
+
throw new Error(
|
|
4781
|
+
"onDuplicateUpdate error: expected column name to be string or object."
|
|
4782
|
+
);
|
|
4783
|
+
}
|
|
4784
|
+
return result;
|
|
4785
|
+
},
|
|
4786
|
+
{ placeholders: [], bindings: [] }
|
|
4787
|
+
);
|
|
4788
|
+
const { sql: originalSQL, bindings: originalBindings } = this.toSQL();
|
|
4789
|
+
const newBindings = [...originalBindings, ...bindings];
|
|
4790
|
+
return this.client.raw(
|
|
4791
|
+
`${originalSQL} ON DUPLICATE KEY UPDATE ${placeholders.join(", ")}`,
|
|
4792
|
+
newBindings
|
|
4793
|
+
);
|
|
4794
|
+
});
|
|
4795
|
+
} catch {
|
|
4796
|
+
console.log("already attached");
|
|
4797
|
+
}
|
|
4794
4798
|
}
|
|
4795
4799
|
|
|
4796
4800
|
// src/api/sonamu.ts
|
|
@@ -7440,4 +7444,4 @@ export {
|
|
|
7440
7444
|
FixtureManagerClass,
|
|
7441
7445
|
FixtureManager
|
|
7442
7446
|
};
|
|
7443
|
-
//# sourceMappingURL=chunk-
|
|
7447
|
+
//# sourceMappingURL=chunk-FOD6BJQJ.mjs.map
|