Adding SQL_MAX_RELATED_ROWS environment variable, defaults to 500, allows for 500 rows per relationship.
This commit is contained in:
parent
5e80a975dd
commit
f63c95e44c
|
@ -171,6 +171,7 @@ const environment = {
|
|||
// Couch/search
|
||||
SQL_LOGGING_ENABLE: process.env.SQL_LOGGING_ENABLE,
|
||||
SQL_MAX_ROWS: process.env.SQL_MAX_ROWS,
|
||||
SQL_MAX_RELATED_ROWS: process.env.MAX_RELATED_ROWS,
|
||||
// smtp
|
||||
SMTP_FALLBACK_ENABLED: process.env.SMTP_FALLBACK_ENABLED,
|
||||
SMTP_USER: process.env.SMTP_USER,
|
||||
|
|
|
@ -49,6 +49,13 @@ function getBaseLimit() {
|
|||
return envLimit || 5000
|
||||
}
|
||||
|
||||
function getRelationshipLimit() {
|
||||
const envLimit = environment.SQL_MAX_RELATED_ROWS
|
||||
? parseInt(environment.SQL_MAX_RELATED_ROWS)
|
||||
: null
|
||||
return envLimit || 500
|
||||
}
|
||||
|
||||
function getTableName(table?: Table): string | undefined {
|
||||
// SQS uses the table ID rather than the table name
|
||||
if (
|
||||
|
@ -921,7 +928,7 @@ class InternalBuilder {
|
|||
const primaryKey = `${toAlias}.${toPrimary || toKey}`
|
||||
let subQuery: Knex.QueryBuilder = knex
|
||||
.from(toTableWithSchema)
|
||||
.limit(getBaseLimit())
|
||||
.limit(getRelationshipLimit())
|
||||
// add sorting to get consistent order
|
||||
.orderBy(primaryKey)
|
||||
|
||||
|
|
Loading…
Reference in New Issue