sonamu 0.2.41 → 0.2.43

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.
@@ -4217,44 +4217,6 @@ var DB = new DBClass();
4217
4217
  var _luxon = require('luxon');
4218
4218
 
4219
4219
 
4220
- // src/database/knex-plugins/knex-on-duplicate-update.ts
4221
-
4222
- function attachOnDuplicateUpdate() {
4223
- _knex2.default.QueryBuilder.extend("onDuplicateUpdate", function(...columns) {
4224
- if (columns.length === 0) {
4225
- const { sql: originalSQL2, bindings: originalBindings2 } = this.toSQL();
4226
- return this.client.raw(originalSQL2, originalBindings2);
4227
- }
4228
- const { placeholders, bindings } = columns.reduce(
4229
- (result, column) => {
4230
- if (typeof column === "string") {
4231
- result.placeholders.push(`?? = Values(??)`);
4232
- result.bindings.push(column, column);
4233
- } else if (column && typeof column === "object") {
4234
- Object.keys(column).forEach((key) => {
4235
- result.placeholders.push(`?? = ?`);
4236
- result.bindings.push(key, column[key]);
4237
- });
4238
- } else {
4239
- throw new Error(
4240
- "onDuplicateUpdate error: expected column name to be string or object."
4241
- );
4242
- }
4243
- return result;
4244
- },
4245
- { placeholders: [], bindings: [] }
4246
- );
4247
- const { sql: originalSQL, bindings: originalBindings } = this.toSQL();
4248
- const newBindings = [...originalBindings, ...bindings];
4249
- return this.client.raw(
4250
- `${originalSQL} ON DUPLICATE KEY UPDATE ${placeholders.join(", ")}`,
4251
- newBindings
4252
- );
4253
- });
4254
- }
4255
-
4256
- // src/database/base-model.ts
4257
-
4258
4220
 
4259
4221
 
4260
4222
  // src/database/upsert-builder.ts
@@ -4546,7 +4508,6 @@ function getTableNamesFromWhere(ast) {
4546
4508
  }
4547
4509
 
4548
4510
  // src/database/base-model.ts
4549
- _lodash.once.call(void 0, () => attachOnDuplicateUpdate());
4550
4511
  var BaseModelClass = class {
4551
4512
  constructor() {
4552
4513
  this.modelName = "Unknown";
@@ -4796,6 +4757,44 @@ var BaseModel = new BaseModelClass();
4796
4757
  // src/api/sonamu.ts
4797
4758
 
4798
4759
 
4760
+
4761
+ // src/database/knex-plugins/knex-on-duplicate-update.ts
4762
+
4763
+ function attachOnDuplicateUpdate() {
4764
+ _knex2.default.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
+ }
4796
+
4797
+ // src/api/sonamu.ts
4799
4798
  var SonamuClass = class {
4800
4799
  constructor() {
4801
4800
  this.isInitialized = false;
@@ -4858,6 +4857,7 @@ var SonamuClass = class {
4858
4857
  );
4859
4858
  this.dbConfig = await DB.readKnexfile();
4860
4859
  !doSilent && console.log(_chalk2.default.green("DB Config Loaded!"));
4860
+ attachOnDuplicateUpdate();
4861
4861
  await EntityManager.autoload(doSilent);
4862
4862
  this.syncer = new Syncer();
4863
4863
  await this.syncer.autoloadModels();
@@ -7441,4 +7441,4 @@ var FixtureManager = new FixtureManagerClass();
7441
7441
 
7442
7442
 
7443
7443
  exports.SQLDateTimeString = SQLDateTimeString; exports.zArrayable = zArrayable; exports.isIntegerProp = isIntegerProp; exports.isBigIntegerProp = isBigIntegerProp; exports.isTextProp = isTextProp; exports.isStringProp = isStringProp; exports.isEnumProp = isEnumProp; exports.isFloatProp = isFloatProp; exports.isDoubleProp = isDoubleProp; exports.isDecimalProp = isDecimalProp; exports.isBooleanProp = isBooleanProp; exports.isDateProp = isDateProp; exports.isDateTimeProp = isDateTimeProp; exports.isTimeProp = isTimeProp; exports.isTimestampProp = isTimestampProp; exports.isJsonProp = isJsonProp; exports.isUuidProp = isUuidProp; exports.isVirtualProp = isVirtualProp; exports.isRelationProp = isRelationProp; exports.isOneToOneRelationProp = isOneToOneRelationProp; exports.isBelongsToOneRelationProp = isBelongsToOneRelationProp; exports.isHasManyRelationProp = isHasManyRelationProp; exports.isManyToManyRelationProp = isManyToManyRelationProp; exports.isCustomJoinClause = isCustomJoinClause; exports.SonamuQueryMode = SonamuQueryMode; exports.isKnexError = isKnexError; exports.ApiParamType = ApiParamType; exports.RenderingNode = RenderingNode; exports.TemplateOptions = TemplateOptions; exports.TemplateKey = TemplateKey; exports.GenerateOptions = GenerateOptions; exports.PathAndCode = PathAndCode; exports.getZodObjectFromApi = getZodObjectFromApi; exports.getZodObjectFromApiParams = getZodObjectFromApiParams; exports.getZodTypeFromApiParamType = getZodTypeFromApiParamType; exports.propNodeToZodTypeDef = propNodeToZodTypeDef; exports.getTextTypeLength = getTextTypeLength; exports.propToZodTypeDef = propToZodTypeDef; exports.zodTypeToZodCode = zodTypeToZodCode; exports.apiParamToTsCode = apiParamToTsCode; exports.apiParamTypeToTsType = apiParamTypeToTsType; exports.unwrapPromiseOnce = unwrapPromiseOnce; exports.serializeZodType = serializeZodType; exports.zodTypeToTsTypeDef = zodTypeToTsTypeDef; exports.registeredApis = registeredApis; exports.api = api; exports.SoException = SoException; exports.isSoException = isSoException; exports.BadRequestException = BadRequestException; exports.UnauthorizedException = UnauthorizedException; exports.NotFoundException = NotFoundException; exports.ServiceUnavailableException = ServiceUnavailableException; exports.InternalServerErrorException = InternalServerErrorException; exports.AlreadyProcessedException = AlreadyProcessedException; exports.DuplicateRowException = DuplicateRowException; exports.TargetNotFoundException = TargetNotFoundException; exports.globAsync = globAsync; exports.importMultiple = importMultiple; exports.findAppRootPath = findAppRootPath; exports.findApiRootPath = findApiRootPath; exports.nonNullable = nonNullable; exports.EntityManager = EntityManager; exports.Syncer = Syncer; exports.isLocal = isLocal; exports.isRemote = isRemote; exports.isInDocker = isInDocker; exports.isDaemonServer = isDaemonServer; exports.isDevelopment = isDevelopment; exports.isStaging = isStaging; exports.isProduction = isProduction; exports.isTest = isTest; exports.DB = DB; exports.isRefField = isRefField; exports.UpsertBuilder = UpsertBuilder; exports.BaseModelClass = BaseModelClass; exports.BaseModel = BaseModel; exports.Sonamu = Sonamu; exports.Migrator = Migrator; exports.FixtureManagerClass = FixtureManagerClass; exports.FixtureManager = FixtureManager;
7444
- //# sourceMappingURL=chunk-BNFMNGGY.js.map
7444
+ //# sourceMappingURL=chunk-COTJCJ2O.js.map