mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-18 13:10:44 +00:00
Fix some cases of joins in exports w/ multiple possible paths
This commit is contained in:
@ -197,7 +197,27 @@ public class ExportAction
|
|||||||
String joinTableName = parts[0];
|
String joinTableName = parts[0];
|
||||||
if(!addedJoinNames.contains(joinTableName))
|
if(!addedJoinNames.contains(joinTableName))
|
||||||
{
|
{
|
||||||
queryJoins.add(new QueryJoin(joinTableName).withType(QueryJoin.Type.LEFT).withSelect(true));
|
QueryJoin queryJoin = new QueryJoin(joinTableName).withType(QueryJoin.Type.LEFT).withSelect(true);
|
||||||
|
queryJoins.add(queryJoin);
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// in at least some cases, we need to let the queryJoin know what join-meta-data to use... //
|
||||||
|
// This code basically mirrors what QFMD is doing right now, so it's better - //
|
||||||
|
// but shouldn't all of this just be in JoinsContext? it does some of this... //
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
QTableMetaData table = exportInput.getTable();
|
||||||
|
Optional<ExposedJoin> exposedJoinOptional = CollectionUtils.nonNullList(table.getExposedJoins()).stream().filter(ej -> ej.getJoinTable().equals(joinTableName)).findFirst();
|
||||||
|
if(exposedJoinOptional.isEmpty())
|
||||||
|
{
|
||||||
|
throw (new QException("Could not find exposed join between base table " + table.getName() + " and requested join table " + joinTableName));
|
||||||
|
}
|
||||||
|
ExposedJoin exposedJoin = exposedJoinOptional.get();
|
||||||
|
|
||||||
|
if(exposedJoin.getJoinPath().size() == 1)
|
||||||
|
{
|
||||||
|
queryJoin.setJoinMetaData(QContext.getQInstance().getJoin(exposedJoin.getJoinPath().get(exposedJoin.getJoinPath().size() - 1)));
|
||||||
|
}
|
||||||
|
|
||||||
addedJoinNames.add(joinTableName);
|
addedJoinNames.add(joinTableName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user