Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,8 @@ private void appendDemographicsCols(final UserSchema us, AbstractTableInfo ti, C
{
for (final DemographicsSource qd : qds)
{
Container targetContainer = us.getContainer().isWorkbookOrTab() ? us.getContainer().getParent() : us.getContainer();
TableInfo target = qd.getTableInfo(targetContainer, us.getUser());
Container parentContainer = us.getContainer().isWorkbookOrTab() ? us.getContainer().getParent() : us.getContainer();
TableInfo target = qd.getTableInfo(parentContainer, us.getUser());

//TODO: push this into LaboratoryService and also cache them?
if (target != null)
Expand All @@ -290,11 +290,10 @@ private void appendDemographicsCols(final UserSchema us, AbstractTableInfo ti, C
}

String name = ColumnInfo.legalNameFromName(qd.getLabel());

if (ti.getColumn(name) != null)
continue;

BaseColumnInfo col = WrappedColumnInfo.wrapAsCopy(ti, FieldKey.fromString(name), subjectCol, qd.getLabel(), null);
ExprColumn col = new ExprColumn(ti, FieldKey.fromString(name), subjectCol.getValueSql(ExprColumn.STR_TABLE_ALIAS), JdbcType.INTEGER, subjectCol);
col.setName(name);
col.setCalculated(true);
col.setShownInInsertView(false);
Expand All @@ -304,7 +303,7 @@ private void appendDemographicsCols(final UserSchema us, AbstractTableInfo ti, C
col.setUserEditable(false);
col.setKeyField(false);

UserSchema targetSchema = qd.getTableInfo(targetContainer, us.getUser()).getUserSchema();
final UserSchema targetSchema = target.getUserSchema();
col.setFk(new QueryForeignKey(us, ti.getContainerFilter(), targetSchema, null, qd.getQueryName(), qd.getTargetColumn(), qd.getTargetColumn())
{
@Override
Expand Down