remult 0.23.0-exp.16 → 0.23.0-exp.18

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.
@@ -75,10 +75,11 @@ declare abstract class rowHelperBase<T> {
75
75
  protected columnsInfo: FieldOptions[];
76
76
  protected instance: T;
77
77
  protected remult: Remult;
78
+ protected isNewRow: boolean;
78
79
  _error: string;
79
80
  get error(): string;
80
81
  set error(val: string);
81
- constructor(columnsInfo: FieldOptions[], instance: T, remult: Remult);
82
+ constructor(columnsInfo: FieldOptions[], instance: T, remult: Remult, isNewRow: boolean);
82
83
  _subscribers: SubscribableImp;
83
84
  subscribe(listener: RefSubscriber): Unsubscribe;
84
85
  _isLoading: boolean;
@@ -442,7 +442,7 @@ export class RepositoryImplementation {
442
442
  row[col.key] =
443
443
  rel.type !== 'toMany'
444
444
  ? result.length == 0
445
- ? undefined
445
+ ? null
446
446
  : result[0]
447
447
  : result;
448
448
  });
@@ -789,6 +789,7 @@ class rowHelperBase {
789
789
  columnsInfo;
790
790
  instance;
791
791
  remult;
792
+ isNewRow;
792
793
  _error;
793
794
  get error() {
794
795
  this._subscribers?.reportObserved();
@@ -798,10 +799,11 @@ class rowHelperBase {
798
799
  this._error = val;
799
800
  this._subscribers?.reportChanged();
800
801
  }
801
- constructor(columnsInfo, instance, remult) {
802
+ constructor(columnsInfo, instance, remult, isNewRow) {
802
803
  this.columnsInfo = columnsInfo;
803
804
  this.instance = instance;
804
805
  this.remult = remult;
806
+ this.isNewRow = isNewRow;
805
807
  {
806
808
  let fac = remult;
807
809
  if (fac != null && fac.remultFactory) {
@@ -847,6 +849,8 @@ class rowHelperBase {
847
849
  else if (getRelationInfo(col)?.type === 'toOne') {
848
850
  let hasVal = instance.hasOwnProperty(col.key);
849
851
  let val = instance[col.key];
852
+ if (isNewRow && !val)
853
+ hasVal = false;
850
854
  Object.defineProperty(instance, col.key, {
851
855
  get: () => {
852
856
  return val;
@@ -1091,7 +1095,7 @@ export class rowHelperImplementation extends rowHelperBase {
1091
1095
  edp;
1092
1096
  _isNew;
1093
1097
  constructor(info, instance, repository, edp, remult, _isNew) {
1094
- super(info.columnsInfo, instance, remult);
1098
+ super(info.columnsInfo, instance, remult, _isNew);
1095
1099
  this.info = info;
1096
1100
  this.repository = repository;
1097
1101
  this.edp = edp;
@@ -1397,7 +1401,7 @@ export function getControllerRef(container, remultArg) {
1397
1401
  }
1398
1402
  export class controllerRefImpl extends rowHelperBase {
1399
1403
  constructor(columnsInfo, instance, remult) {
1400
- super(columnsInfo, instance, remult);
1404
+ super(columnsInfo, instance, remult, false);
1401
1405
  let _items = [];
1402
1406
  let r = {
1403
1407
  find: (c) => r[typeof c === 'string' ? c : c.key],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remult",
3
- "version": "0.23.0-exp.16",
3
+ "version": "0.23.0-exp.18",
4
4
  "description": "A CRUD framework for full-stack TypeScript",
5
5
  "types": "index.d.ts",
6
6
  "module": "esm/index.js",
@@ -75,10 +75,11 @@ declare abstract class rowHelperBase<T> {
75
75
  protected columnsInfo: FieldOptions[];
76
76
  protected instance: T;
77
77
  protected remult: Remult;
78
+ protected isNewRow: boolean;
78
79
  _error: string;
79
80
  get error(): string;
80
81
  set error(val: string);
81
- constructor(columnsInfo: FieldOptions[], instance: T, remult: Remult);
82
+ constructor(columnsInfo: FieldOptions[], instance: T, remult: Remult, isNewRow: boolean);
82
83
  _subscribers: SubscribableImp;
83
84
  subscribe(listener: RefSubscriber): Unsubscribe;
84
85
  _isLoading: boolean;
@@ -734,7 +734,7 @@ var RepositoryImplementation = /** @class */ (function () {
734
734
  row[col.key] =
735
735
  rel.type !== 'toMany'
736
736
  ? result.length == 0
737
- ? undefined
737
+ ? null
738
738
  : result[0]
739
739
  : result;
740
740
  });
@@ -1264,13 +1264,14 @@ function createOldEntity(entity, remult) {
1264
1264
  }
1265
1265
  exports.createOldEntity = createOldEntity;
1266
1266
  var rowHelperBase = /** @class */ (function () {
1267
- function rowHelperBase(columnsInfo, instance, remult) {
1267
+ function rowHelperBase(columnsInfo, instance, remult, isNewRow) {
1268
1268
  var e_21, _a;
1269
1269
  var _this = this;
1270
1270
  var _b;
1271
1271
  this.columnsInfo = columnsInfo;
1272
1272
  this.instance = instance;
1273
1273
  this.remult = remult;
1274
+ this.isNewRow = isNewRow;
1274
1275
  this._isLoading = false;
1275
1276
  this.lookups = new Map();
1276
1277
  this.originalValues = {};
@@ -1320,6 +1321,8 @@ var rowHelperBase = /** @class */ (function () {
1320
1321
  else if (((_b = (0, relationInfoMember_1.getRelationInfo)(col)) === null || _b === void 0 ? void 0 : _b.type) === 'toOne') {
1321
1322
  var hasVal = instance.hasOwnProperty(col.key);
1322
1323
  var val_1 = instance[col.key];
1324
+ if (isNewRow && !val_1)
1325
+ hasVal = false;
1323
1326
  Object.defineProperty(instance, col.key, {
1324
1327
  get: function () {
1325
1328
  return val_1;
@@ -1718,7 +1721,7 @@ var rowHelperImplementation = /** @class */ (function (_super) {
1718
1721
  tslib_1.__extends(rowHelperImplementation, _super);
1719
1722
  function rowHelperImplementation(info, instance, repository, edp, remult, _isNew) {
1720
1723
  var e_28, _a;
1721
- var _this = _super.call(this, info.columnsInfo, instance, remult) || this;
1724
+ var _this = _super.call(this, info.columnsInfo, instance, remult, _isNew) || this;
1722
1725
  _this.info = info;
1723
1726
  _this.repository = repository;
1724
1727
  _this.edp = edp;
@@ -2368,7 +2371,7 @@ var controllerRefImpl = /** @class */ (function (_super) {
2368
2371
  tslib_1.__extends(controllerRefImpl, _super);
2369
2372
  function controllerRefImpl(columnsInfo, instance, remult) {
2370
2373
  var _a, e_39, _b;
2371
- var _this = _super.call(this, columnsInfo, instance, remult) || this;
2374
+ var _this = _super.call(this, columnsInfo, instance, remult, false) || this;
2372
2375
  var _items = [];
2373
2376
  var r = (_a = {
2374
2377
  find: function (c) {