|
|
@ -1631,16 +1631,25 @@ class BaseModelSqlv2 { |
|
|
|
}`,
|
|
|
|
}`,
|
|
|
|
], |
|
|
|
], |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
break; |
|
|
|
} else if (this.isPg) { |
|
|
|
} else if (this.isPg) { |
|
|
|
// TODO
|
|
|
|
// if there is no timezone info, convert it to UTC
|
|
|
|
res[sanitize(column.title || column.column_name)] = sanitize( |
|
|
|
if (column.dt !== 'timestamp with time zone') { |
|
|
|
`${alias || this.model.table_name}.${column.column_name}`, |
|
|
|
res[sanitize(column.title || column.column_name)] = |
|
|
|
); |
|
|
|
this.dbDriver.raw( |
|
|
|
} else { |
|
|
|
`?? AT TIME ZONE CURRENT_SETTING('timezone') AT TIME ZONE 'UTC'`, |
|
|
|
res[sanitize(column.title || column.column_name)] = sanitize( |
|
|
|
[ |
|
|
|
`${alias || this.model.table_name}.${column.column_name}`, |
|
|
|
`${sanitize(alias || this.model.table_name)}.${ |
|
|
|
); |
|
|
|
column.column_name |
|
|
|
|
|
|
|
}`,
|
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
res[sanitize(column.title || column.column_name)] = sanitize( |
|
|
|
|
|
|
|
`${alias || this.model.table_name}.${column.column_name}`, |
|
|
|
|
|
|
|
); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 'LinkToAnotherRecord': |
|
|
|
case 'LinkToAnotherRecord': |
|
|
|
case 'Lookup': |
|
|
|
case 'Lookup': |
|
|
@ -2191,10 +2200,6 @@ class BaseModelSqlv2 { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// set the session timezone
|
|
|
|
|
|
|
|
// see the comments in function for details
|
|
|
|
|
|
|
|
await this.setUtcTimezone(trx); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const response = |
|
|
|
const response = |
|
|
|
this.isPg || this.isMssql |
|
|
|
this.isPg || this.isMssql |
|
|
|
? await trx |
|
|
|
? await trx |
|
|
@ -2256,10 +2261,6 @@ class BaseModelSqlv2 { |
|
|
|
|
|
|
|
|
|
|
|
transaction = await this.dbDriver.transaction(); |
|
|
|
transaction = await this.dbDriver.transaction(); |
|
|
|
|
|
|
|
|
|
|
|
// set the session timezone
|
|
|
|
|
|
|
|
// see the comments in function for details
|
|
|
|
|
|
|
|
await this.setUtcTimezone(transaction); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (const o of toBeUpdated) { |
|
|
|
for (const o of toBeUpdated) { |
|
|
|
await transaction(this.tnPath).update(o.d).where(o.wherePk); |
|
|
|
await transaction(this.tnPath).update(o.d).where(o.wherePk); |
|
|
|
} |
|
|
|
} |
|
|
@ -3225,10 +3226,6 @@ class BaseModelSqlv2 { |
|
|
|
query = sanitize(query); |
|
|
|
query = sanitize(query); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// set the session timezone
|
|
|
|
|
|
|
|
// see the comments in function for details
|
|
|
|
|
|
|
|
await this.setUtcTimezone(this.dbDriver); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let data = |
|
|
|
let data = |
|
|
|
this.isPg || this.isSnowflake |
|
|
|
this.isPg || this.isSnowflake |
|
|
|
? (await this.dbDriver.raw(query))?.rows |
|
|
|
? (await this.dbDriver.raw(query))?.rows |
|
|
@ -3391,12 +3388,6 @@ class BaseModelSqlv2 { |
|
|
|
} |
|
|
|
} |
|
|
|
return data; |
|
|
|
return data; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private async setUtcTimezone(knex) { |
|
|
|
|
|
|
|
if (this.isPg) { |
|
|
|
|
|
|
|
await knex.raw(`SET TIME ZONE 'UTC'`); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function extractSortsObject( |
|
|
|
function extractSortsObject( |
|
|
|