@@ -277,8 +277,8 @@ private void appendDemographicsCols(final UserSchema us, AbstractTableInfo ti, C
277277 {
278278 for (final DemographicsSource qd : qds )
279279 {
280- Container targetContainer = us .getContainer ().isWorkbookOrTab () ? us .getContainer ().getParent () : us .getContainer ();
281- TableInfo target = qd .getTableInfo (targetContainer , us .getUser ());
280+ Container parentContainer = us .getContainer ().isWorkbookOrTab () ? us .getContainer ().getParent () : us .getContainer ();
281+ TableInfo target = qd .getTableInfo (parentContainer , us .getUser ());
282282
283283 //TODO: push this into LaboratoryService and also cache them?
284284 if (target != null )
@@ -290,11 +290,10 @@ private void appendDemographicsCols(final UserSchema us, AbstractTableInfo ti, C
290290 }
291291
292292 String name = ColumnInfo .legalNameFromName (qd .getLabel ());
293-
294293 if (ti .getColumn (name ) != null )
295294 continue ;
296295
297- BaseColumnInfo col = WrappedColumnInfo . wrapAsCopy (ti , FieldKey .fromString (name ), subjectCol , qd . getLabel ( ), null );
296+ ExprColumn col = new ExprColumn (ti , FieldKey .fromString (name ), subjectCol . getValueSql ( ExprColumn . STR_TABLE_ALIAS ), JdbcType . INTEGER , subjectCol );
298297 col .setName (name );
299298 col .setCalculated (true );
300299 col .setShownInInsertView (false );
@@ -304,7 +303,7 @@ private void appendDemographicsCols(final UserSchema us, AbstractTableInfo ti, C
304303 col .setUserEditable (false );
305304 col .setKeyField (false );
306305
307- UserSchema targetSchema = qd . getTableInfo ( targetContainer , us . getUser ()) .getUserSchema ();
306+ final UserSchema targetSchema = target .getUserSchema ();
308307 col .setFk (new QueryForeignKey (us , ti .getContainerFilter (), targetSchema , null , qd .getQueryName (), qd .getTargetColumn (), qd .getTargetColumn ())
309308 {
310309 @ Override
0 commit comments