diff --git a/packages/server/src/api/controllers/row/alias.ts b/packages/server/src/api/controllers/row/alias.ts index d2d41e085f..c27bed6a4b 100644 --- a/packages/server/src/api/controllers/row/alias.ts +++ b/packages/server/src/api/controllers/row/alias.ts @@ -57,13 +57,15 @@ export default class AliasTables { const tableNames = this.tableNames if (field.includes(".")) { const [tableName, column] = field.split(".") - const foundTableName = tableNames.find(name => tableName.includes(name)) + const foundTableName = tableNames.find( + name => tableName.includes(name) && tableName.indexOf(name) <= 1 + ) if (foundTableName) { const aliasedTableName = tableName.replace( foundTableName, this.getAlias(foundTableName) ) - return `${aliasedTableName}.${column}` + field = `${aliasedTableName}.${column}` } } return field