@inflector/optima 1.0.17 → 1.0.19

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.
Files changed (2) hide show
  1. package/dist/index.js +13 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -421,7 +421,7 @@ var escape = (val) => {
421
421
  return String(val);
422
422
  };
423
423
  var SQL_GENERATORS = {
424
- eq: (c, v) => `${c} = ${escape(v)}`,
424
+ eq: (c, v) => v === null ? `${c} IS NULL` : `${c} = ${escape(v)}`,
425
425
  ne: (c, v) => `${c} != ${escape(v)}`,
426
426
  gt: (c, v) => `${c} > ${escape(v)}`,
427
427
  gte: (c, v) => `${c} >= ${escape(v)}`,
@@ -476,7 +476,11 @@ var OptimaTable = class _OptimaTable {
476
476
  } else if (val && typeof val === "object" && !Array.isArray(val) && !(val instanceof Date)) {
477
477
  processLevel(val, colName);
478
478
  } else {
479
- conditions.push(SQL_GENERATORS.eq(colName, val));
479
+ if (val === null) {
480
+ conditions.push(SQL_GENERATORS.is(colName, null));
481
+ } else {
482
+ conditions.push(SQL_GENERATORS.eq(colName, val));
483
+ }
480
484
  }
481
485
  }
482
486
  };
@@ -518,8 +522,12 @@ var OptimaTable = class _OptimaTable {
518
522
  const orderedValues = columnKeys.map((key) => {
519
523
  let v = r[key];
520
524
  if (v == null) {
521
- if (typeof this.Columns[key].config.default === "function") {
522
- v = this.Columns[key].config.default();
525
+ if (this.Columns[key].config.default !== void 0) {
526
+ if (typeof this.Columns[key].config.default === "function") {
527
+ v = this.Columns[key].config.default();
528
+ } else {
529
+ v = this.Columns[key].config.default;
530
+ }
523
531
  } else if (this.Columns[key].config.defaultNow) {
524
532
  v = /* @__PURE__ */ new Date();
525
533
  }
@@ -667,6 +675,7 @@ ${valuesBlock}${isReturning ? "\nRETURNING *" : ""};`;
667
675
  this.Validate(record);
668
676
  record = this.Transform(record);
669
677
  const { sql } = this.BuildInsert(this.Name, [record], data.returning);
678
+ console.log(sql);
670
679
  const Result = await (await this.Connection.run(sql)).getRowObjects();
671
680
  const Res = this.FormatOut(Result);
672
681
  if (Res.length != 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inflector/optima",
3
- "version": "1.0.17",
3
+ "version": "1.0.19",
4
4
  "type": "module",
5
5
  "author": "Inflector",
6
6
  "main": "./dist/index.js",