|
|
|
@ -100,7 +100,7 @@ class BaseModelSqlv2 {
|
|
|
|
|
|
|
|
|
|
qb.where(_wherePk(this.model.primaryKeys, id)); |
|
|
|
|
|
|
|
|
|
let data = (await this.extractRawQueryAndExec(qb))?.[0]; |
|
|
|
|
let data = (await this.execAndParse(qb))?.[0]; |
|
|
|
|
|
|
|
|
|
if (data) { |
|
|
|
|
const proto = await this.getProto(); |
|
|
|
@ -252,7 +252,7 @@ class BaseModelSqlv2 {
|
|
|
|
|
|
|
|
|
|
if (!ignoreViewFilterAndSort) applyPaginate(qb, rest); |
|
|
|
|
const proto = await this.getProto(); |
|
|
|
|
let data = await this.extractRawQueryAndExec(qb); |
|
|
|
|
let data = await this.execAndParse(qb); |
|
|
|
|
|
|
|
|
|
return data?.map((d) => { |
|
|
|
|
d.__proto__ = proto; |
|
|
|
@ -423,7 +423,7 @@ class BaseModelSqlv2 {
|
|
|
|
|
.as('list') |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
let children = await this.extractRawQueryAndExec(childQb, childTable); |
|
|
|
|
let children = await this.execAndParse(childQb, childTable); |
|
|
|
|
const proto = await ( |
|
|
|
|
await Model.getBaseModelSQL({ |
|
|
|
|
id: childTable.id, |
|
|
|
@ -550,7 +550,7 @@ class BaseModelSqlv2 {
|
|
|
|
|
|
|
|
|
|
await childModel.selectObject({ qb }); |
|
|
|
|
|
|
|
|
|
let children = await this.extractRawQueryAndExec(qb, childTable); |
|
|
|
|
let children = await this.execAndParse(qb, childTable); |
|
|
|
|
|
|
|
|
|
const proto = await ( |
|
|
|
|
await Model.getBaseModelSQL({ |
|
|
|
@ -667,7 +667,7 @@ class BaseModelSqlv2 {
|
|
|
|
|
!this.isSqlite |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
let children = await this.extractRawQueryAndExec(finalQb, childTable); |
|
|
|
|
let children = await this.execAndParse(finalQb, childTable); |
|
|
|
|
if (this.isMySQL) { |
|
|
|
|
children = children[0]; |
|
|
|
|
} |
|
|
|
@ -735,7 +735,7 @@ class BaseModelSqlv2 {
|
|
|
|
|
qb.limit(+rest?.limit || 25); |
|
|
|
|
qb.offset(+rest?.offset || 0); |
|
|
|
|
|
|
|
|
|
let children = await this.extractRawQueryAndExec(qb, childTable); |
|
|
|
|
let children = await this.execAndParse(qb, childTable); |
|
|
|
|
const proto = await ( |
|
|
|
|
await Model.getBaseModelSQL({ id: rtnId, dbDriver: this.dbDriver }) |
|
|
|
|
).getProto(); |
|
|
|
@ -1075,7 +1075,7 @@ class BaseModelSqlv2 {
|
|
|
|
|
applyPaginate(qb, rest); |
|
|
|
|
|
|
|
|
|
const proto = await childModel.getProto(); |
|
|
|
|
let data = await this.extractRawQueryAndExec(qb, childTable); |
|
|
|
|
let data = await this.execAndParse(qb, childTable); |
|
|
|
|
|
|
|
|
|
return data.map((c) => { |
|
|
|
|
c.__proto__ = proto; |
|
|
|
@ -1193,7 +1193,7 @@ class BaseModelSqlv2 {
|
|
|
|
|
applyPaginate(qb, rest); |
|
|
|
|
|
|
|
|
|
const proto = await parentModel.getProto(); |
|
|
|
|
let data = await this.extractRawQueryAndExec(qb, childTable); |
|
|
|
|
let data = await this.execAndParse(qb, childTable); |
|
|
|
|
|
|
|
|
|
return data.map((c) => { |
|
|
|
|
c.__proto__ = proto; |
|
|
|
@ -1525,7 +1525,7 @@ class BaseModelSqlv2 {
|
|
|
|
|
query.returning( |
|
|
|
|
`${this.model.primaryKey.column_name} as ${this.model.primaryKey.title}` |
|
|
|
|
); |
|
|
|
|
response = await this.extractRawQueryAndExec(query); |
|
|
|
|
response = await this.execAndParse(query); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const ai = this.model.columns.find((c) => c.ai); |
|
|
|
@ -1535,7 +1535,7 @@ class BaseModelSqlv2 {
|
|
|
|
|
|
|
|
|
|
// handle if autogenerated primary key is used
|
|
|
|
|
if (ag) { |
|
|
|
|
if (!response) await this.extractRawQueryAndExec(query); |
|
|
|
|
if (!response) await this.execAndParse(query); |
|
|
|
|
response = await this.readByPk(data[ag.title]); |
|
|
|
|
} else if ( |
|
|
|
|
!response || |
|
|
|
@ -1545,7 +1545,7 @@ class BaseModelSqlv2 {
|
|
|
|
|
if (response?.length) { |
|
|
|
|
id = response[0]; |
|
|
|
|
} else { |
|
|
|
|
const res = await this.extractRawQueryAndExec(query); |
|
|
|
|
const res = await this.execAndParse(query); |
|
|
|
|
id = res?.id ?? res[0]?.insertId; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1650,7 +1650,7 @@ class BaseModelSqlv2 {
|
|
|
|
|
.update(updateObj) |
|
|
|
|
.where(await this._wherePk(id)); |
|
|
|
|
|
|
|
|
|
await this.extractRawQueryAndExec(query); |
|
|
|
|
await this.execAndParse(query); |
|
|
|
|
|
|
|
|
|
const response = await this.readByPk(id); |
|
|
|
|
await this.afterUpdate(response, trx, cookie); |
|
|
|
@ -2755,7 +2755,7 @@ class BaseModelSqlv2 {
|
|
|
|
|
return await qb; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private async extractRawQueryAndExec( |
|
|
|
|
private async execAndParse( |
|
|
|
|
qb: Knex.QueryBuilder, |
|
|
|
|
childTable?: Model |
|
|
|
|
) { |
|
|
|
|