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.
@@ -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
- knex2.QueryBuilder.extend("onDuplicateUpdate", function(...columns) {
4764
- if (columns.length === 0) {
4765
- const { sql: originalSQL2, bindings: originalBindings2 } = this.toSQL();
4766
- return this.client.raw(originalSQL2, originalBindings2);
4767
- }
4768
- const { placeholders, bindings } = columns.reduce(
4769
- (result, column) => {
4770
- if (typeof column === "string") {
4771
- result.placeholders.push(`?? = Values(??)`);
4772
- result.bindings.push(column, column);
4773
- } else if (column && typeof column === "object") {
4774
- Object.keys(column).forEach((key) => {
4775
- result.placeholders.push(`?? = ?`);
4776
- result.bindings.push(key, column[key]);
4777
- });
4778
- } else {
4779
- throw new Error(
4780
- "onDuplicateUpdate error: expected column name to be string or object."
4781
- );
4782
- }
4783
- return result;
4784
- },
4785
- { placeholders: [], bindings: [] }
4786
- );
4787
- const { sql: originalSQL, bindings: originalBindings } = this.toSQL();
4788
- const newBindings = [...originalBindings, ...bindings];
4789
- return this.client.raw(
4790
- `${originalSQL} ON DUPLICATE KEY UPDATE ${placeholders.join(", ")}`,
4791
- newBindings
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-5B6LB6JU.mjs.map
7447
+ //# sourceMappingURL=chunk-FOD6BJQJ.mjs.map