Adding the ability to disable SQL aliasing if necessary.
This commit is contained in:
parent
8a09f6c2d6
commit
5f76f143bf
|
@ -35,6 +35,7 @@ import { processDates, processFormulas } from "../../../utilities/rowProcessor"
|
|||
import { db as dbCore } from "@budibase/backend-core"
|
||||
import AliasTables from "./alias"
|
||||
import sdk from "../../../sdk"
|
||||
import env from "../../../environment"
|
||||
|
||||
export interface ManyRelationship {
|
||||
tableId?: string
|
||||
|
@ -884,12 +885,20 @@ export class ExternalRequest<T extends Operation> {
|
|||
},
|
||||
}
|
||||
|
||||
const aliasing = new AliasTables(Object.keys(this.tables))
|
||||
// remove any relationships that could block deletion
|
||||
if (operation === Operation.DELETE && id) {
|
||||
await this.removeRelationshipsToRow(table, generateRowIdField(id))
|
||||
}
|
||||
const response = await aliasing.queryWithAliasing(json)
|
||||
|
||||
// aliasing can be disabled fully if desired
|
||||
let response
|
||||
if (!env.SQL_ALIASING_DISABLE) {
|
||||
const aliasing = new AliasTables(Object.keys(this.tables))
|
||||
response = await aliasing.queryWithAliasing(json)
|
||||
} else {
|
||||
response = await getDatasourceAndQuery(json)
|
||||
}
|
||||
|
||||
// handle many-to-many relationships now if we know the ID (could be auto increment)
|
||||
if (operation !== Operation.READ) {
|
||||
await this.handleManyRelationships(
|
||||
|
|
|
@ -76,13 +76,16 @@ const environment = {
|
|||
DEFAULTS.AUTOMATION_THREAD_TIMEOUT > QUERY_THREAD_TIMEOUT
|
||||
? DEFAULTS.AUTOMATION_THREAD_TIMEOUT
|
||||
: QUERY_THREAD_TIMEOUT,
|
||||
SQL_MAX_ROWS: process.env.SQL_MAX_ROWS,
|
||||
BB_ADMIN_USER_EMAIL: process.env.BB_ADMIN_USER_EMAIL,
|
||||
BB_ADMIN_USER_PASSWORD: process.env.BB_ADMIN_USER_PASSWORD,
|
||||
PLUGINS_DIR: process.env.PLUGINS_DIR || DEFAULTS.PLUGINS_DIR,
|
||||
OPENAI_API_KEY: process.env.OPENAI_API_KEY,
|
||||
MAX_IMPORT_SIZE_MB: process.env.MAX_IMPORT_SIZE_MB,
|
||||
SESSION_EXPIRY_SECONDS: process.env.SESSION_EXPIRY_SECONDS,
|
||||
// SQL
|
||||
SQL_MAX_ROWS: process.env.SQL_MAX_ROWS,
|
||||
SQL_LOGGING_ENABLE: process.env.SQL_LOGGING_ENABLE,
|
||||
SQL_ALIASING_DISABLE: process.env.SQL_ALIASING_DISABLE,
|
||||
// flags
|
||||
ALLOW_DEV_AUTOMATIONS: process.env.ALLOW_DEV_AUTOMATIONS,
|
||||
DISABLE_THREADING: process.env.DISABLE_THREADING,
|
||||
|
@ -90,7 +93,6 @@ const environment = {
|
|||
DISABLE_RATE_LIMITING: process.env.DISABLE_RATE_LIMITING,
|
||||
MULTI_TENANCY: process.env.MULTI_TENANCY,
|
||||
ENABLE_ANALYTICS: process.env.ENABLE_ANALYTICS,
|
||||
ENABLE_SQL_LOGGING: process.env.ENABLE_SQL_LOGGING,
|
||||
SELF_HOSTED: process.env.SELF_HOSTED,
|
||||
HTTP_MB_LIMIT: process.env.HTTP_MB_LIMIT,
|
||||
FORKED_PROCESS_NAME:
|
||||
|
|
|
@ -688,7 +688,7 @@ class SqlQueryBuilder extends SqlTableQueryBuilder {
|
|||
}
|
||||
|
||||
log(query: string, values?: any[]) {
|
||||
if (!environment.ENABLE_SQL_LOGGING) {
|
||||
if (!environment.SQL_LOGGING_ENABLE) {
|
||||
return
|
||||
}
|
||||
const sqlClient = this.getSqlClient()
|
||||
|
|
Loading…
Reference in New Issue