|
|
@ -158,9 +158,10 @@ class BaseModelSqlv2 { |
|
|
|
qb.orderBy(this.model.primaryKey.column_name); |
|
|
|
qb.orderBy(this.model.primaryKey.column_name); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const data = await qb.first(); |
|
|
|
let data = await qb.first(); |
|
|
|
|
|
|
|
|
|
|
|
if (data) { |
|
|
|
if (data) { |
|
|
|
|
|
|
|
data = this.convertAttachmentType(data); |
|
|
|
const proto = await this.getProto(); |
|
|
|
const proto = await this.getProto(); |
|
|
|
data.__proto__ = proto; |
|
|
|
data.__proto__ = proto; |
|
|
|
} |
|
|
|
} |
|
|
@ -365,8 +366,7 @@ class BaseModelSqlv2 { |
|
|
|
qb.groupBy(args.column_name); |
|
|
|
qb.groupBy(args.column_name); |
|
|
|
if (sorts) await sortV2(sorts, qb, this.dbDriver); |
|
|
|
if (sorts) await sortV2(sorts, qb, this.dbDriver); |
|
|
|
applyPaginate(qb, rest); |
|
|
|
applyPaginate(qb, rest); |
|
|
|
const data = await qb; |
|
|
|
return this.convertAttachmentType(await qb); |
|
|
|
return data; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async multipleHmList({ colId, ids }, args: { limit?; offset? } = {}) { |
|
|
|
async multipleHmList({ colId, ids }, args: { limit?; offset? } = {}) { |
|
|
@ -672,10 +672,10 @@ class BaseModelSqlv2 { |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
let children = await this.extractRawQueryAndExec(finalQb); |
|
|
|
let children = await this.extractRawQueryAndExec(finalQb); |
|
|
|
children = this.convertAttachmentType(children); |
|
|
|
|
|
|
|
if (this.isMySQL) { |
|
|
|
if (this.isMySQL) { |
|
|
|
children = children[0]; |
|
|
|
children = children[0]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
children = this.convertAttachmentType(children); |
|
|
|
const proto = await ( |
|
|
|
const proto = await ( |
|
|
|
await Model.getBaseModelSQL({ |
|
|
|
await Model.getBaseModelSQL({ |
|
|
|
id: rtnId, |
|
|
|
id: rtnId, |
|
|
@ -967,8 +967,8 @@ class BaseModelSqlv2 { |
|
|
|
applyPaginate(qb, rest); |
|
|
|
applyPaginate(qb, rest); |
|
|
|
|
|
|
|
|
|
|
|
const proto = await childModel.getProto(); |
|
|
|
const proto = await childModel.getProto(); |
|
|
|
const data = await qb; |
|
|
|
let data = await qb; |
|
|
|
|
|
|
|
data = this.convertAttachmentType(data); |
|
|
|
return data.map((c) => { |
|
|
|
return data.map((c) => { |
|
|
|
c.__proto__ = proto; |
|
|
|
c.__proto__ = proto; |
|
|
|
return c; |
|
|
|
return c; |
|
|
@ -2737,6 +2737,15 @@ class BaseModelSqlv2 { |
|
|
|
: await this.dbDriver.raw(query); |
|
|
|
: await this.dbDriver.raw(query); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private _convertAttachmentType(attachmentColumns, d) { |
|
|
|
|
|
|
|
attachmentColumns.forEach((col) => { |
|
|
|
|
|
|
|
if (d[col.title] && typeof d[col.title] === 'string') { |
|
|
|
|
|
|
|
d[col.title] = JSON.parse(d[col.title]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
return d; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private convertAttachmentType(data) { |
|
|
|
private convertAttachmentType(data) { |
|
|
|
// attachment is stored in text and parse in UI
|
|
|
|
// attachment is stored in text and parse in UI
|
|
|
|
// convertAttachmentType is used to convert the response in string to array of object in API response
|
|
|
|
// convertAttachmentType is used to convert the response in string to array of object in API response
|
|
|
@ -2745,17 +2754,13 @@ class BaseModelSqlv2 { |
|
|
|
(c) => c.uidt === UITypes.Attachment |
|
|
|
(c) => c.uidt === UITypes.Attachment |
|
|
|
); |
|
|
|
); |
|
|
|
if (attachmentColumns.length) { |
|
|
|
if (attachmentColumns.length) { |
|
|
|
if (!Array.isArray(data)) { |
|
|
|
if (Array.isArray(data)) { |
|
|
|
data = [data]; |
|
|
|
data = data.map((d) => |
|
|
|
} |
|
|
|
this._convertAttachmentType(attachmentColumns, d) |
|
|
|
data = data.map((d) => { |
|
|
|
); |
|
|
|
attachmentColumns.forEach((col) => { |
|
|
|
} else { |
|
|
|
if (d[col.title] && typeof d[col.title] === 'string') { |
|
|
|
this._convertAttachmentType(attachmentColumns, data); |
|
|
|
d[col.title] = JSON.parse(d[col.title]); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
return d; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return data; |
|
|
|
return data; |
|
|
|