|
|
@ -1713,13 +1713,14 @@ class BaseModelSqlv2 { |
|
|
|
)) as LinkToAnotherRecordColumn |
|
|
|
)) as LinkToAnotherRecordColumn |
|
|
|
).getParentColumn(this.context); |
|
|
|
).getParentColumn(this.context); |
|
|
|
const parentTable = await parentCol.getModel(this.context); |
|
|
|
const parentTable = await parentCol.getModel(this.context); |
|
|
|
const childModel = await Model.getBaseModelSQL(this.context, { |
|
|
|
const childBaseModel = await Model.getBaseModelSQL(this.context, { |
|
|
|
model: childTable, |
|
|
|
model: childTable, |
|
|
|
dbDriver: this.dbDriver, |
|
|
|
dbDriver: this.dbDriver, |
|
|
|
}); |
|
|
|
}); |
|
|
|
await parentTable.getColumns(this.context); |
|
|
|
await parentTable.getColumns(this.context); |
|
|
|
|
|
|
|
|
|
|
|
const childTn = this.getTnPath(childTable); |
|
|
|
|
|
|
|
|
|
|
|
const childTn = childBaseModel.getTnPath(childTable); |
|
|
|
const parentTn = this.getTnPath(parentTable); |
|
|
|
const parentTn = this.getTnPath(parentTable); |
|
|
|
|
|
|
|
|
|
|
|
const qb = this.dbDriver(childTn); |
|
|
|
const qb = this.dbDriver(childTn); |
|
|
@ -1736,7 +1737,7 @@ class BaseModelSqlv2 { |
|
|
|
qb.limit(+rest?.limit || 25); |
|
|
|
qb.limit(+rest?.limit || 25); |
|
|
|
qb.offset(+rest?.offset || 0); |
|
|
|
qb.offset(+rest?.offset || 0); |
|
|
|
|
|
|
|
|
|
|
|
await childModel.selectObject({ |
|
|
|
await childBaseModel.selectObject({ |
|
|
|
qb, |
|
|
|
qb, |
|
|
|
fieldsSet: args.fieldSet, |
|
|
|
fieldsSet: args.fieldSet, |
|
|
|
}); |
|
|
|
}); |
|
|
@ -1790,7 +1791,11 @@ class BaseModelSqlv2 { |
|
|
|
const parentTable = await parentCol.getModel(this.context); |
|
|
|
const parentTable = await parentCol.getModel(this.context); |
|
|
|
await parentTable.getColumns(this.context); |
|
|
|
await parentTable.getColumns(this.context); |
|
|
|
|
|
|
|
|
|
|
|
const childTn = this.getTnPath(childTable); |
|
|
|
const childBaseModel = await Model.getBaseModelSQL({ |
|
|
|
|
|
|
|
dbDriver: this.dbDriver, |
|
|
|
|
|
|
|
model: childTable, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
const childTn = childBaseModel.getTnPath(childTable); |
|
|
|
const parentTn = this.getTnPath(parentTable); |
|
|
|
const parentTn = this.getTnPath(parentTable); |
|
|
|
|
|
|
|
|
|
|
|
const query = this.dbDriver(childTn) |
|
|
|
const query = this.dbDriver(childTn) |
|
|
@ -1945,7 +1950,12 @@ class BaseModelSqlv2 { |
|
|
|
)) as LinkToAnotherRecordColumn; |
|
|
|
)) as LinkToAnotherRecordColumn; |
|
|
|
|
|
|
|
|
|
|
|
const mmTable = await relColOptions.getMMModel(this.context); |
|
|
|
const mmTable = await relColOptions.getMMModel(this.context); |
|
|
|
const vtn = this.getTnPath(mmTable); |
|
|
|
const assocBaseModel = await Model.getBaseModelSQL({ |
|
|
|
|
|
|
|
id: mmTable.id, |
|
|
|
|
|
|
|
dbDriver: this.dbDriver, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const vtn = assocBaseModel.getTnPath(mmTable); |
|
|
|
const vcn = (await relColOptions.getMMChildColumn(this.context)) |
|
|
|
const vcn = (await relColOptions.getMMChildColumn(this.context)) |
|
|
|
.column_name; |
|
|
|
.column_name; |
|
|
|
const vrcn = (await relColOptions.getMMParentColumn(this.context)) |
|
|
|
const vrcn = (await relColOptions.getMMParentColumn(this.context)) |
|
|
@ -1980,8 +1990,12 @@ class BaseModelSqlv2 { |
|
|
|
).getModel(this.context); |
|
|
|
).getModel(this.context); |
|
|
|
await parentTable.getColumns(this.context); |
|
|
|
await parentTable.getColumns(this.context); |
|
|
|
|
|
|
|
|
|
|
|
const childTn = this.getTnPath(childTable); |
|
|
|
const parentBaseModel = await Model.getBaseModelSQL({ |
|
|
|
const parentTn = this.getTnPath(parentTable); |
|
|
|
id: parentTable.id, |
|
|
|
|
|
|
|
dbDriver: this.dbDriver, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
const childTn = childBaseModel.getTnPath(childTable); |
|
|
|
|
|
|
|
const parentTn = parentBaseModel.getTnPath(parentTable); |
|
|
|
|
|
|
|
|
|
|
|
const rtn = childTn; |
|
|
|
const rtn = childTn; |
|
|
|
const qb = this.dbDriver(rtn) |
|
|
|
const qb = this.dbDriver(rtn) |
|
|
@ -2096,7 +2110,13 @@ class BaseModelSqlv2 { |
|
|
|
)) as LinkToAnotherRecordColumn; |
|
|
|
)) as LinkToAnotherRecordColumn; |
|
|
|
|
|
|
|
|
|
|
|
const mmTable = await relColOptions.getMMModel(this.context); |
|
|
|
const mmTable = await relColOptions.getMMModel(this.context); |
|
|
|
const vtn = this.getTnPath(mmTable); |
|
|
|
|
|
|
|
|
|
|
|
const assocBaseModel = await Model.getBaseModelSQL({ |
|
|
|
|
|
|
|
model: mmTable, |
|
|
|
|
|
|
|
dbDriver: this.dbDriver, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const vtn = assocBaseModel.getTnPath(mmTable); |
|
|
|
const vcn = (await relColOptions.getMMChildColumn(this.context)) |
|
|
|
const vcn = (await relColOptions.getMMChildColumn(this.context)) |
|
|
|
.column_name; |
|
|
|
.column_name; |
|
|
|
const vrcn = (await relColOptions.getMMParentColumn(this.context)) |
|
|
|
const vrcn = (await relColOptions.getMMParentColumn(this.context)) |
|
|
@ -2112,7 +2132,12 @@ class BaseModelSqlv2 { |
|
|
|
).getModel(this.context); |
|
|
|
).getModel(this.context); |
|
|
|
await parentTable.getColumns(this.context); |
|
|
|
await parentTable.getColumns(this.context); |
|
|
|
|
|
|
|
|
|
|
|
const childTn = this.getTnPath(childTable); |
|
|
|
const childBaseModel = await Model.getBaseModelSQL({ |
|
|
|
|
|
|
|
dbDriver: this.dbDriver, |
|
|
|
|
|
|
|
model: childTable, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const childTn = childBaseModel.getTnPath(childTable); |
|
|
|
const parentTn = this.getTnPath(parentTable); |
|
|
|
const parentTn = this.getTnPath(parentTable); |
|
|
|
|
|
|
|
|
|
|
|
const rtn = childTn; |
|
|
|
const rtn = childTn; |
|
|
@ -2162,20 +2187,33 @@ class BaseModelSqlv2 { |
|
|
|
)) as LinkToAnotherRecordColumn; |
|
|
|
)) as LinkToAnotherRecordColumn; |
|
|
|
|
|
|
|
|
|
|
|
const mmTable = await relColOptions.getMMModel(this.context); |
|
|
|
const mmTable = await relColOptions.getMMModel(this.context); |
|
|
|
const vtn = this.getTnPath(mmTable); |
|
|
|
const assocBaseModel = await Model.getBaseModelSQL({ |
|
|
|
|
|
|
|
id: mmTable.id, |
|
|
|
|
|
|
|
dbDriver: this.dbDriver, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const vtn = assocBaseModel.getTnPath(mmTable); |
|
|
|
const vcn = (await relColOptions.getMMChildColumn(this.context)) |
|
|
|
const vcn = (await relColOptions.getMMChildColumn(this.context)) |
|
|
|
.column_name; |
|
|
|
.column_name; |
|
|
|
const vrcn = (await relColOptions.getMMParentColumn(this.context)) |
|
|
|
const vrcn = (await relColOptions.getMMParentColumn(this.context)) |
|
|
|
.column_name; |
|
|
|
.column_name; |
|
|
|
const rcn = (await relColOptions.getParentColumn(this.context)).column_name; |
|
|
|
const rcn = (await relColOptions.getParentColumn(this.context)).column_name; |
|
|
|
const cn = (await relColOptions.getChildColumn(this.context)).column_name; |
|
|
|
const cn = (await relColOptions.getChildColumn(this.context)).column_name; |
|
|
|
const childTable = await ( |
|
|
|
|
|
|
|
await relColOptions.getParentColumn(this.context) |
|
|
|
const childTable = await (await relColOptions.getParentColumn(this.cotext)).getModel(this.cotext); |
|
|
|
).getModel(this.context); |
|
|
|
const parentTable = await (await relColOptions.getChildColumn(this.cotext)).getModel(this.cotext); |
|
|
|
const childModel = await Model.getBaseModelSQL(this.context, { |
|
|
|
await parentTable.getColumns(); |
|
|
|
|
|
|
|
const parentBaseModel = await Model.getBaseModelSQL({ |
|
|
|
|
|
|
|
id: parentTable.id, |
|
|
|
dbDriver: this.dbDriver, |
|
|
|
dbDriver: this.dbDriver, |
|
|
|
model: childTable, |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
const childBaseModel = await Model.getBaseModelSQL({ |
|
|
|
|
|
|
|
dbDriver: this.dbDriver, |
|
|
|
|
|
|
|
id: childTable.id, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
const childTn = childBaseModel.getTnPath(childTable); |
|
|
|
|
|
|
|
const parentTn = parentBaseModel.getTnPath(parentTable); |
|
|
|
|
|
|
|
|
|
|
|
const childView = await relColOptions.getChildView(this.context); |
|
|
|
const childView = await relColOptions.getChildView(this.context); |
|
|
|
let listArgs: any = {}; |
|
|
|
let listArgs: any = {}; |
|
|
|
if (childView) { |
|
|
|
if (childView) { |
|
|
@ -2188,14 +2226,6 @@ class BaseModelSqlv2 { |
|
|
|
listArgs = dependencyFields; |
|
|
|
listArgs = dependencyFields; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const parentTable = await ( |
|
|
|
|
|
|
|
await relColOptions.getChildColumn(this.context) |
|
|
|
|
|
|
|
).getModel(this.context); |
|
|
|
|
|
|
|
await parentTable.getColumns(this.context); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const childTn = this.getTnPath(childTable); |
|
|
|
|
|
|
|
const parentTn = this.getTnPath(parentTable); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const rtn = childTn; |
|
|
|
const rtn = childTn; |
|
|
|
|
|
|
|
|
|
|
|
const qb = this.dbDriver(rtn).where((qb) => |
|
|
|
const qb = this.dbDriver(rtn).where((qb) => |
|
|
@ -2288,8 +2318,8 @@ class BaseModelSqlv2 { |
|
|
|
|
|
|
|
|
|
|
|
const childView = await relColOptions.getChildView(this.context); |
|
|
|
const childView = await relColOptions.getChildView(this.context); |
|
|
|
|
|
|
|
|
|
|
|
const childTn = this.getTnPath(childTable); |
|
|
|
const childTn = childBaseModel.getTnPath(childTable); |
|
|
|
const parentTn = this.getTnPath(parentTable); |
|
|
|
const parentTn = parentBaseModel.getTnPath(parentTable); |
|
|
|
|
|
|
|
|
|
|
|
const tn = childTn; |
|
|
|
const tn = childTn; |
|
|
|
const rtn = parentTn; |
|
|
|
const rtn = parentTn; |
|
|
@ -2308,7 +2338,7 @@ class BaseModelSqlv2 { |
|
|
|
await this.shuffle({ qb }); |
|
|
|
await this.shuffle({ qb }); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
await childModel.selectObject({ qb }); |
|
|
|
await childBaseModel.selectObject({ qb }); |
|
|
|
|
|
|
|
|
|
|
|
const aliasColObjMap = await childTable.getAliasColObjMap(this.context); |
|
|
|
const aliasColObjMap = await childTable.getAliasColObjMap(this.context); |
|
|
|
const filterObj = extractFilterFromXwhere(where, aliasColObjMap); |
|
|
|
const filterObj = extractFilterFromXwhere(where, aliasColObjMap); |
|
|
@ -2330,12 +2360,11 @@ class BaseModelSqlv2 { |
|
|
|
|
|
|
|
|
|
|
|
applyPaginate(qb, rest); |
|
|
|
applyPaginate(qb, rest); |
|
|
|
|
|
|
|
|
|
|
|
const proto = await childModel.getProto(); |
|
|
|
const proto = await childBaseModel.getProto(); |
|
|
|
const data = await this.execAndParse( |
|
|
|
const data = await this.execAndParse( |
|
|
|
qb, |
|
|
|
qb, |
|
|
|
await childTable.getColumns(this.context), |
|
|
|
await childTable.getColumns(this.context), |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
return data.map((c) => { |
|
|
|
return data.map((c) => { |
|
|
|
c.__proto__ = proto; |
|
|
|
c.__proto__ = proto; |
|
|
|
return c; |
|
|
|
return c; |
|
|
@ -2367,7 +2396,12 @@ class BaseModelSqlv2 { |
|
|
|
|
|
|
|
|
|
|
|
const childView = await relColOptions.getChildView(this.context); |
|
|
|
const childView = await relColOptions.getChildView(this.context); |
|
|
|
|
|
|
|
|
|
|
|
const childTn = this.getTnPath(childTable); |
|
|
|
const childBaseModel = await Model.getBaseModelSQL({ |
|
|
|
|
|
|
|
dbDriver: this.dbDriver, |
|
|
|
|
|
|
|
model: childTable, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const childTn = childBaseModel.getTnPath(childTable); |
|
|
|
const parentTn = this.getTnPath(parentTable); |
|
|
|
const parentTn = this.getTnPath(parentTable); |
|
|
|
|
|
|
|
|
|
|
|
const tn = childTn; |
|
|
|
const tn = childTn; |
|
|
@ -2431,7 +2465,12 @@ class BaseModelSqlv2 { |
|
|
|
dbDriver: this.dbDriver, |
|
|
|
dbDriver: this.dbDriver, |
|
|
|
model: childTable, |
|
|
|
model: childTable, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
const childBaseModel = await Model.getBaseModelSQL({ |
|
|
|
|
|
|
|
dbDriver: this.dbDriver, |
|
|
|
|
|
|
|
model: childTable, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const childTn = childBaseModel.getTnPath(childTable); |
|
|
|
const childView = await relColOptions.getChildView(this.context); |
|
|
|
const childView = await relColOptions.getChildView(this.context); |
|
|
|
let listArgs: any = {}; |
|
|
|
let listArgs: any = {}; |
|
|
|
if (childView) { |
|
|
|
if (childView) { |
|
|
@ -2530,8 +2569,13 @@ class BaseModelSqlv2 { |
|
|
|
await relColOptions.getChildColumn(this.context) |
|
|
|
await relColOptions.getChildColumn(this.context) |
|
|
|
).getModel(this.context); |
|
|
|
).getModel(this.context); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const parentBaseModel = await Model.getBaseModelSQL({ |
|
|
|
|
|
|
|
dbDriver: this.dbDriver, |
|
|
|
|
|
|
|
model: parentTable, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const childTn = this.getTnPath(childTable); |
|
|
|
const childTn = this.getTnPath(childTable); |
|
|
|
const parentTn = this.getTnPath(parentTable); |
|
|
|
const parentTn = parentBaseModel.getTnPath(parentTable); |
|
|
|
|
|
|
|
|
|
|
|
const rtn = parentTn; |
|
|
|
const rtn = parentTn; |
|
|
|
const tn = childTn; |
|
|
|
const tn = childTn; |
|
|
@ -2652,13 +2696,13 @@ class BaseModelSqlv2 { |
|
|
|
const childTable = await ( |
|
|
|
const childTable = await ( |
|
|
|
await relColOptions.getChildColumn(this.context) |
|
|
|
await relColOptions.getChildColumn(this.context) |
|
|
|
).getModel(this.context); |
|
|
|
).getModel(this.context); |
|
|
|
const parentModel = await Model.getBaseModelSQL(this.context, { |
|
|
|
const parentBaseModel = await Model.getBaseModelSQL(this.context, { |
|
|
|
dbDriver: this.dbDriver, |
|
|
|
dbDriver: this.dbDriver, |
|
|
|
model: parentTable, |
|
|
|
model: parentTable, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const childTn = this.getTnPath(childTable); |
|
|
|
const childTn = this.getTnPath(childTable); |
|
|
|
const parentTn = this.getTnPath(parentTable); |
|
|
|
const parentTn = parentBaseModel.getTnPath(parentTable); |
|
|
|
|
|
|
|
|
|
|
|
const rtn = parentTn; |
|
|
|
const rtn = parentTn; |
|
|
|
const tn = childTn; |
|
|
|
const tn = childTn; |
|
|
@ -2679,7 +2723,7 @@ class BaseModelSqlv2 { |
|
|
|
await this.shuffle({ qb }); |
|
|
|
await this.shuffle({ qb }); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
await parentModel.selectObject({ qb }); |
|
|
|
await parentBaseModel.selectObject({ qb }); |
|
|
|
|
|
|
|
|
|
|
|
const aliasColObjMap = await parentTable.getAliasColObjMap(this.context); |
|
|
|
const aliasColObjMap = await parentTable.getAliasColObjMap(this.context); |
|
|
|
const filterObj = extractFilterFromXwhere(where, aliasColObjMap); |
|
|
|
const filterObj = extractFilterFromXwhere(where, aliasColObjMap); |
|
|
@ -2706,7 +2750,7 @@ class BaseModelSqlv2 { |
|
|
|
|
|
|
|
|
|
|
|
applyPaginate(qb, rest); |
|
|
|
applyPaginate(qb, rest); |
|
|
|
|
|
|
|
|
|
|
|
const proto = await parentModel.getProto(); |
|
|
|
const proto = await parentBaseModel.getProto(); |
|
|
|
const data = await this.execAndParse( |
|
|
|
const data = await this.execAndParse( |
|
|
|
qb, |
|
|
|
qb, |
|
|
|
await parentTable.getColumns(this.context), |
|
|
|
await parentTable.getColumns(this.context), |
|
|
@ -5525,8 +5569,19 @@ class BaseModelSqlv2 { |
|
|
|
await childTable.getColumns(this.context); |
|
|
|
await childTable.getColumns(this.context); |
|
|
|
await parentTable.getColumns(this.context); |
|
|
|
await parentTable.getColumns(this.context); |
|
|
|
|
|
|
|
|
|
|
|
const childTn = this.getTnPath(childTable); |
|
|
|
const parentBaseModel = await Model.getBaseModelSQL({ |
|
|
|
const parentTn = this.getTnPath(parentTable); |
|
|
|
model: parentTable, |
|
|
|
|
|
|
|
dbDriver: this.dbDriver, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const childBaseModel = await Model.getBaseModelSQL({ |
|
|
|
|
|
|
|
dbDriver: this.dbDriver, |
|
|
|
|
|
|
|
model: childTable, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const childTn = childBaseModel.getTnPath(childTable); |
|
|
|
|
|
|
|
const parentTn = parentBaseModel.getTnPath(parentTable); |
|
|
|
|
|
|
|
|
|
|
|
const relatedChildCol = getRelatedLinksColumn( |
|
|
|
const relatedChildCol = getRelatedLinksColumn( |
|
|
|
column, |
|
|
|
column, |
|
|
@ -5582,15 +5637,20 @@ class BaseModelSqlv2 { |
|
|
|
const vParentCol = await colOptions.getMMParentColumn(this.context); |
|
|
|
const vParentCol = await colOptions.getMMParentColumn(this.context); |
|
|
|
const vTable = await colOptions.getMMModel(this.context); |
|
|
|
const vTable = await colOptions.getMMModel(this.context); |
|
|
|
|
|
|
|
|
|
|
|
const vTn = this.getTnPath(vTable); |
|
|
|
const assocBaseModel = await Model.getBaseModelSQL({ |
|
|
|
|
|
|
|
model: vTable, |
|
|
|
|
|
|
|
dbDriver: this.dbDriver, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const vTn = assocBaseModel.getTnPath(vTable); |
|
|
|
|
|
|
|
|
|
|
|
if (this.isSnowflake || this.isDatabricks) { |
|
|
|
if (this.isSnowflake || this.isDatabricks) { |
|
|
|
const parentPK = this.dbDriver(parentTn) |
|
|
|
const parentPK = parentBaseModel.dbDriver(parentTn) |
|
|
|
.select(parentColumn.column_name) |
|
|
|
.select(parentColumn.column_name) |
|
|
|
.where(_wherePk(parentTable.primaryKeys, childId)) |
|
|
|
.where(_wherePk(parentTable.primaryKeys, childId)) |
|
|
|
.first(); |
|
|
|
.first(); |
|
|
|
|
|
|
|
|
|
|
|
const childPK = this.dbDriver(childTn) |
|
|
|
const childPK = childBaseModel.dbDriver(childTn) |
|
|
|
.select(childColumn.column_name) |
|
|
|
.select(childColumn.column_name) |
|
|
|
.where(_wherePk(childTable.primaryKeys, rowId)) |
|
|
|
.where(_wherePk(childTable.primaryKeys, rowId)) |
|
|
|
.first(); |
|
|
|
.first(); |
|
|
@ -5621,11 +5681,13 @@ class BaseModelSqlv2 { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
await this.updateLastModified({ |
|
|
|
await this.updateLastModified({ |
|
|
|
|
|
|
|
baseModel: parentBaseModel, |
|
|
|
model: parentTable, |
|
|
|
model: parentTable, |
|
|
|
rowIds: [childId], |
|
|
|
rowIds: [childId], |
|
|
|
cookie, |
|
|
|
cookie, |
|
|
|
}); |
|
|
|
}); |
|
|
|
await this.updateLastModified({ |
|
|
|
await this.updateLastModified({ |
|
|
|
|
|
|
|
baseModel: childBaseModel, |
|
|
|
model: childTable, |
|
|
|
model: childTable, |
|
|
|
rowIds: [rowId], |
|
|
|
rowIds: [rowId], |
|
|
|
cookie, |
|
|
|
cookie, |
|
|
@ -5699,6 +5761,7 @@ class BaseModelSqlv2 { |
|
|
|
await triggerAfterRemoveChild(); |
|
|
|
await triggerAfterRemoveChild(); |
|
|
|
|
|
|
|
|
|
|
|
await this.updateLastModified({ |
|
|
|
await this.updateLastModified({ |
|
|
|
|
|
|
|
baseModel: parentBaseModel, |
|
|
|
model: parentTable, |
|
|
|
model: parentTable, |
|
|
|
rowIds: [rowId], |
|
|
|
rowIds: [rowId], |
|
|
|
cookie, |
|
|
|
cookie, |
|
|
@ -5811,6 +5874,7 @@ class BaseModelSqlv2 { |
|
|
|
await triggerAfterRemoveChild(); |
|
|
|
await triggerAfterRemoveChild(); |
|
|
|
|
|
|
|
|
|
|
|
await this.updateLastModified({ |
|
|
|
await this.updateLastModified({ |
|
|
|
|
|
|
|
baseModel: parentBaseModel, |
|
|
|
model: parentTable, |
|
|
|
model: parentTable, |
|
|
|
rowIds: [childId], |
|
|
|
rowIds: [childId], |
|
|
|
cookie, |
|
|
|
cookie, |
|
|
@ -6060,6 +6124,7 @@ class BaseModelSqlv2 { |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
await this.updateLastModified({ |
|
|
|
await this.updateLastModified({ |
|
|
|
|
|
|
|
baseModel: parentBaseModel, |
|
|
|
model: parentTable, |
|
|
|
model: parentTable, |
|
|
|
rowIds: [childId], |
|
|
|
rowIds: [childId], |
|
|
|
cookie, |
|
|
|
cookie, |
|
|
@ -6176,8 +6241,18 @@ class BaseModelSqlv2 { |
|
|
|
await childTable.getColumns(this.context); |
|
|
|
await childTable.getColumns(this.context); |
|
|
|
await parentTable.getColumns(this.context); |
|
|
|
await parentTable.getColumns(this.context); |
|
|
|
|
|
|
|
|
|
|
|
const childTn = this.getTnPath(childTable); |
|
|
|
const parentBaseModel = await Model.getBaseModelSQL({ |
|
|
|
const parentTn = this.getTnPath(parentTable); |
|
|
|
model: parentTable, |
|
|
|
|
|
|
|
dbDriver: this.dbDriver, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const childBaseModel = await Model.getBaseModelSQL({ |
|
|
|
|
|
|
|
dbDriver: this.dbDriver, |
|
|
|
|
|
|
|
model: childTable, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const childTn = childBaseModel.getTnPath(childTable); |
|
|
|
|
|
|
|
const parentTn = parentBaseModel.getTnPath(parentTable); |
|
|
|
|
|
|
|
|
|
|
|
const relatedChildCol = getRelatedLinksColumn( |
|
|
|
const relatedChildCol = getRelatedLinksColumn( |
|
|
|
column, |
|
|
|
column, |
|
|
@ -6210,8 +6285,11 @@ class BaseModelSqlv2 { |
|
|
|
const vChildCol = await colOptions.getMMChildColumn(this.context); |
|
|
|
const vChildCol = await colOptions.getMMChildColumn(this.context); |
|
|
|
const vParentCol = await colOptions.getMMParentColumn(this.context); |
|
|
|
const vParentCol = await colOptions.getMMParentColumn(this.context); |
|
|
|
const vTable = await colOptions.getMMModel(this.context); |
|
|
|
const vTable = await colOptions.getMMModel(this.context); |
|
|
|
|
|
|
|
const assocBaseModel = await Model.getBaseModelSQL({ |
|
|
|
const vTn = this.getTnPath(vTable); |
|
|
|
model: vTable, |
|
|
|
|
|
|
|
dbDriver: this.dbDriver, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
const vTn = assocBaseModel.getTnPath(vTable); |
|
|
|
|
|
|
|
|
|
|
|
await this.execAndParse( |
|
|
|
await this.execAndParse( |
|
|
|
this.dbDriver(vTn) |
|
|
|
this.dbDriver(vTn) |
|
|
@ -6231,11 +6309,13 @@ class BaseModelSqlv2 { |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
await this.updateLastModified({ |
|
|
|
await this.updateLastModified({ |
|
|
|
|
|
|
|
baseModel: parentBaseModel, |
|
|
|
model: parentTable, |
|
|
|
model: parentTable, |
|
|
|
rowIds: [childId], |
|
|
|
rowIds: [childId], |
|
|
|
cookie, |
|
|
|
cookie, |
|
|
|
}); |
|
|
|
}); |
|
|
|
await this.updateLastModified({ |
|
|
|
await this.updateLastModified({ |
|
|
|
|
|
|
|
baseModel: childBaseModel, |
|
|
|
model: childTable, |
|
|
|
model: childTable, |
|
|
|
rowIds: [rowId], |
|
|
|
rowIds: [rowId], |
|
|
|
cookie, |
|
|
|
cookie, |
|
|
@ -6264,6 +6344,7 @@ class BaseModelSqlv2 { |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
await this.updateLastModified({ |
|
|
|
await this.updateLastModified({ |
|
|
|
|
|
|
|
baseModel: parentBaseModel, |
|
|
|
model: parentTable, |
|
|
|
model: parentTable, |
|
|
|
rowIds: [rowId], |
|
|
|
rowIds: [rowId], |
|
|
|
cookie, |
|
|
|
cookie, |
|
|
@ -6290,6 +6371,7 @@ class BaseModelSqlv2 { |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
await this.updateLastModified({ |
|
|
|
await this.updateLastModified({ |
|
|
|
|
|
|
|
baseModel: parentBaseModel, |
|
|
|
model: parentTable, |
|
|
|
model: parentTable, |
|
|
|
rowIds: [childId], |
|
|
|
rowIds: [childId], |
|
|
|
cookie, |
|
|
|
cookie, |
|
|
@ -6312,6 +6394,7 @@ class BaseModelSqlv2 { |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
await this.updateLastModified({ |
|
|
|
await this.updateLastModified({ |
|
|
|
|
|
|
|
baseModel: parentBaseModel, |
|
|
|
model: parentTable, |
|
|
|
model: parentTable, |
|
|
|
rowIds: [childId], |
|
|
|
rowIds: [childId], |
|
|
|
cookie, |
|
|
|
cookie, |
|
|
@ -8027,11 +8110,13 @@ class BaseModelSqlv2 { |
|
|
|
cookie, |
|
|
|
cookie, |
|
|
|
model = this.model, |
|
|
|
model = this.model, |
|
|
|
knex = this.dbDriver, |
|
|
|
knex = this.dbDriver, |
|
|
|
|
|
|
|
baseModel = this, |
|
|
|
}: { |
|
|
|
}: { |
|
|
|
rowIds: any | any[]; |
|
|
|
rowIds: any | any[]; |
|
|
|
cookie?: { user?: any }; |
|
|
|
cookie?: { user?: any }; |
|
|
|
model?: Model; |
|
|
|
model?: Model; |
|
|
|
knex?: XKnex; |
|
|
|
knex?: XKnex; |
|
|
|
|
|
|
|
baseModel?: BaseModelSqlv2 |
|
|
|
}) { |
|
|
|
}) { |
|
|
|
const columns = await model.getColumns(this.context); |
|
|
|
const columns = await model.getColumns(this.context); |
|
|
|
|
|
|
|
|
|
|
@ -8055,7 +8140,7 @@ class BaseModelSqlv2 { |
|
|
|
|
|
|
|
|
|
|
|
if (Object.keys(updateObject).length === 0) return; |
|
|
|
if (Object.keys(updateObject).length === 0) return; |
|
|
|
|
|
|
|
|
|
|
|
const qb = knex(this.getTnPath(model.table_name)).update(updateObject); |
|
|
|
const qb = knex(baseModel.getTnPath(model.table_name)).update(updateObject); |
|
|
|
|
|
|
|
|
|
|
|
for (const rowId of Array.isArray(rowIds) ? rowIds : [rowIds]) { |
|
|
|
for (const rowId of Array.isArray(rowIds) ? rowIds : [rowIds]) { |
|
|
|
qb.orWhere(_wherePk(model.primaryKeys, rowId)); |
|
|
|
qb.orWhere(_wherePk(model.primaryKeys, rowId)); |
|
|
|