|
|
|
@ -1266,7 +1266,10 @@ class BaseModelSql extends BaseModel {
|
|
|
|
|
); |
|
|
|
|
let { fields } = restArgs; |
|
|
|
|
const { cn } = this.hasManyRelations.find(({ tn }) => tn === child) || {}; |
|
|
|
|
const _cn = this.dbModels[child].columnToAlias?.[cn]; |
|
|
|
|
if (!this.dbModels[child]) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
const _cn = this.dbModels[child]?.columnToAlias?.[cn]; |
|
|
|
|
|
|
|
|
|
if (fields !== '*' && fields.split(',').indexOf(cn) === -1) { |
|
|
|
|
fields += ',' + cn; |
|
|
|
@ -1345,6 +1348,10 @@ class BaseModelSql extends BaseModel {
|
|
|
|
|
fields += ',' + cn; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!this.dbModels[child]) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const childs = await this._run( |
|
|
|
|
driver.union( |
|
|
|
|
parentIds.map(id => { |
|
|
|
@ -1498,7 +1505,11 @@ class BaseModelSql extends BaseModel {
|
|
|
|
|
fields += ',' + this.pks[0].cn; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (parents) |
|
|
|
|
for (const parent of parents.split(',')) { |
|
|
|
|
if (!parent) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
const { cn } = |
|
|
|
|
this.belongsToRelations.find(({ rtn }) => rtn === parent) || {}; |
|
|
|
|
if (fields !== '*' && fields.split(',').indexOf(cn) === -1) { |
|
|
|
@ -1525,6 +1536,7 @@ class BaseModelSql extends BaseModel {
|
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (parents) |
|
|
|
|
await Promise.all( |
|
|
|
|
parents.split(',').map((parent, index): any => { |
|
|
|
|
if (!parent) { |
|
|
|
@ -1945,6 +1957,8 @@ class BaseModelSql extends BaseModel {
|
|
|
|
|
fields += ',' + rcn; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!this.dbModels[parent]) return; |
|
|
|
|
|
|
|
|
|
const parents = await this._run( |
|
|
|
|
driver(this.dbModels[parent].tnPath) |
|
|
|
|
// .select(...fields.split(',')
|
|
|
|
|